补齐相关日志日志
This commit is contained in:
+22
-3
@@ -125,17 +125,36 @@ type VirtualPaySettingS struct {
|
||||
Enable bool // 是否启用虚拟支付;未开通时置 false,虚拟商品下单返回「虚拟支付未开通」
|
||||
}
|
||||
|
||||
// UserDefaultQuotaSettingS 新用户注册时初始化的免费额度与赠送会员天数配置。
|
||||
// UserDefaultQuotaSettingS 新用户注册时初始化的免费额度配置。
|
||||
// 使用指针类型以区分「未配置」与「显式配置为 0」:
|
||||
// - nil:该项未配置(或整段缺失),由 service 层回落内置默认常量;
|
||||
// - 非 nil:以配置值为准,允许为 0(额度类表示不赠送,GiftVIPDay 表示不赠送体验会员);
|
||||
// - 非 nil:以配置值为准,允许为 0(表示不赠送该类免费额度);
|
||||
// - 负数:视为非法配置,回落内置默认常量。
|
||||
type UserDefaultQuotaSettingS struct {
|
||||
Cos *int64 // 免费上传额度(永久,不每天重置)
|
||||
AI *int64 // 免费 AI 推荐额度(每日,每天 0 点重置)
|
||||
OutfitShare *int64 // 免费社区分享额度(每日,每天 0 点重置)
|
||||
ClosetShare *int64 // 免费衣柜分享额度(每日,每天 0 点重置;0 表示不赠送)
|
||||
GiftVIPDay *int64 // 注册赠送的体验会员天数(vip_type=4,0 表示不赠送)
|
||||
// [已废弃] 体验会员天数已迁至 NewUserGift.GiftVIPDay。
|
||||
// 保留此字段仅为兼容旧配置:新位置未配置时回落读这里。
|
||||
GiftVIPDay *int64
|
||||
}
|
||||
|
||||
// NewUserGiftSettingS 新用户注册赠送的体验会员及其额度配置。
|
||||
//
|
||||
// 与 UserDefaultQuota 的区别:
|
||||
// - UserDefaultQuota 是「免费额度」,所有用户长期享有,不依赖会员身份;
|
||||
// - 本段是「注册赠送」,其中额度以体验会员凭证(source=4)发放,有效期是
|
||||
// 「注册时刻 + 体验天数」这个固定值,不随后续续费延长(否则用户充值后会把
|
||||
// 体验额度一直「继承」下去);因此仅在 GiftVIPDay > 0 时才发放。
|
||||
//
|
||||
// 指针语义同 UserDefaultQuotaSettingS:nil 回落内置默认,显式 0 表示不赠送,负数视为非法。
|
||||
type NewUserGiftSettingS struct {
|
||||
GiftVIPDay *int64 // 赠送的体验会员天数(vip_type=4);0 表示不赠送体验会员
|
||||
Cos *int64 // 体验会员赠送的上传额度
|
||||
AI *int64 // 体验会员赠送的 AI 推荐额度
|
||||
OutfitShare *int64 // 体验会员赠送的社区分享额度
|
||||
ClosetShare *int64 // 体验会员赠送的衣柜分享额度
|
||||
}
|
||||
|
||||
// AdRewardSettingS 广告激励额度配置。
|
||||
|
||||
@@ -111,11 +111,20 @@ func runFortuneGenerationWithLock(client *Client, horoscopeDao *mysqldao.Horosco
|
||||
defer cancel()
|
||||
|
||||
ok, lerr := redisdao.TryLock(ctx, lockKey, lockVal, 5*time.Minute)
|
||||
if lerr != nil || !ok {
|
||||
slog.Info("fortune generation already in progress, skip", "date", today)
|
||||
if lerr != nil {
|
||||
// Redis 故障与「其它实例正在执行」必须区分:前者当天运势可能缺失且无人知晓。
|
||||
slog.ErrorContext(ctx, "fortune generation: acquire lock failed", "date", today, "error", lerr)
|
||||
return
|
||||
}
|
||||
defer redisdao.Unlock(context.Background(), lockKey, lockVal)
|
||||
if !ok {
|
||||
slog.InfoContext(ctx, "fortune generation already in progress, skip", "date", today)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if uerr := redisdao.Unlock(context.Background(), lockKey, lockVal); uerr != nil {
|
||||
slog.WarnContext(ctx, "fortune generation: release lock failed", "date", today, "error", uerr)
|
||||
}
|
||||
}()
|
||||
|
||||
runFortuneGeneration(client, horoscopeDao)
|
||||
}
|
||||
@@ -145,21 +154,21 @@ func EnsureTodayFortunes() {
|
||||
today := now.Format("2006-01-02")
|
||||
statDate, err := strconv.ParseInt(now.Format("20060102"), 10, 64)
|
||||
if err != nil {
|
||||
slog.Error("EnsureTodayFortunes: parse stat date failed", "error", err)
|
||||
slog.ErrorContext(ctx, "EnsureTodayFortunes: parse stat date failed", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
horoscopes, err := horoscopeDao.HoroscopeGetByDate(ctx, statDate)
|
||||
if err != nil {
|
||||
slog.Warn("EnsureTodayFortunes: query today fortunes failed, will try to generate", "error", err, "date", today)
|
||||
slog.WarnContext(ctx, "EnsureTodayFortunes: query today fortunes failed, will try to generate", "error", err, "date", today)
|
||||
}
|
||||
|
||||
if len(horoscopes) >= 12 {
|
||||
slog.Info("EnsureTodayFortunes: today fortunes already complete, skip", "date", today, "count", len(horoscopes))
|
||||
slog.InfoContext(ctx, "EnsureTodayFortunes: today fortunes already complete, skip", "date", today, "count", len(horoscopes))
|
||||
return
|
||||
}
|
||||
|
||||
slog.Info("EnsureTodayFortunes: today fortunes incomplete, generating...",
|
||||
slog.InfoContext(ctx, "EnsureTodayFortunes: today fortunes incomplete, generating...",
|
||||
"date", today,
|
||||
"existing", len(horoscopes),
|
||||
"needed", 12,
|
||||
|
||||
Reference in New Issue
Block a user