Ver código fonte

Merge remote-tracking branch 'origin/master'

three
huangjiajun 1 ano atrás
pai
commit
28c56c1180
4 arquivos alterados com 97 adições e 16 exclusões
  1. +65
    -0
      consume/dou_shen_user_register_for_user_register_up_lv.go
  2. +5
    -4
      consume/init.go
  3. +22
    -12
      consume/md/consume_key.go
  4. +5
    -0
      consume/md/md_doushen.go

+ 65
- 0
consume/dou_shen_user_register_for_user_register_up_lv.go Ver arquivo

@@ -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
}

+ 5
- 4
consume/init.go Ver arquivo

@@ -20,10 +20,11 @@ func initConsumes() {
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
//jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
//jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
//jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
//jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund


+ 22
- 12
consume/md/consume_key.go Ver arquivo

@@ -102,6 +102,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "official",
ConsumeFunName: "DouShenUserRegisterConsumeForOfficial",
},
{
ExchangeName: "zhios.doushen.user.register.exchange",
Name: "zhios_doushen_user_register_user_comm_up_lv",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "user_register_comm_up_lv",
BindKey: "user_register_comm_up_lv",
ConsumeFunName: "DouShenUserRegisterConsumeForUserRegisterUpLv",
},
{
ExchangeName: "canal.topic",
Name: "canal_mall_ord_for_you_mi_shang",
@@ -123,16 +132,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"
)

+ 5
- 0
consume/md/md_doushen.go Ver arquivo

@@ -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"`
}

Carregando…
Cancelar
Salvar