gpt
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user