diff --git a/app/db/offical/model/mall_add_supply_goods.go b/app/db/offical/model/mall_add_supply_goods.go new file mode 100644 index 0000000..b5a300b --- /dev/null +++ b/app/db/offical/model/mall_add_supply_goods.go @@ -0,0 +1,7 @@ +package model + +type MallAddSupplyGoods struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Data string `json:"data" xorm:"not null comment('数据') TEXT"` + MasterId string `json:"master_id" xorm:"not null comment('站长ID') CHAR(50)"` +} diff --git a/consume/mall_add_supply_goods.go b/consume/mall_add_supply_goods.go index 09514f1..4ef8aba 100644 --- a/consume/mall_add_supply_goods.go +++ b/consume/mall_add_supply_goods.go @@ -1,8 +1,9 @@ package consume import ( + "applet/app/db" + model2 "applet/app/db/offical/model" svc2 "applet/app/svc" - "applet/app/utils/aes" "applet/app/utils/logx" "applet/consume/md" md3 "applet/mall/md" @@ -29,7 +30,7 @@ func MallAddSupplyGoodsConsume(queue md.MqQueue) { //1、将自己绑定到交换机上 ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) //2、取出数据进行消费 - ch.Qos(10) + ch.Qos(1) delivery := ch.Consume(queue.Name, false) var res amqp.Delivery @@ -58,15 +59,11 @@ func handleMallAddSupplyGoodsConsume(msgData []byte) error { } //解析mq中queue的数据结构体 - strs := aes.AesDecryptByECB(aes.AesKey, msg["aes_data"]) var pushStuct struct { - Args struct { - GoodsInfo []*md3.OfficialGoods `json:"goods_info"` - md3.OfficialGoodsConditions - } `json:"args"` - Mid string `json:"mid"` + Mid string `json:"mid"` + Affected string `json:"affected"` } - err = json.Unmarshal([]byte(strs), &pushStuct) + err = json.Unmarshal([]byte(msg["data"]), &pushStuct) if err != nil { panic(err) } @@ -76,11 +73,25 @@ func handleMallAddSupplyGoodsConsume(msgData []byte) error { return nil } c.Set("mid", pushStuct.Mid) + + //查找 MallAddSupplyGoods + var mm model2.MallAddSupplyGoods + get, err := db.Db.Where("id=?", pushStuct.Affected).Get(&mm) + if err != nil { + panic(err) + } + if !get { + return errors.New("未查询到记录:::" + pushStuct.Affected) + } var t struct { GoodsInfo []*md3.OfficialGoods `json:"goods_info"` md3.OfficialGoodsConditions } - t = pushStuct.Args + + err = json.Unmarshal([]byte(mm.Data), &t) + if err != nil { + panic(err) + } var conditions md3.OfficialGoodsConditions conditions.CategoryId = t.CategoryId conditions.AddPriceBase = t.AddPriceBase diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 1d16924..4d2e54e 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -40,7 +40,7 @@ var RabbitMqQueueKeyList = []*MqQueue{ }, { ExchangeName: "zhios.addSupplyGoods.exchange", - Name: "mall_add_supply_goods", + Name: "new_mall_add_supply_goods", Type: FanOutQueueType, IsPersistent: false, RoutKey: "",