来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { readFileSync } from 'node:fs';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* 自采列表「配送日」序列化回归守卫(2026-09-21 事故)。
|
|
*
|
|
* `orders.delivery_date` 是 date 列。服务端没有为 pg 的 date 类型(OID 1082)注册解析器时,
|
|
* node-postgres 会把它变成 JS Date(进程本地时区的午夜),`res.json` 再序列化成 UTC ISO 串:
|
|
* 2026-09-09(中国)→ "2026-09-08T16:00:00.000Z"
|
|
* 前端对展示字段取前 10 位就得到 2026-09-08 —— 筛选窗内(按 SQL 口径正确)的行显示成前一天,
|
|
* 表现为「选了 09-09~09-17,却出现 09-08」。
|
|
*
|
|
* 仓库里正确的既有写法是 to_char(..., 'YYYY-MM-DD')(备货列表、倒挂风险表都这么做)。
|
|
*/
|
|
const serviceSrc = readFileSync(
|
|
path.join(__dirname, '../src/services/purchaseOrderQueryService.ts'),
|
|
'utf8'
|
|
);
|
|
|
|
describe('自采列表配送日:以纯日期串下发,不下发 date 列的 Date/ISO', () => {
|
|
it('order_delivery_date 用 to_char 输出 YYYY-MM-DD', () => {
|
|
expect(serviceSrc).toContain("to_char(o.delivery_date, 'YYYY-MM-DD') AS order_delivery_date");
|
|
});
|
|
|
|
it('不再裸选 o.delivery_date AS order_delivery_date', () => {
|
|
expect(serviceSrc).not.toMatch(/o\.delivery_date\s+AS\s+order_delivery_date/);
|
|
});
|
|
|
|
it('对照:备货列表与风险表同样使用 to_char 纯日期串(口径一致)', () => {
|
|
const prepSrc = readFileSync(
|
|
path.join(__dirname, '../src/services/preparationListQueryService.ts'),
|
|
'utf8'
|
|
);
|
|
const riskSrc = readFileSync(
|
|
path.join(__dirname, '../src/services/priceInvertRiskQueryService.ts'),
|
|
'utf8'
|
|
);
|
|
expect(prepSrc).toContain("'YYYY-MM-DD') AS delivery_date");
|
|
expect(riskSrc).toContain("'YYYY-MM-DD') AS delivery_day");
|
|
});
|
|
});
|