Skip to content

fix(redenvelope): reset daily limit at local midnight - #251

Merged
yyg-max merged 1 commit into
linux-do:masterfrom
huzhe01:fix/red-envelope-daily-window
Sep 18, 2026
Merged

yyg-max merged 1 commit into
linux-do:masterfrom
huzhe01:fix/red-envelope-daily-window

Conversation

@huzhe01

@huzhe01 huzhe01 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

例行检查

  • 我已阅读并理解 贡献者公约
  • 我已阅读并同意 贡献者许可协议 (CLA),确认我的贡献将根据项目的 Apache2.0 许可证进行许可
  • 我知晓如果此 PR 并不做出实质性更改,或可被认为是为了PR被合并而提交PR的,则可能不会被合并

变更内容

  • 按当前时间所在时区构造当天 00:00,作为每日红包发送数量的查询起点。
  • 添加 UTC+8 凌晨场景的回归测试。

变更原因

time.Time.Truncate(24 * time.Hour) 按绝对时间的 24 小时边界截断,不会返回当前时区的自然日午夜。生产镜像使用 Asia/Shanghai 时区,因此原实现会把每日红包数量窗口设为北京时间 08:00 到次日 08:00。

例如在北京时间 2026-09-04 01:30,原实现得到 2026-09-03 08:00,而正确的当天起点应为 2026-09-04 00:00。这会导致用户在 00:00–08:00 期间仍受前一天红包数量影响。

验证

  • 修复前:TestStartOfDayUsesLocalMidnight 失败,实际得到前一天 08:00
  • 修复后:专项测试通过
  • go test ./...
  • go vet ./...
  • go build ./...
  • git diff --check

@yyg-max
yyg-max merged commit 6083983 into linux-do:master Sep 18, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants