fix: 修复账单时间显示为UTC时区问题,改为本地时间

- 新增 LocalTime 自定义类型,JSON序列化输出本地时间格式
- 修改 CleanedBill.Time 字段类型为 LocalTime
- 更新 parseTime 函数返回 LocalTime 类型
- 前端添加 formatDateTime 工具函数(兼容处理)
- 版本号更新至 1.0.2
This commit is contained in:
2026-01-11 21:40:27 +08:00
parent d49d9afb3a
commit 8a9de1b328
9 changed files with 107 additions and 14 deletions

View File

@@ -34,7 +34,7 @@ func checkDuplicate(ctx context.Context, bill *model.CleanedBill) bool {
} else {
// 回退到 时间+金额+商户 组合判断
filter = bson.M{
"time": bill.Time,
"time": bill.Time.Time(), // 转换为 time.Time 用于 MongoDB 查询
"amount": bill.Amount,
"merchant": bill.Merchant,
}
@@ -489,11 +489,11 @@ func saveCleanedBillsFromJSON(filePath, billType, sourceFile, uploadBatch string
}
// parseTime 解析时间字符串
// 使用本地时区解析,避免 UTC 时区问题
func parseTime(s string) time.Time {
// 使用本地时区解析,返回 model.LocalTime 类型
func parseTime(s string) model.LocalTime {
s = strings.TrimSpace(s)
if s == "" {
return time.Time{}
return model.LocalTime(time.Time{})
}
// 尝试多种时间格式(使用本地时区)
@@ -508,11 +508,11 @@ func parseTime(s string) time.Time {
for _, format := range formats {
if t, err := time.ParseInLocation(format, s, time.Local); err == nil {
return t
return model.LocalTime(t)
}
}
return time.Time{}
return model.LocalTime(time.Time{})
}
// parseAmount 解析金额字符串