1、新增渠道适配,后续需改成通过数据库配置;

This commit is contained in:
chenlin 2025-05-21 16:13:13 +08:00
parent 1b1f0ed785
commit 3030162f83

View File

@ -28,6 +28,7 @@ const (
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)