fix(拆单脚本): 互斥旧生效单时排除源单自身(生产演练发现源单被误置 status=3)
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 18:26:17 +08:00
parent a180ee7320
commit 2ee38fb400
@@ -14,8 +14,8 @@
* ⚠️ 本库业务表启用 **RLS**:不带 `app.branch_code` 时查询恒为 0 行(2026-10-18 实测)。
* 所以所有查询/写入都必须在 `withTenant()` 内执行。
*/
import { pool } from '../src/db';
import { newSheetCode } from '../src/services/quoteSheetService';
import { pool } from '../dist/db';
import { newSheetCode } from '../dist/services/quoteSheetService';
const argv = process.argv.slice(2);
const execute = argv.includes('--execute');
@@ -209,11 +209,11 @@ async function main() {
);
await client.query(
`UPDATE ${schema}.customer_quote_sheets SET status = 3, updated_at = NOW()
WHERE status = 1 AND quote_sheet_code <> $1
WHERE status = 1 AND quote_sheet_code <> $1 AND quote_sheet_code <> $3
AND quote_sheet_code IN (
SELECT quote_sheet_code FROM ${schema}.customer_quote_sheet_customers WHERE customer_code = $2
)`,
[nextCode, extra]
[nextCode, extra, row.code]
);
createdCodes.push(`${extra}=${nextCode}`);
}