diff --git a/business/jxcallback/orderman/order_afs.go b/business/jxcallback/orderman/order_afs.go index 21bb07231..7019c32a0 100644 --- a/business/jxcallback/orderman/order_afs.go +++ b/business/jxcallback/orderman/order_afs.go @@ -200,6 +200,9 @@ func (c *OrderManager) addAfsOrderStatus(db *dao.DaoDB, orderStatus *model.Order if db == nil { db = dao.GetDB() } + if orderStatus.RefVendorOrderID == "3801105140856800486" { + globals.SugarLogger.Debugf("======orderStatus := %s", utils.Format4Output(orderStatus, false)) + } isDuplicated, err = addOrderOrWaybillStatus(orderStatus, db) //if err == nil && !isDuplicated && (orderStatus.Status != model.OrderStatusUnknown && orderStatus.Status != model.OrderStatusMsg) { if err == nil && (orderStatus.Status != model.OrderStatusUnknown && orderStatus.Status != model.OrderStatusMsg) { @@ -208,6 +211,9 @@ func (c *OrderManager) addAfsOrderStatus(db *dao.DaoDB, orderStatus *model.Order VendorID: orderStatus.VendorID, } if err = db.Db.ReadForUpdate(order, "AfsOrderID", "VendorID"); err == nil { + if orderStatus.RefVendorOrderID == "3801105140856800486" { + globals.SugarLogger.Debugf("======order := %s", utils.Format4Output(order, false)) + } if orderStatus.Status > model.OrderStatusUnknown { // todo 要求status不能回绕 order.VendorStatus = orderStatus.VendorStatus order.Status = orderStatus.Status @@ -230,9 +236,15 @@ func (c *OrderManager) addAfsOrderStatus(db *dao.DaoDB, orderStatus *model.Order updateFields = append(updateFields, "AfsFinishedAt") if handler := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID); handler != nil { if orderAfsInfo, err := handler.GetOrderAfsInfo(nil, order.VendorOrderID, order.AfsOrderID); err == nil && orderAfsInfo.AfsTotalShopMoney != 0 { + if orderStatus.RefVendorOrderID == "3801105140856800486" { + globals.SugarLogger.Debugf("======orderAfsInfo := %s", utils.Format4Output(orderAfsInfo, false)) + } order.AfsTotalShopMoney = orderAfsInfo.AfsTotalShopMoney + updateFields = append(updateFields, "AfsTotalShopMoney") + if orderStatus.RefVendorOrderID == "3801105140856800486" { + globals.SugarLogger.Debugf("======order2 := %s", utils.Format4Output(order, false)) + } } - updateFields = append(updateFields, "AfsTotalShopMoney") } } diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index b3a55bba8..39e4e921f 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -3,7 +3,6 @@ package mtwm import ( "errors" "fmt" - "github.com/astaxie/beego/server/web" "math" "net/url" "regexp" @@ -356,9 +355,6 @@ func (c *PurchaseHandler) onOrderMsg(msg *mtwmapi.CallbackMsg) (response *mtwmap if err == nil { utils.CallFuncAsync(func() { if msg.Cmd == mtwmapi.MsgTypeNewOrder { - if order.VendorOrderID == "2301091492659134406" && web.BConfig.RunMode == "jxgy" { - globals.SugarLogger.Debugf("============orderMap %s", utils.Format4Output(orderMap, false)) - } c.OnOrderDetail(orderMap, partner.CreatedPeration) } else { c.OnOrderDetail(orderMap, partner.UpdatedPeration) diff --git a/business/partner/purchase/mtwm/order_afs.go b/business/partner/purchase/mtwm/order_afs.go index 456825dbb..a90fc23ff 100644 --- a/business/partner/purchase/mtwm/order_afs.go +++ b/business/partner/purchase/mtwm/order_afs.go @@ -46,10 +46,10 @@ func (c *PurchaseHandler) isAfsMsg(msg *mtwmapi.CallbackMsg) bool { // refundData := msg.Data.(*mtwmapi.CallbackRefundInfo) orderID := utils.Str2Int64(GetOrderIDFromMsg(msg)) order, _ := partner.CurOrderManager.LoadOrder(utils.Int64ToStr(orderID), model.VendorIDMTWM) + if orderID == 3801105140856800486 { + return true + } if order != nil { - //status, err := getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), order.VendorStoreID).OrderViewStatus(orderID) - //if err == nil { - //return utils.Int2Str(status) == mtwmapi.OrderStatusFinished return true //TODO 有的美团订单售前退款,也当做售后处理试试 //} } @@ -70,7 +70,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma orderStatus := c.callbackAfsMsg2Status(msg) needCallNew := orderStatus.Status == model.AfsOrderStatusWait4Approve || orderStatus.Status == model.AfsOrderStatusNew if !needCallNew { - _, err := partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID) + _, err = partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID) if err != nil { if dao.IsNoRowsError(err) { needCallNew = true @@ -98,8 +98,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma ReasonDesc: utils.LimitUTF8StringLen(refundData.Reason, 1024), ReasonImgList: utils.LimitUTF8StringLen(strings.Join(refundData.PictureList, ","), 1024), RefundType: model.AfsTypePartRefund, - - VendorOrgCode: msg.AppID, + VendorOrgCode: msg.AppID, // FreightUserMoney: afsInfo.OrderFreightMoney, // AfsFreightMoney: afsInfo.AfsFreight, // BoxMoney: afsInfo.PackagingMoney, @@ -181,6 +180,16 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma order.Status = model.OrderStatusCanceled dao.UpdateEntity(dao.GetDB(), order, "Status") } + + //// 可能存在退差价的情况 + //if strings.Contains(orderStatus.Remark, "退差价") { + // afsOrder, _ := partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID) + // afsOrder.AfsTotalShopMoney = utils.Float64TwoInt64(utils.Str2Float64(msg.FormData.Get("key")) * 100) + // dao.UpdateEntity(dao.GetDB(), afsOrder, "AfsTotalShopMoney") + // + // ?? + // order.TotalShopMoney = order.TotalShopMoney - afsOrder.AfsTotalShopMoney + //} } // 新订单平台自动同意退单,某一些情况下产生的运单没退!这个处理一下! diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 7f404edb0..a80e90950 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -265,7 +265,7 @@ func GetCategoryAttrValueList(appOrgCode, keyword string, attrID int) (categoryA // GetRetailRecommendTag 根据商品UPC或名称或类目ID查询平台推荐类目及类目属性信息 func GetRetailRecommendTag(appOrgCode, appPoiCode, name string, tagID, tagType int) (*mtwmapi.RetailRecommendTagResp, error) { - if resp, err := getAPI(appOrgCode, 0, "").RetailRecommendTag(name, appPoiCode, tagID, tagType); err == nil { + if resp, err := getAPI(appOrgCode, 0, appPoiCode).RetailRecommendTag(name, appPoiCode, tagID, tagType); err == nil { return resp, nil } else { return nil, err diff --git a/controllers/mtwm_callback.go b/controllers/mtwm_callback.go index f5871938e..bd871628d 100644 --- a/controllers/mtwm_callback.go +++ b/controllers/mtwm_callback.go @@ -18,35 +18,6 @@ func (c *MtwmController) onCallbackMsg(msgType string) { c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request) if callbackResponse == nil { - // 定时任务在拉去,暂时不推送了 - //if web.BConfig.RunMode != "jxgy" { // 订单查询不到所属门店默认为果园订单 - // vendorStoreId := msg.FormData.Get("app_poi_code") - // if vendorStoreId == "" { - // vendorStoreId = msg.FormData.Get("wm_poi_id") - // } - // if msgType == mtwmapi.MsgTypeOrderFinishedPickup { - // finishedPickup := FinishedPickup{} - // json.Unmarshal([]byte(msg.FormData.Get("pick_up_data")), &finishedPickup) - // vendorStoreId = finishedPickup.AppPoiCode - // } - // if vendorStoreId != "" { - // storeDetail, err2 := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreId, model.VendorIDMTWM, "") - // - // if storeDetail == nil { - // // 推送到果园 - // if vendorStoreId == "9472886" { - // globals.SugarLogger.Debugf("=====store:%s", utils.Format4Output(storeDetail, false)) - // globals.SugarLogger.Debugf("=====storeerr2:%s", utils.Format4Output(err2, false)) - // globals.SugarLogger.Debugf("=====msg.FormData:%s", utils.Format4Output(msg.FormData, false)) - // globals.SugarLogger.Debugf("=====msgType:%s", utils.Format4Output(msgType, false)) - // } - // pushMTWMOrder2GY(msg.FormData, msgType) - // c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") - // c.ServeJSON() - // return - // } - // } - //} callbackResponse = mtwm.OnCallbackMsg(msg, msgType) if callbackResponse == nil { callbackResponse = mtwmapi.Err2CallbackResponse(nil, "")