yueli
8755837fe8
fix(timezone): 审批单据时间统一为 naive 北京时间,消除 8 小时偏差
成因:approved_at / executed_at 列是 timestamp without time zone,而赋值用了
带时区的 datetime.now(timezone(timedelta(hours=8)))。psycopg2 对 naive 列不会
剥掉 tzinfo,而是转成 naive UTC 再写入,结果比同为北京时间的 created_at 早 8 小时。
(代码里并无 datetime.utcnow(),真实成因是 aware 值被驱动的隐式 UTC 转换。)
改动:
· outbound_service / borrow_service 的审批分支
datetime.now(beijing_tz).replace(tzinfo=None) → beijing_time()
(免审批分支已在上一轮改为 beijing_time,此处补齐审批分支);
· purchase_service 审批/完结分支同源缺陷一并修复;
· scrap_approval / scrap_approval_service 的 _beijing()、_beijing_now() 由
tz-aware 改为 naive —— 配合上述迁移把列类型改为 naive,
若仍返回 aware 值,timestamptz→timestamp 后会反向早 8 小时。
实测四表(scrap/outbound/borrow/purchase)created_at 与 approved_at 差值
均在同一秒内(-1ms ~ -12ms)。
2026-09-10 10:14:31 +08:00
..
2026-09-10 10:14:31 +08:00
2026-05-22 10:59:39 +08:00
2026-09-02 18:39:09 +08:00
2026-09-01 13:52:56 +08:00
2026-09-02 18:39:09 +08:00
2026-03-19 09:49:21 +08:00
2026-07-14 17:02:07 +08:00
2026-03-19 09:49:21 +08:00
2026-07-15 11:11:40 +08:00
2026-09-02 18:39:17 +08:00
2026-05-12 15:17:42 +08:00
2026-03-19 09:49:21 +08:00
2026-04-02 10:31:53 +08:00