fix(拆单脚本): 互斥旧生效单时排除源单自身(生产演练发现源单被误置 status=3)
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user