fix: 适配 Gateway 响应模型变更,更新轮询处理器和 Mock 服务
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m25s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m25s
- polling_handler: Status→RealStatus, UsedFlow→Used, parseRealnameStatus 参数改为 bool - mock_gateway: 同步接口路径和响应结构与上游文档一致
This commit is contained in:
@@ -123,11 +123,11 @@ func (h *PollingHandler) HandleRealnameCheck(ctx context.Context, t *asynq.Task)
|
||||
}
|
||||
|
||||
// 解析实名状态
|
||||
newRealnameStatus = h.parseRealnameStatus(result.Status)
|
||||
newRealnameStatus = h.parseRealnameStatus(result.RealStatus)
|
||||
h.logger.Info("实名检查完成",
|
||||
zap.Uint64("card_id", cardID),
|
||||
zap.String("iccid", card.ICCID),
|
||||
zap.String("gateway_status", result.Status),
|
||||
zap.Bool("gateway_real_status", result.RealStatus),
|
||||
zap.Int("new_status", newRealnameStatus),
|
||||
zap.Int("old_status", card.RealNameStatus))
|
||||
} else {
|
||||
@@ -236,7 +236,7 @@ func (h *PollingHandler) HandleCarddataCheck(ctx context.Context, t *asynq.Task)
|
||||
}
|
||||
|
||||
// Gateway 返回的是 MB 单位的流量
|
||||
gatewayFlowMB = float64(result.UsedFlow)
|
||||
gatewayFlowMB = result.Used
|
||||
h.logger.Info("流量检查完成",
|
||||
zap.Uint64("card_id", cardID),
|
||||
zap.String("iccid", card.ICCID),
|
||||
@@ -692,15 +692,12 @@ func (h *PollingHandler) stopCards(ctx context.Context, cards []*model.IotCard,
|
||||
}
|
||||
|
||||
// parseRealnameStatus 解析实名状态
|
||||
func (h *PollingHandler) parseRealnameStatus(gatewayStatus string) int {
|
||||
switch gatewayStatus {
|
||||
case "已实名", "realname", "1":
|
||||
// Gateway 返回 bool 类型:true=已实名, false=未实名
|
||||
func (h *PollingHandler) parseRealnameStatus(realStatus bool) int {
|
||||
if realStatus {
|
||||
return 2 // 已实名
|
||||
case "实名中", "processing":
|
||||
return 1 // 实名中
|
||||
default:
|
||||
return 0 // 未实名
|
||||
}
|
||||
return 0 // 未实名
|
||||
}
|
||||
|
||||
// extractTaskType 从完整的任务类型中提取简短的类型名
|
||||
|
||||
Reference in New Issue
Block a user