From ff43659cf99d78e12007fde7582e72f3dd086f52 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 18 May 2023 19:15:11 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=8A=96=E7=9C=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=EF=BC=8C=E6=8E=A8=E8=8D=90=E4=BA=BA=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n_user_register_for_user_register_up_lv.go | 65 +++++++++++++++++++ consume/init.go | 1 + consume/md/consume_key.go | 25 +++---- consume/md/md_doushen.go | 5 ++ 4 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 consume/dou_shen_user_register_for_user_register_up_lv.go diff --git a/consume/dou_shen_user_register_for_user_register_up_lv.go b/consume/dou_shen_user_register_for_user_register_up_lv.go new file mode 100644 index 0000000..2ade7e1 --- /dev/null +++ b/consume/dou_shen_user_register_for_user_register_up_lv.go @@ -0,0 +1,65 @@ +package consume + +import ( + "applet/app/db" + utils2 "applet/app/utils" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" + "strconv" + "time" +) + +func DouShenUserRegisterConsumeForUserRegisterUpLv(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>DouShenUserRegisterConsumeForUserRegisterUpLv>>>>>>>>>>>>") + 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) + + var res amqp.Delivery + var ok bool + for { + res, ok = <-delivery + if ok == true { + fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + err = handleDouShenUserRegisterConsumeForUserRegisterUpLv(res.Body) + if err != nil { + fmt.Println("!!!!!!!err!!!!!!!", err) + utils2.FilePutContents("douShenUserRegisterConsumeForUserRegisterUpLv_err", "[err]:"+err.Error()) + _ = res.Reject(false) + } else { + _ = res.Ack(true) + } + } else { + panic(errors.New("error getting message")) + } + } + fmt.Println("get msg done") +} + +func handleDouShenUserRegisterConsumeForUserRegisterUpLv(msgData []byte) error { + time.Sleep(time.Duration(10) * time.Second) + //1、解析mq中queue的数据结构体 + var msg *md.DouShenUserRegisterMessageStructForUserRegisterUpLv + err := json.Unmarshal(msgData, &msg) + if err != nil { + return err + } + eg := db.DBs[msg.MasterId] + levelList, _ := db.UserLevlEgAll(eg) + FindUser(eg, strconv.FormatInt(msg.Uid, 10), msg.MasterId, levelList) + return nil +} diff --git a/consume/init.go b/consume/init.go index cd9f42a..274d86c 100644 --- a/consume/init.go +++ b/consume/init.go @@ -22,6 +22,7 @@ func initConsumes() { jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter + jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 12b6b0e..bde5c31 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -123,16 +123,17 @@ var RabbitMqQueueKeyList = []*MqQueue{ } const ( - CanalOrderConsumeFunName = "CanalOrderConsume" - CanalGuideOrderConsumeFunName = "CanalGuideOrderConsume" - ZhiOsUserVisitIpAddressConsumeFunName = "ZhiOsUserVisitIpAddressConsume" - DouShenUserRegisterConsumeForOfficialFunName = "DouShenUserRegisterConsumeForOfficial" - DouShenUserRegisterConsumeForOperationCenterFunName = "DouShenUserRegisterConsumeForOperationCenter" - DouShenUserRegisterConsumeForMyRecommenderFunName = "DouShenUserRegisterConsumeForMyRecommender" - DouShenUserRegisterConsumeForMyFansFunName = "DouShenUserRegisterConsumeForMyFans" - ZhiosFastReturnOrderPayFunName = "ZhiosFastReturnOrderPay" - ZhiosFastReturnOrderSuccessFunName = "ZhiosFastReturnOrderSuccess" - ZhiosFastReturnOrderRefundFunName = "ZhiosFastReturnOrderRefund" - CanalMallOrdForYouMiShangFunName = "CanalMallOrdForYouMiShang" - YoumishangExchangeStoreFunName = "YoumishangExchangeStore" + CanalOrderConsumeFunName = "CanalOrderConsume" + CanalGuideOrderConsumeFunName = "CanalGuideOrderConsume" + ZhiOsUserVisitIpAddressConsumeFunName = "ZhiOsUserVisitIpAddressConsume" + DouShenUserRegisterConsumeForOfficialFunName = "DouShenUserRegisterConsumeForOfficial" + DouShenUserRegisterConsumeForOperationCenterFunName = "DouShenUserRegisterConsumeForOperationCenter" + DouShenUserRegisterConsumeForMyRecommenderFunName = "DouShenUserRegisterConsumeForMyRecommender" + DouShenUserRegisterConsumeForMyFansFunName = "DouShenUserRegisterConsumeForMyFans" + DouShenUserRegisterConsumeForUserRegisterUpLvFunName = "DouShenUserRegisterConsumeForUserRegisterUpLv" + ZhiosFastReturnOrderPayFunName = "ZhiosFastReturnOrderPay" + ZhiosFastReturnOrderSuccessFunName = "ZhiosFastReturnOrderSuccess" + ZhiosFastReturnOrderRefundFunName = "ZhiosFastReturnOrderRefund" + CanalMallOrdForYouMiShangFunName = "CanalMallOrdForYouMiShang" + YoumishangExchangeStoreFunName = "YoumishangExchangeStore" ) diff --git a/consume/md/md_doushen.go b/consume/md/md_doushen.go index 32678be..0c5ad23 100644 --- a/consume/md/md_doushen.go +++ b/consume/md/md_doushen.go @@ -22,3 +22,8 @@ type DouShenUserRegisterMessageStructForOperationCenter struct { Uid int64 `json:"uid"` OperationCenterUid int64 `json:"operation_center_uid"` } + +type DouShenUserRegisterMessageStructForUserRegisterUpLv struct { + MasterId string `json:"master_id"` + Uid int64 `json:"uid"` +}