1
This commit is contained in:
@@ -34,10 +34,27 @@ func OnCallbackMsg(msg *mtwmapi.CallbackMsg, msgType string) (response *mtwmapi.
|
||||
_, err := netprinter.PrintStoreStatus(jxcontext.AdminCtx, storeDetail, model.VendorIDMTWM, -9)
|
||||
response = mtwmapi.Err2CallbackResponse(err, "")
|
||||
} else if msg.Cmd == mtwmapi.MsgTypeSkuUpdate {
|
||||
globals.SugarLogger.Debugf("-----MsgTypeSkuUpdate := %s", utils.Format4Output(msg.FormData.Get("retail_data"), false))
|
||||
dataMap := make([]*mtwmapi.VendorUpdateSkuCallback, 0, 0)
|
||||
json.Unmarshal([]byte(msg.FormData.Get("retail_data")), &dataMap)
|
||||
globals.SugarLogger.Debugf("-----MsgTypeSkuUpdate := %s", utils.Format4Output(dataMap, false))
|
||||
if len(dataMap) != 0 {
|
||||
for _, v := range dataMap {
|
||||
globals.SugarLogger.Debugf("-----MsgTypeSkuUpdate := %s", utils.Format4Output(v, false))
|
||||
if v.AppFoodCode != "" && v.AppPoiCode != "" {
|
||||
storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), v.AppPoiCode, model.VendorIDMTWM, utils.Int2Str(v.AppId))
|
||||
if storeDetail != nil {
|
||||
param := []interface{}{}
|
||||
switch v.DiffContents.IsSoldOut.Result {
|
||||
case 1: // 下架
|
||||
param = append(param, 0)
|
||||
case 0: // 上架
|
||||
param = append(param, 1)
|
||||
}
|
||||
param = append(param, mtwmapi.MsgTypeSkuUpdate, storeDetail.ID, v.AppFoodCode)
|
||||
dao.ExecuteSQL(dao.GetDB(), "UPDATE store_sku_bind SET status = ?,last_operator = ? WHERE store_id = ? AND sku_id = ? ", param...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return mtwmapi.Err2CallbackResponse(nil, "")
|
||||
} else {
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -148,24 +149,25 @@ func (c *MtwmController) DeliveryFeeChange() {
|
||||
|
||||
// Invoice 发票推送
|
||||
func (c *MtwmController) Invoice() {
|
||||
body, err := ioutil.ReadAll(c.Ctx.Request.Body)
|
||||
if err != nil {
|
||||
msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse != nil {
|
||||
c.Data["json"] = map[string]interface{}{"result_code": -1}
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
globals.SugarLogger.Debugf("------Invoice:= %s", string(body))
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "MtwmController发票推送", string(body))
|
||||
globals.SugarLogger.Debugf("------Invoice:= %s", utils.Format4Output(msg.FormData, false))
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "MtwmController发票推送", utils.Format4Output(msg.FormData, false))
|
||||
|
||||
data := &mtwmapi.InvoiceCallback{}
|
||||
if err = json.Unmarshal(body, data); err != nil {
|
||||
byteData, _ := json.Marshal(msg.Data)
|
||||
if err := json.Unmarshal(byteData, data); err != nil {
|
||||
c.Data["json"] = map[string]interface{}{"result_code": -1}
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 消息通知
|
||||
if err = mtwm.InvoiceCallback(data); err != nil {
|
||||
if err := mtwm.InvoiceCallback(data); err != nil {
|
||||
globals.SugarLogger.Errorf("mtwm Invoice err := %v", err)
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"result_code": 1}
|
||||
|
||||
Reference in New Issue
Block a user