|
@@ -1,8 +1,9 @@ |
|
|
package consume |
|
|
package consume |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"applet/app/db" |
|
|
|
|
|
model2 "applet/app/db/offical/model" |
|
|
svc2 "applet/app/svc" |
|
|
svc2 "applet/app/svc" |
|
|
"applet/app/utils/aes" |
|
|
|
|
|
"applet/app/utils/logx" |
|
|
"applet/app/utils/logx" |
|
|
"applet/consume/md" |
|
|
"applet/consume/md" |
|
|
md3 "applet/mall/md" |
|
|
md3 "applet/mall/md" |
|
@@ -29,7 +30,7 @@ func MallAddSupplyGoodsConsume(queue md.MqQueue) { |
|
|
//1、将自己绑定到交换机上 |
|
|
//1、将自己绑定到交换机上 |
|
|
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) |
|
|
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) |
|
|
//2、取出数据进行消费 |
|
|
//2、取出数据进行消费 |
|
|
ch.Qos(10) |
|
|
|
|
|
|
|
|
ch.Qos(1) |
|
|
delivery := ch.Consume(queue.Name, false) |
|
|
delivery := ch.Consume(queue.Name, false) |
|
|
|
|
|
|
|
|
var res amqp.Delivery |
|
|
var res amqp.Delivery |
|
@@ -58,15 +59,11 @@ func handleMallAddSupplyGoodsConsume(msgData []byte) error { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//解析mq中queue的数据结构体 |
|
|
//解析mq中queue的数据结构体 |
|
|
strs := aes.AesDecryptByECB(aes.AesKey, msg["aes_data"]) |
|
|
|
|
|
var pushStuct struct { |
|
|
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 { |
|
|
if err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
@@ -76,11 +73,25 @@ func handleMallAddSupplyGoodsConsume(msgData []byte) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
c.Set("mid", pushStuct.Mid) |
|
|
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 { |
|
|
var t struct { |
|
|
GoodsInfo []*md3.OfficialGoods `json:"goods_info"` |
|
|
GoodsInfo []*md3.OfficialGoods `json:"goods_info"` |
|
|
md3.OfficialGoodsConditions |
|
|
md3.OfficialGoodsConditions |
|
|
} |
|
|
} |
|
|
t = pushStuct.Args |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = json.Unmarshal([]byte(mm.Data), &t) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
panic(err) |
|
|
|
|
|
} |
|
|
var conditions md3.OfficialGoodsConditions |
|
|
var conditions md3.OfficialGoodsConditions |
|
|
conditions.CategoryId = t.CategoryId |
|
|
conditions.CategoryId = t.CategoryId |
|
|
conditions.AddPriceBase = t.AddPriceBase |
|
|
conditions.AddPriceBase = t.AddPriceBase |
|
|