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 (