feat(收口): 补齐 8 月迭代缺口并同步 Spec 与证据链
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
- 新增六对成对迁移 000232–000237:H5 弹窗类型、退款结算标识与申请人备注、优先轮询事实字段与两个新终态、通道阈值命中留痕、手机号最近解绑人、提现资格校验留痕 - 退款:原因必填与申请人备注、来源支付与渠道流水冻结、线下处理流水号补录审计、按订单查询可选退款方式、企微审批材料补齐且新增字段缺失映射即明确失败 - 优先轮询:人工关闭、有效期到期独立周期任务、失败与过期人工重触发、事实字段与异常重试查询、资产解析端点只读投影 - 通道阈值:命中事实同事务留痕与命中记录查询;员工账单:列表筛选与详情投影;商户池:列表投影与统计周期语义;H5:弹窗类型与类别排序 - 手机号:有效关联数量与最近解绑人、短信验证码失败次数限制;导出:佣金明细十五列与报表序号列 - 时间筛选:三处新增筛选纳入统一严格解析契约,员工账单产生时间参数改名 - 同步 12 份主 Spec 需求、两端点与异步任务证据链,门禁 context-health 与 OpenSpec 校验通过
This commit is contained in:
@@ -200,32 +200,43 @@ func (b *PollingBase) requeueCardAt(cardID uint, taskType string, nextCheckAt ti
|
||||
return nil
|
||||
}
|
||||
|
||||
// requeueCard 将卡按匹配配置间隔重新入队分片 Sorted Set
|
||||
// ⚠️ 关键:Lua 脚本原子出队后卡已从队列移除,若并发满时直接 return 会导致卡永久丢失
|
||||
// 调用方必须在 acquireConcurrency 返回 false 时调用此方法入队后再返回
|
||||
func (b *PollingBase) requeueCard(_ context.Context, cardID uint, taskType string) error {
|
||||
ctx, cancel := pollingFallbackContext()
|
||||
// pollingRequeueFallbackInterval 是无法解析轮询间隔时的兜底重入队间隔。
|
||||
// 防止卡或优先项因配置缺失而永久停在待执行状态。
|
||||
const pollingRequeueFallbackInterval = 30 * time.Second
|
||||
|
||||
// pollingNextCheckAt 计算该卡该任务类型的下一次检查时间,与 requeueCard 共用同一间隔解析与兜底口径。
|
||||
// 返回 ok=false 表示该任务类型没有可用轮询间隔(配置为 NULL),调用方不得入队。
|
||||
func (b *PollingBase) pollingNextCheckAt(ctx context.Context, cardID uint, taskType string) (time.Time, bool) {
|
||||
card, err := b.getCardWithCache(ctx, cardID)
|
||||
cancel()
|
||||
if err != nil {
|
||||
b.logger.Warn("重入队:获取卡信息失败,使用30秒兜底间隔",
|
||||
zap.Uint("card_id", cardID), zap.String("task_type", taskType), zap.Error(err))
|
||||
// 获取卡失败时立即重入队(下次仍然尝试处理)
|
||||
return b.requeueCardAt(cardID, taskType, time.Now().Add(30*time.Second))
|
||||
return time.Now().Add(pollingRequeueFallbackInterval), true
|
||||
}
|
||||
|
||||
intervals := b.configMgr.MergedTaskIntervals(card)
|
||||
if len(intervals) == 0 {
|
||||
// 兜底:配置未加载时延迟 30 秒重入队,防止卡从轮询永久消失
|
||||
b.logger.Warn("无匹配轮询配置,30秒后重入队(配置可能未加载)",
|
||||
zap.Uint("card_id", cardID), zap.String("task_type", taskType))
|
||||
return b.requeueCardAt(cardID, taskType, time.Now().Add(30*time.Second))
|
||||
return time.Now().Add(pollingRequeueFallbackInterval), true
|
||||
}
|
||||
info, ok := intervals[taskType]
|
||||
if !ok || info.Interval <= 0 {
|
||||
b.logger.Debug("轮询间隔为 NULL,不入队", zap.Uint("card_id", cardID), zap.String("task_type", taskType))
|
||||
return time.Time{}, false
|
||||
}
|
||||
return time.Now().Add(time.Duration(info.Interval) * time.Second), true
|
||||
}
|
||||
|
||||
// requeueCard 将卡按匹配配置间隔重新入队分片 Sorted Set
|
||||
// ⚠️ 关键:Lua 脚本原子出队后卡已从队列移除,若并发满时直接 return 会导致卡永久丢失
|
||||
// 调用方必须在 acquireConcurrency 返回 false 时调用此方法入队后再返回
|
||||
func (b *PollingBase) requeueCard(_ context.Context, cardID uint, taskType string) error {
|
||||
ctx, cancel := pollingFallbackContext()
|
||||
nextCheckAt, ok := b.pollingNextCheckAt(ctx, cardID, taskType)
|
||||
cancel()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
nextCheckAt := time.Now().Add(time.Duration(info.Interval) * time.Second)
|
||||
return b.requeueCardAt(cardID, taskType, nextCheckAt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user