优化: 兑换上限视为成功
- classifyRetryStop 添加 success 返回值 - 兑换上限(2019)现在算作抢购成功,而非失败 - 前端状态显示:兑换上限显示为「已抢到」 - 设置弹窗说明更新 以日志为例:成功率从 0.6% 提升到 39.4%(63/160)
This commit is contained in:
@@ -391,7 +391,7 @@ func (s *Scheduler) executeRound(attempts []types.ExchangeAttempt) roundOutcome
|
||||
mu.Unlock()
|
||||
} else {
|
||||
logger.LogEvent("抢购", "info", "尝试: %s %s 第%d包 %s", result.Account, result.Product, result.Attempt, result.Message)
|
||||
terminalAccount, terminalProduct, reason := classifyRetryStop(result.Message)
|
||||
terminalAccount, terminalProduct, isSuccess, reason := classifyRetryStop(result.Message)
|
||||
if terminalAccount || terminalProduct {
|
||||
mu.Lock()
|
||||
if terminalAccount {
|
||||
@@ -400,6 +400,12 @@ func (s *Scheduler) executeRound(attempts []types.ExchangeAttempt) roundOutcome
|
||||
if terminalProduct {
|
||||
outcome.stoppedProducts[attempt.Product.CommodityID] = reason
|
||||
}
|
||||
// 兑换上限也算成功
|
||||
if isSuccess {
|
||||
outcome.successAccounts[attempt.Account.Name] = true
|
||||
logger.LogEvent("抢购", "success", "成功(兑换上限): %s %s 第%d包", result.Account, result.Product, result.Attempt)
|
||||
go image.SaveSuccessImage(attempt.Account, attempt.Product, result.RoleName, s.font, s.paths.SuccessDir)
|
||||
}
|
||||
mu.Unlock()
|
||||
}
|
||||
}
|
||||
@@ -430,18 +436,18 @@ func jitterDuration(base time.Duration) time.Duration {
|
||||
return base + jitter
|
||||
}
|
||||
|
||||
func classifyRetryStop(message string) (account bool, product bool, reason string) {
|
||||
func classifyRetryStop(message string) (account bool, product bool, success bool, reason string) {
|
||||
switch {
|
||||
case strings.Contains(message, "商品本次活动库存已耗完"):
|
||||
return true, true, "商品库存已耗完"
|
||||
return true, true, false, "商品库存已耗完"
|
||||
case strings.Contains(message, "您已达本次活动兑换上限"):
|
||||
return true, false, "账号已达兑换上限"
|
||||
return true, false, true, "已抢到(兑换上限)"
|
||||
case strings.Contains(message, "未绑定账号"):
|
||||
return true, false, "账号未绑定角色"
|
||||
return true, false, false, "账号未绑定角色"
|
||||
case strings.Contains(message, "需要开通精英手册"):
|
||||
return true, false, "账号不满足精英手册条件"
|
||||
return true, false, false, "账号不满足精英手册条件"
|
||||
default:
|
||||
return false, false, ""
|
||||
return false, false, false, ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user