feat: add kuaidi100 logistics sync

This commit is contained in:
wushumin
2026-05-26 17:08:33 +08:00
parent 09d9fcbe69
commit a5f00d7e31
31 changed files with 2596 additions and 67 deletions

View File

@@ -45,14 +45,18 @@ CREATE TABLE IF NOT EXISTS express_companies (
SQL);
$now = date('Y-m-d H:i:s');
$stmt = $pdo->prepare('SELECT id FROM express_companies WHERE company_name = ? LIMIT 1');
$stmt = $pdo->prepare('SELECT id, company_code FROM express_companies WHERE company_name = ? LIMIT 1');
$stmt->execute(['顺丰速运']);
$exists = $stmt->fetch();
if (!$exists) {
$insert = $pdo->prepare('INSERT INTO express_companies (company_name, company_code, status, is_default, sort_order, remark, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
$insert->execute(['顺丰速运', 'sf_express', 'enabled', 1, 1, '系统默认快递公司', $now, $now]);
$insert->execute(['顺丰速运', 'shunfeng', 'enabled', 1, 1, '系统默认快递公司', $now, $now]);
echo "SEED_DEFAULT_EXPRESS_COMPANY\n";
} elseif (in_array((string)($exists['company_code'] ?? ''), ['', 'sf_express'], true) || str_starts_with((string)($exists['company_code'] ?? ''), 'express_')) {
$update = $pdo->prepare('UPDATE express_companies SET company_code = ?, updated_at = ? WHERE id = ?');
$update->execute(['shunfeng', $now, (int)$exists['id']]);
echo "UPDATE_DEFAULT_EXPRESS_COMPANY_CODE\n";
}
$defaultCount = (int)$pdo->query("SELECT COUNT(*) FROM express_companies WHERE status = 'enabled' AND is_default = 1")->fetchColumn();