Просмотр исходного кода

update 供应链加入商品库

V3
DengBiao 10 месяцев назад
Родитель
Сommit
9a1ed36ef5
3 измененных файлов: 29 добавлений и 11 удалений
  1. +7
    -0
      app/db/offical/model/mall_add_supply_goods.go
  2. +21
    -10
      consume/mall_add_supply_goods.go
  3. +1
    -1
      consume/md/consume_key.go

+ 7
- 0
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)"`
}

+ 21
- 10
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


+ 1
- 1
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: "",


Загрузка…
Отмена
Сохранить