feat(客户列表): 主系统绑定客户隐藏「上门取货」开关;后端改该开关返回 409(待取货只由主系统免入库决定)
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

This commit is contained in:
Ubuntu
2026-10-19 20:42:45 +08:00
parent dac43897bb
commit 56fe7de7a2
2 changed files with 25 additions and 4 deletions
@@ -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) {
+16 -2
View File
@@ -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 = () => {
</td>
);
case 'self_pickup':
/**
* 主系统按绑定编码分配过来的客户(`source='main_system'`):
* 其「待取货」只由**主系统「免入库」**决定,我方不允许改这个开关 ⇒ 直接不显示。
* (2026-10-19 开发者口径:这类客户给按钮隐藏掉)
*/
if (c.source === 'main_system') {
return (
<td key={col.id} className="px-4 py-4">
<span className="app-foreground-muted text-xs">—</span>
</td>
);
}
return (
<td key={col.id} className="px-4 py-4">
<label