fix: display finance records and ledgers in Beijing time
Deploy olons-server production / deploy (push) Successful in 34s

This commit is contained in:
richjohnrambo
2026-10-23 00:13:07 +08:00
parent 8ce67648b1
commit f56b84bb10
9 changed files with 224 additions and 30 deletions
+20
View File
@@ -6,3 +6,23 @@ package store
func databaseWallTimeUTC(column string) string {
return `DATE_FORMAT(TIMESTAMPADD(SECOND,TIMESTAMPDIFF(SECOND,NOW(),UTC_TIMESTAMP()),` + column + `),'%Y-%m-%dT%H:%i:%sZ')`
}
// beijingWallTimeUTC handles DATETIME fields explicitly written by the admin
// service, whose business clock is Asia/Shanghai, independently of the DB session.
func beijingWallTimeUTC(column string) string {
return `DATE_FORMAT(TIMESTAMPADD(HOUR,-8,` + column + `),'%Y-%m-%dT%H:%i:%sZ')`
}
// walletLedgerTimeUTC preserves the UTC clock used by insertTaskLedger and
// insertWithdrawalLedger; all other ledger writers use the admin's Beijing clock.
// Legacy forced-payment entries share the task:...:match key with client entries,
// so their writer-provided remarks must also distinguish those two sources.
func walletLedgerTimeUTC() string {
return `CASE WHEN idempotency_key LIKE 'withdrawal:%'
OR idempotency_key REGEXP '^task:[0-9]+:(settle|expire):'
OR (idempotency_key REGEXP '^task:[0-9]+:match:(available|frozen)$' AND remark IN (
'自动派单扣除可用余额','自动派单冻结订单本金',
'会员确认手动订单扣除可用余额','会员确认手动订单冻结本金'))
THEN DATE_FORMAT(occurred_at,'%Y-%m-%dT%H:%i:%sZ')
ELSE ` + beijingWallTimeUTC("occurred_at") + ` END`
}