This commit is contained in:
zhengchiliu
2026-09-15 00:53:04 +08:00
parent 32a0b87e9e
commit 112c5f8e46
42 changed files with 1121 additions and 304 deletions
+13 -1
View File
@@ -69,7 +69,12 @@ func (s *AdRewardService) Grant(ctx context.Context, userID int64, request *dto.
QuotaType: quotaType,
Reason: "广告激励赠送",
}
created, err := mysqldao.NewQuotaGrantDao().QuotaGrantCreateWithFlow(ctx, grant, flow)
maxClaims := global.AdRewardSetting.MaxClaimsPerDay
if maxClaims <= 0 {
maxClaims = 1
}
dayStart, dayEnd := todayRangeUnix()
created, err := mysqldao.NewQuotaGrantDao().AdRewardGrantCreateWithFlow(ctx, grant, flow, dayStart, dayEnd, maxClaims)
if err != nil {
return nil, errcode.DatabaseError
}
@@ -126,6 +131,13 @@ func parseAdRewardType(rewardType string) (int8, bool) {
}
}
// todayRangeUnix 返回本地时区当天的左闭右开时间范围。
func todayRangeUnix() (int64, int64) {
now := time.Now()
start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
return start.Unix(), start.AddDate(0, 0, 1).Unix()
}
// todayEndUnix 返回当天 23:59:59 的秒级时间戳(广告激励当天有效)。
func todayEndUnix() int64 {
now := time.Now()