diff --git a/app/admin/models/migu.go b/app/admin/models/migu.go index 6e2a341..b8aed64 100644 --- a/app/admin/models/migu.go +++ b/app/admin/models/migu.go @@ -26,8 +26,9 @@ const ( MiGUCheckOrderUrl = "https://mg.zeqinkeji.cn/coupon-provider/api/orders/exchange-type/check" MiGUQueryRightsInfoUrl = "https://betagame.migufun.com/member/shareRights/v1.1.0.7/queryRightsInfo" - ProductID = 1 - ChannelCode = "40458652536" + ProductID = 1 + ChannelCode = "40458652536" + NewChannelCode = "40458653076" SM4KEy = "ve3N1I75AJ0Oy6nA" @@ -1091,9 +1092,14 @@ func processBatch(batch []MgOrder, wg *sync.WaitGroup) { defer wg.Done() for _, order := range batch { + productChannelCode := GetProductChannelCode(order.ChannelCode) + if productChannelCode == "" { + fmt.Println("未知的渠道编码:", order.ChannelCode) + continue + } for j := 0; j < 3; j++ { var req QueryRightsInfoReq - req.AppChannelList = append(req.AppChannelList, ChannelCode) + req.AppChannelList = append(req.AppChannelList, productChannelCode) req.Mobile = order.PhoneNumber resp, err := MiGuQueryRightsInfo(&req) @@ -1193,6 +1199,18 @@ func CheckAllOrderStateBatch() { wg.Wait() // 等待所有 goroutines 完成 } +// GetProductChannelCode 根据渠道编码返回对应的产品渠道编码 +func GetProductChannelCode(channelID string) string { + switch channelID { + case "6015150807": + return ChannelCode // ChannelCode + case "8159641101": + return NewChannelCode // NewChannelCode + default: + return "" // 未知渠道时返回空字符串 + } +} + // CheckAllOrderState 定时任务,检查历史订阅用户有无退订 func CheckAllOrderState() { if database.Db == nil { @@ -1218,9 +1236,14 @@ func CheckAllOrderState() { } for i, _ := range orderList { + productChannelCode := GetProductChannelCode(orderList[i].ChannelCode) + if productChannelCode == "" { + fmt.Println("未知的渠道编码:", orderList[i].ChannelCode) + continue + } for j := 0; j < 3; j++ { var req QueryRightsInfoReq - req.AppChannelList = append(req.AppChannelList, ChannelCode) + req.AppChannelList = append(req.AppChannelList, productChannelCode) req.Mobile = orderList[i].PhoneNumber resp, err := MiGuQueryRightsInfo(&req) @@ -1312,9 +1335,14 @@ func CheckCancelOrderState() { } for i, _ := range orderList { + productChannelCode := GetProductChannelCode(orderList[i].ChannelCode) + if productChannelCode == "" { + fmt.Println("未知的渠道编码:", orderList[i].ChannelCode) + continue + } for j := 0; j < 5; j++ { var req QueryRightsInfoReq - req.AppChannelList = append(req.AppChannelList, ChannelCode) + req.AppChannelList = append(req.AppChannelList, productChannelCode) req.Mobile = orderList[i].PhoneNumber resp, err := MiGuQueryRightsInfo(&req) @@ -1372,9 +1400,14 @@ func CheckOneHourCancelOrderState() { } for i, _ := range orderList { + productChannelCode := GetProductChannelCode(orderList[i].ChannelCode) + if productChannelCode == "" { + fmt.Println("未知的渠道编码:", orderList[i].ChannelCode) + continue + } for j := 0; j < 5; j++ { var req QueryRightsInfoReq - req.AppChannelList = append(req.AppChannelList, ChannelCode) + req.AppChannelList = append(req.AppChannelList, productChannelCode) req.Mobile = orderList[i].PhoneNumber resp, err := MiGuQueryRightsInfo(&req)