@@ -347,8 +347,7 @@ func parsePids(eg *xorm.Engine, masterId, pvd string, pids []string) map[int]*md | |||||
orderTypes = append(orderTypes, v) | orderTypes = append(orderTypes, v) | ||||
user[id] = &md.UserPid{Pids: orderTypes, Uid: id, OrderType: orderType, Lv: 0} | user[id] = &md.UserPid{Pids: orderTypes, Uid: id, OrderType: orderType, Lv: 0} | ||||
} | } | ||||
case "csjp", "csjp_live", md.PVD_TIKTOKLIFE, md.PVD_ELM, md.PVD_T3_CAR, md.PVD_WALLACE, md.PVD_TOURISM, md.PVD_NEAR, md.PVD_DELIVERY, md.PVD_FLOWERCAKE, md.PVD_KUAISHOULIVE, md.PVD_KUAISHOU, md.PVD_TIKTOKLIVE, md.PVD_TIKTOK, md.PVD_MEITUAN, md.PVD_MEITUANLM, md.PVD_KFC, md.PVD_CINEMA, md.PVD_OILSTATION, md.PVD_BRIGHTOILSTATION, md.PVD_DUOMAI, md.PVD_STATIONMEITUANLM, md.PVD_NAYUKI, md.PVD_MCDONALD, md.PVD_STARBUCKS, md.PVD_TO_KFC, md.PVD_PAGODA, md.PVD_LUCKIN, md.PVD_DIDI_ENERGY, md.PVD_DIDI_ONLINE_CAR, md.PVD_KING_FLOWER, md.PVD_DIDI_FREIGHT, md.PVD_BURGERKING, md.PVD_HEYTEA, md.PVD_PIZZA, md.PVD_DIDI_CHAUFFEUR: | |||||
default: | |||||
for _, v := range pids { | for _, v := range pids { | ||||
s := strings.Split(v, "_") | s := strings.Split(v, "_") | ||||
@@ -64,7 +64,7 @@ func commCheckUser(eg *xorm.Engine, existOrd model.OrdList, ords map[string]md.O | |||||
return | return | ||||
} | } | ||||
existOrd.BenefitAll = utils.FloatFormat(existOrd.BenefitAll, 2) | existOrd.BenefitAll = utils.FloatFormat(existOrd.BenefitAll, 2) | ||||
pvdList := []string{md.PVD_JDOwn, md.PVD_JD, "csjp", "csjp_live", md.PVD_TIKTOKLIFE, md.PVD_ELM, md.PVD_STATIONMEITUANLM, md.PVD_MEITUANLMSTART, md.PVD_MEITUANLM, md.PVD_MEITUAN, md.PVD_T3_CAR, md.PVD_WALLACE, md.PVD_TOURISM, md.PVD_DELIVERY, md.PVD_NEAR, md.PVD_FLOWERCAKE, md.PVD_TIKTOK, md.PVD_PIZZA, md.PVD_TIKTOKLIVE, md.PVD_KUAISHOU, md.PVD_KUAISHOULIVE, md.PVD_MEITUAN, md.PVD_MEITUANLM, md.PVD_CINEMA, md.PVD_KFC, md.PVD_HEYTEA, md.PVD_BURGERKING, md.PVD_STARBUCKS, md.PVD_MCDONALD, md.PVD_NAYUKI, md.PVD_LUCKIN, md.PVD_TO_KFC, md.PVD_PAGODA, md.PVD_KING_FLOWER, md.PVD_DIDI_ONLINE_CAR, md.PVD_DIDI_FREIGHT, md.PVD_DIDI_ENERGY, md.PVD_OILSTATION, md.PVD_DIDI_CHAUFFEUR} | |||||
pvdList := []string{"tik_tok_team_order", md.PVD_JDOwn, md.PVD_JD, "csjp", "csjp_live", md.PVD_TIKTOKLIFE, md.PVD_ELM, md.PVD_STATIONMEITUANLM, md.PVD_MEITUANLMSTART, md.PVD_MEITUANLM, md.PVD_MEITUAN, md.PVD_T3_CAR, md.PVD_WALLACE, md.PVD_TOURISM, md.PVD_DELIVERY, md.PVD_NEAR, md.PVD_FLOWERCAKE, md.PVD_TIKTOK, md.PVD_PIZZA, md.PVD_TIKTOKLIVE, md.PVD_KUAISHOU, md.PVD_KUAISHOULIVE, md.PVD_MEITUAN, md.PVD_MEITUANLM, md.PVD_CINEMA, md.PVD_KFC, md.PVD_HEYTEA, md.PVD_BURGERKING, md.PVD_STARBUCKS, md.PVD_MCDONALD, md.PVD_NAYUKI, md.PVD_LUCKIN, md.PVD_TO_KFC, md.PVD_PAGODA, md.PVD_KING_FLOWER, md.PVD_DIDI_ONLINE_CAR, md.PVD_DIDI_FREIGHT, md.PVD_DIDI_ENERGY, md.PVD_OILSTATION, md.PVD_DIDI_CHAUFFEUR} | |||||
fmt.Println("===============================111111111111111111111111111111") | fmt.Println("===============================111111111111111111111111111111") | ||||
fmt.Println((existOrd.Uid == 0 && pid != "" && pidToUser[pid] != nil && (pvd == md.PVD_TB || pvd == "ele"))) | fmt.Println((existOrd.Uid == 0 && pid != "" && pidToUser[pid] != nil && (pvd == md.PVD_TB || pvd == "ele"))) | ||||
fmt.Println((existOrd.BenefitAll != ords[existOrd.PvdOid].Commission || (ords[existOrd.PvdOid].Commission == 0 && existOrd.UserCommission > 0))) | fmt.Println((existOrd.BenefitAll != ords[existOrd.PvdOid].Commission || (ords[existOrd.PvdOid].Commission == 0 && existOrd.UserCommission > 0))) | ||||
@@ -22,9 +22,10 @@ func initConsumes() { | |||||
//jobs[consumeMd.ZhiosOrderTrackRefundForTbAllConsumeFunName] = ZhiosOrderTrackRefundForTbAllConsume //淘宝-全部退款 | //jobs[consumeMd.ZhiosOrderTrackRefundForTbAllConsumeFunName] = ZhiosOrderTrackRefundForTbAllConsume //淘宝-全部退款 | ||||
//jobs[consumeMd.ZhiosOrderTrackRefundForTbPartConsumeFunName] = ZhiosOrderTrackRefundForTbPartConsume //淘宝-部分退款 | //jobs[consumeMd.ZhiosOrderTrackRefundForTbPartConsumeFunName] = ZhiosOrderTrackRefundForTbPartConsume //淘宝-部分退款 | ||||
jobs[consumeMd.ZhiosOrderTrackCreateForJdConsumeFunName] = ZhiosOrderTrackCreateForJdConsume //京东-创建订单 | |||||
jobs[consumeMd.ZhiosOrderTrackUpdateForJdConsumeFunName] = ZhiosOrderTrackUpdateForJdConsume //京东-更新订单 | |||||
jobs[consumeMd.ZhiosOrderTrackCreateForPddConsumeFunName] = ZhiosOrderTrackCreateForPddConsume //拼多多-全部订单 | |||||
jobs[consumeMd.ZhiosOrderTrackCreateForJdConsumeFunName] = ZhiosOrderTrackCreateForJdConsume //京东-创建订单 | |||||
jobs[consumeMd.ZhiosOrderTrackUpdateForJdConsumeFunName] = ZhiosOrderTrackUpdateForJdConsume //京东-更新订单 | |||||
jobs[consumeMd.ZhiosOrderTrackCreateForPddConsumeFunName] = ZhiosOrderTrackCreateForPddConsume //拼多多-全部订单 | |||||
jobs[consumeMd.ZhiosOrderTrackCreateForTikTokTeamConsumeFunName] = ZhiosOrderTrackCreateForTikTokTeamConsume //抖音团长服务费-全部订单 | |||||
} | } | ||||
@@ -56,6 +56,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||||
BindKey: "", | BindKey: "", | ||||
ConsumeFunName: "ZhiosOrderTrackCreateForPddConsume", | ConsumeFunName: "ZhiosOrderTrackCreateForPddConsume", | ||||
}, | }, | ||||
{ | |||||
ExchangeName: "zhios.order_track_create.exchange", | |||||
Name: "order_track_create_for_tik_tok_team", | |||||
Type: DirectQueueType, | |||||
IsPersistent: false, | |||||
RoutKey: "tik_tok_team", | |||||
BindKey: "", | |||||
ConsumeFunName: "ZhiosOrderTrackCreateForTikTokTeamConsume", | |||||
}, | |||||
{ | { | ||||
ExchangeName: "zhios.order_track_refund.exchange", | ExchangeName: "zhios.order_track_refund.exchange", | ||||
Name: "order_track_refund_for_tb_all", | Name: "order_track_refund_for_tb_all", | ||||
@@ -77,11 +86,12 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||||
} | } | ||||
const ( | const ( | ||||
ZhiosOrderTrackUpdateForTbConsumeFunName = "ZhiosOrderTrackUpdateForTbConsume" | |||||
ZhiosOrderTrackCreateForTbConsumeFunName = "ZhiosOrderTrackCreateForTbConsume" | |||||
ZhiosOrderTrackCreateForJdConsumeFunName = "ZhiosOrderTrackCreateForJdConsume" | |||||
ZhiosOrderTrackCreateForPddConsumeFunName = "ZhiosOrderTrackCreateForPddConsume" | |||||
ZhiosOrderTrackUpdateForJdConsumeFunName = "ZhiosOrderTrackUpdateForJdConsume" | |||||
ZhiosOrderTrackRefundForTbAllConsumeFunName = "ZhiosOrderTrackRefundForTbAllConsume" | |||||
ZhiosOrderTrackRefundForTbPartConsumeFunName = "ZhiosOrderTrackRefundForTbPartConsume" | |||||
ZhiosOrderTrackUpdateForTbConsumeFunName = "ZhiosOrderTrackUpdateForTbConsume" | |||||
ZhiosOrderTrackCreateForTbConsumeFunName = "ZhiosOrderTrackCreateForTbConsume" | |||||
ZhiosOrderTrackCreateForJdConsumeFunName = "ZhiosOrderTrackCreateForJdConsume" | |||||
ZhiosOrderTrackCreateForPddConsumeFunName = "ZhiosOrderTrackCreateForPddConsume" | |||||
ZhiosOrderTrackCreateForTikTokTeamConsumeFunName = "ZhiosOrderTrackCreateForTikTokTeamConsume" | |||||
ZhiosOrderTrackUpdateForJdConsumeFunName = "ZhiosOrderTrackUpdateForJdConsume" | |||||
ZhiosOrderTrackRefundForTbAllConsumeFunName = "ZhiosOrderTrackRefundForTbAllConsume" | |||||
ZhiosOrderTrackRefundForTbPartConsumeFunName = "ZhiosOrderTrackRefundForTbPartConsume" | |||||
) | ) |
@@ -0,0 +1,90 @@ | |||||
package consume | |||||
import ( | |||||
"applet/app/cfg" | |||||
"applet/app/db" | |||||
md2 "applet/app/md" | |||||
svc2 "applet/app/svc" | |||||
"applet/app/utils" | |||||
"applet/app/utils/logx" | |||||
"applet/consume/md" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles" | |||||
"encoding/json" | |||||
"errors" | |||||
"fmt" | |||||
"github.com/streadway/amqp" | |||||
"time" | |||||
) | |||||
func ZhiosOrderTrackCreateForTikTokTeamConsume(queue md.MqQueue) { | |||||
fmt.Println(">>>>>>>>>>>>ZhiosOrderTrackCreateForPddConsume>>>>>>>>>>>>") | |||||
ch, err := rabbit.Cfg.Pool.GetChannel() | |||||
if err != nil { | |||||
logx.Error(err) | |||||
return | |||||
} | |||||
defer ch.Release() | |||||
//1、将自己绑定到交换机上 | |||||
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) | |||||
//2、取出数据进行消费 | |||||
ch.Qos(1) | |||||
delivery := ch.Consume(queue.Name, false) | |||||
one_circles.Init(cfg.RedisAddr) | |||||
var res amqp.Delivery | |||||
var ok bool | |||||
for { | |||||
res, ok = <-delivery | |||||
if ok == true { | |||||
err = handleZhiosOrderTrackCreateForTikTokTeamConsume(res.Body) | |||||
fmt.Println("err ::: ", err) | |||||
if err != nil { | |||||
fmt.Println("ZhiosOrderTrackCreateForTikTokTeamConsume_ERR:::::", err.Error()) | |||||
_ = res.Reject(true) //TODO::拒绝 Ack | |||||
//_ = res.Reject(false) | |||||
var msg interface{} | |||||
json.Unmarshal(res.Body, &msg) | |||||
if err.Error() == "Connection timed out" { | |||||
//TODO::重新推回队列末尾,避免造成队列堵塞 | |||||
ch.Publish(queue.ExchangeName, msg, queue.RoutKey) | |||||
} else { | |||||
//TODO::推入新的队列中备份 | |||||
utils.FilePutContents("ZhiosOrderTrackCreateForTikTokTeamConsume_ERR", utils.SerializeStr(err.Error())) | |||||
ch.Publish("zhios.order_track_create_exception.exchange", map[string]interface{}{ | |||||
"msg": msg, | |||||
"err": err.Error(), | |||||
}, "tik_tok_team") | |||||
} | |||||
} else { | |||||
err = res.Ack(true) | |||||
} | |||||
} else { | |||||
panic(errors.New("error getting message")) | |||||
} | |||||
} | |||||
fmt.Println("get msg done") | |||||
} | |||||
func handleZhiosOrderTrackCreateForTikTokTeamConsume(msgData []byte) error { | |||||
//1、解析mq中queue的数据结构体 | |||||
var msg md2.ZhiosOrderTrackCreateRoutKeyForTb | |||||
err := json.Unmarshal(msgData, &msg) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
time.Sleep(time.Microsecond * 100) // 等待100毫秒 | |||||
fmt.Println("order_track_create_for_TikTokTeam_message:::::::::::>>>>>>>>>") | |||||
fmt.Println(msg) | |||||
if db.DBs[msg.DbName] == nil { | |||||
return nil | |||||
} | |||||
engine := db.DBs[msg.DbName] | |||||
err = svc2.OrderSaveCreateUpdate(engine, msg.Pvd, msg.OrderData, msg.Opts, msg.DbName) | |||||
if err != nil { | |||||
fmt.Println("order_track_create_for_TikTokTeam_ERR:::::::::::>>>>>>>>>", err.Error()) | |||||
return err | |||||
} | |||||
return nil | |||||
} |