From a5f00d7e31e4a9bff1c8311cee28de9875ea750c Mon Sep 17 00:00:00 2001 From: wushumin Date: Tue, 26 May 2026 17:08:33 +0800 Subject: [PATCH] feat: add kuaidi100 logistics sync --- AGENTS.md | 4 +- CLAUDE.md | 4 +- admin-web/src/api/admin.ts | 68 ++ .../src/pages/express-companies/index.vue | 135 ++- admin-web/src/pages/orders/index.vue | 117 ++- admin-web/src/pages/system-config/index.vue | 2 +- .../admin/ExpressCompaniesController.php | 48 ++ .../app/controller/admin/OrdersController.php | 53 +- .../admin/SystemConfigsController.php | 56 ++ .../app/controller/app/OrdersController.php | 9 + .../app/controller/app/ShippingController.php | 33 + .../controller/open/Kuaidi100Controller.php | 43 + .../app/middleware/AdminAuthMiddleware.php | 1 + .../process/Kuaidi100LogisticsSyncProcess.php | 26 + .../app/support/ExpressCompanyService.php | 781 +++++++++++++++++- .../app/support/FulfillmentFlowService.php | 45 + server-api/app/support/Kuaidi100Client.php | 187 +++++ .../app/support/Kuaidi100ConfigService.php | 61 ++ .../app/support/OrderLogisticsSyncService.php | 557 +++++++++++++ server-api/config/process.php | 4 + server-api/config/route.php | 6 + server-api/database/schema.sql | 39 + server-api/tools/db_seed.php | 4 +- .../schema_upgrade_express_companies.php | 8 +- user-app/src/api/app.ts | 33 + user-app/src/mocks/app.ts | 3 + user-app/src/pages/order/detail.vue | 31 +- user-app/src/pages/order/shipping.vue | 79 +- work-app/src/api/admin.ts | 70 ++ work-app/src/pages/order/detail.vue | 47 ++ work-app/src/pages/return-shipping/index.vue | 109 ++- 31 files changed, 2596 insertions(+), 67 deletions(-) create mode 100644 server-api/app/controller/open/Kuaidi100Controller.php create mode 100644 server-api/app/process/Kuaidi100LogisticsSyncProcess.php create mode 100644 server-api/app/support/Kuaidi100Client.php create mode 100644 server-api/app/support/Kuaidi100ConfigService.php create mode 100644 server-api/app/support/OrderLogisticsSyncService.php diff --git a/AGENTS.md b/AGENTS.md index 82c6e23..282f0d7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **anxinyan** (4880 symbols, 11926 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **anxinyan** (5063 symbols, 12441 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. @@ -40,4 +40,4 @@ This project is indexed by GitNexus as **anxinyan** (4880 symbols, 11926 relatio | Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` | | Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` | - \ No newline at end of file + diff --git a/CLAUDE.md b/CLAUDE.md index 82c6e23..282f0d7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **anxinyan** (4880 symbols, 11926 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **anxinyan** (5063 symbols, 12441 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. @@ -40,4 +40,4 @@ This project is indexed by GitNexus as **anxinyan** (4880 symbols, 11926 relatio | Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` | | Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` | - \ No newline at end of file + diff --git a/admin-web/src/api/admin.ts b/admin-web/src/api/admin.ts index a415067..962ce9b 100644 --- a/admin-web/src/api/admin.ts +++ b/admin-web/src/api/admin.ts @@ -253,6 +253,9 @@ export interface AdminOrderDetail { tracking_no: string; tracking_status: string; tracking_status_text: string; + provider_status_text: string; + sync_status_text: string; + sync_error: string; latest_desc: string; latest_time: string; nodes: Array<{ @@ -266,6 +269,9 @@ export interface AdminOrderDetail { tracking_no: string; tracking_status: string; tracking_status_text: string; + provider_status_text: string; + sync_status_text: string; + sync_error: string; latest_desc: string; latest_time: string; nodes: Array<{ @@ -1183,6 +1189,37 @@ export interface AdminExpressCompanyItem { updated_at: string; } +export interface AdminExpressCompanyCatalogItem { + id: number; + company_name: string; + company_code: string; + company_type: string; + display_text: string; + source: string; + synced_at: string; +} + +export interface AdminExpressCompanyRecognitionCandidate { + company_name: string; + company_code: string; + official_name?: string; + display_text: string; + length_pre?: number; + source: string; +} + +export interface AdminExpressCompanyRecognitionResult { + input: string; + tracking_no: string; + company_code: string; + company_name: string; + status: string; + status_text: string; + error_message?: string; + resolved: null | AdminExpressCompanyRecognitionCandidate; + candidates: AdminExpressCompanyRecognitionCandidate[]; +} + export interface AdminExpressCompanyPayload { id?: number; company_name: string; @@ -2288,6 +2325,37 @@ export const adminApi = { }; }>; }, + getExpressCompanyCatalog(params?: { keyword?: string; limit?: number }) { + return request.get("/api/admin/express-company/catalog", { params }) as Promise<{ + code: number; + message: string; + data: { + list: AdminExpressCompanyCatalogItem[]; + total: number; + synced_at: string; + }; + }>; + }, + syncExpressCompanyCatalog() { + return request.post("/api/admin/express-company/catalog/sync") as Promise<{ + code: number; + message: string; + data: { + total: number; + inserted: number; + updated: number; + backfilled: number; + synced_at: string; + }; + }>; + }, + recognizeExpressCompany(data: { tracking_no: string; company_name?: string; company_code?: string }) { + return request.post("/api/admin/express-company/recognize", data) as Promise<{ + code: number; + message: string; + data: AdminExpressCompanyRecognitionResult; + }>; + }, saveExpressCompany(data: AdminExpressCompanyPayload) { return request.post("/api/admin/express-company/save", data) as Promise<{ code: number; diff --git a/admin-web/src/pages/express-companies/index.vue b/admin-web/src/pages/express-companies/index.vue index d359519..132b506 100644 --- a/admin-web/src/pages/express-companies/index.vue +++ b/admin-web/src/pages/express-companies/index.vue @@ -1,20 +1,29 @@