From 56fe7de7a2d11ebff7157845b330d7ee9cbc0b53 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 19 Oct 2026 20:42:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E4=B8=BB=E7=B3=BB=E7=BB=9F=E7=BB=91=E5=AE=9A=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E3=80=8C=E4=B8=8A=E9=97=A8=E5=8F=96=E8=B4=A7?= =?UTF-8?q?=E3=80=8D=E5=BC=80=E5=85=B3=EF=BC=9B=E5=90=8E=E7=AB=AF=E6=94=B9?= =?UTF-8?q?=E8=AF=A5=E5=BC=80=E5=85=B3=E8=BF=94=E5=9B=9E=20409=EF=BC=88?= =?UTF-8?q?=E5=BE=85=E5=8F=96=E8=B4=A7=E5=8F=AA=E7=94=B1=E4=B8=BB=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=85=8D=E5=85=A5=E5=BA=93=E5=86=B3=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/services/selfPickupCustomerService.ts | 11 +++++++++-- src/pages/customers/CustomerManagement.tsx | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/server/src/services/selfPickupCustomerService.ts b/server/src/services/selfPickupCustomerService.ts index 2000e89..544d52a 100644 --- a/server/src/services/selfPickupCustomerService.ts +++ b/server/src/services/selfPickupCustomerService.ts @@ -30,12 +30,19 @@ export async function setCustomerSelfPickup(input: { const enabled = input.enabled === true; return runWithTenantDbContext(branchCode, async () => { - const before = await pool.query<{ is_self_pickup: boolean | null }>( - `SELECT COALESCE(is_self_pickup, false) AS is_self_pickup + const before = await pool.query<{ is_self_pickup: boolean | null; source: string | null }>( + `SELECT COALESCE(is_self_pickup, false) AS is_self_pickup, source FROM customers WHERE customer_code = $1 LIMIT 1`, [customerCode] ); if (!before.rowCount) throw businessError('客户不存在', 404, 'not_found'); + /** + * 主系统按绑定编码分配过来的客户:其「待取货」只由主系统「免入库」决定, + * 不允许在我方客户列表改这个开关(2026-10-19 开发者口径)。 + */ + if (String(before.rows[0]?.source || '') === 'main_system') { + throw businessError('主系统客户的「上门取货」由主系统免入库决定,不能在此修改', 409, 'main_system_customer_locked'); + } const previous = before.rows[0]?.is_self_pickup === true; if (previous === enabled) { diff --git a/src/pages/customers/CustomerManagement.tsx b/src/pages/customers/CustomerManagement.tsx index 178845f..35756fe 100644 --- a/src/pages/customers/CustomerManagement.tsx +++ b/src/pages/customers/CustomerManagement.tsx @@ -94,6 +94,8 @@ interface Customer { credit_frozen?: boolean | null; /** 客户「是否取货」(自提,2026-10-15 需求):其订单不走配送,分拣完毕进 50「待取货」 */ is_self_pickup?: boolean | null; + /** 客户来源:main_system = 主系统按绑定编码分配过来的客户 */ + source?: string | null; settlement_days: number | null; status: number | null; customer_type?: string | null; @@ -879,7 +881,7 @@ export const CustomerManagement: React.FC = () => { useEffect(() => { void supabase .from('customers') - .select('customer_code, company_name') + .select('customer_code, company_name, source') .eq('customer_role', 'account') .eq('status', 10) .order('company_name') @@ -980,7 +982,7 @@ export const CustomerManagement: React.FC = () => { const code = `CUS${Date.now().toString().slice(-9)}${Math.floor(Math.random() * 90 + 10)}`; const { data } = await supabase .from('customers') - .select('customer_code') + .select('customer_code, source') .eq('customer_code', code) .maybeSingle(); if (!data) return code; @@ -1962,6 +1964,18 @@ export const CustomerManagement: React.FC = () => { ); case 'self_pickup': + /** + * 主系统按绑定编码分配过来的客户(`source='main_system'`): + * 其「待取货」只由**主系统「免入库」**决定,我方不允许改这个开关 ⇒ 直接不显示。 + * (2026-10-19 开发者口径:这类客户给按钮隐藏掉) + */ + if (c.source === 'main_system') { + return ( + + — + + ); + } return (