From c57d3dabb5a06ffaa6dd9b050c0f8fad5ae7abec Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 15 Jun 2021 10:15:47 +0800 Subject: [PATCH] aa --- business/partner/purchase/jd/callback.go | 4 -- business/partner/purchase/jd/order.go | 60 +++++++++++++----------- controllers/jd_callback.go | 2 - 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/business/partner/purchase/jd/callback.go b/business/partner/purchase/jd/callback.go index 7aa0bf1f8..395cdc5e3 100644 --- a/business/partner/purchase/jd/callback.go +++ b/business/partner/purchase/jd/callback.go @@ -2,14 +2,10 @@ package jd import ( "git.rosy.net.cn/baseapi/platformapi/jdapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" ) func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) { - globals.SugarLogger.Debugf("jd deliverOrder 3.5 %v", utils.Format4Output(CurPurchaseHandler, true)) if CurPurchaseHandler != nil { - globals.SugarLogger.Debugf("jd deliverOrder 3.6 %v", utils.Format4Output(msg, true)) retVal = CurPurchaseHandler.OnOrderMsg(a, msg) } return retVal diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index 046cd11b6..9a01f96ab 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -63,7 +63,6 @@ func (c *PurchaseHandler) OnOrderMsg(a *jdapi.API, msg *jdapi.CallbackOrderMsg) primaryID := msg.BillID primaryID += utils.Int64ToStr(time.Now().Unix()) jxutils.CallMsgHandler(func() { - globals.SugarLogger.Debugf("jd deliverOrder 3.7 ") retVal = c.onOrderMsg(a, msg) }, primaryID) return retVal @@ -143,33 +142,38 @@ func (c *PurchaseHandler) onOrderInfoChangeMsg(vendorOrgCode string, msg *jdapi. order, err := dao.GetSimpleOrder(db, msg.BillID) if err == nil { globals.SugarLogger.Debugf("onOrderInfoChangeMsg msg:%v", utils.Format4Output(msg, false)) - if msg.BuyerFullAddress != "" { - order.ConsigneeAddress = msg.BuyerFullAddress - } - if msg.BuyerFullName != "" { - order.ConsigneeName = msg.BuyerFullName - } - if msg.BuyerMobile != "" { - order.ConsigneeMobile = msg.BuyerMobile - } - if msg.BuyerLat != "" { - order.ConsigneeLat = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLat)) - } - if msg.BuyerLng != "" { - order.ConsigneeLng = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLng)) - } - if msg.OrderBuyerRemark != "" { - order.BuyerComment = msg.OrderBuyerRemark - } - _, err = dao.UpdateEntity(db, order, "ConsigneeAddress", "ConsigneeName", "ConsigneeMobile", "ConsigneeLat", "ConsigneeLng", "BuyerComment") - if order.Status <= model.OrderStatusEndBegin { - if order.BusinessType == model.BusinessTypeImmediate { - if time.Now().Sub(order.OrderCreatedAt).Hours() <= 1 { - weixinmsg.NotifyOrderChanged(order) - } - } else { - if order.ExpectedDeliveredTime.Sub(time.Now()).Hours() >= 1 { - weixinmsg.NotifyOrderChanged(order) + //任意一项变了 + if msg.BuyerFullAddress != order.ConsigneeAddress || msg.BuyerFullName != order.ConsigneeName || msg.BuyerMobile != order.ConsigneeMobile || + jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLat)) != order.ConsigneeLat || jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLng)) != order.ConsigneeLng || + msg.OrderBuyerRemark != order.BuyerComment { + if msg.BuyerFullAddress != "" { + order.ConsigneeAddress = msg.BuyerFullAddress + } + if msg.BuyerFullName != "" { + order.ConsigneeName = msg.BuyerFullName + } + if msg.BuyerMobile != "" { + order.ConsigneeMobile = msg.BuyerMobile + } + if msg.BuyerLat != "" { + order.ConsigneeLat = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLat)) + } + if msg.BuyerLng != "" { + order.ConsigneeLng = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLng)) + } + if msg.OrderBuyerRemark != "" { + order.BuyerComment = msg.OrderBuyerRemark + } + _, err = dao.UpdateEntity(db, order, "ConsigneeAddress", "ConsigneeName", "ConsigneeMobile", "ConsigneeLat", "ConsigneeLng", "BuyerComment") + if order.Status <= model.OrderStatusEndBegin { + if order.BusinessType == model.BusinessTypeImmediate { + if time.Now().Sub(order.OrderCreatedAt).Hours() <= 1 { + weixinmsg.NotifyOrderChanged(order) + } + } else { + if order.ExpectedDeliveredTime.Sub(time.Now()).Hours() >= 1 { + weixinmsg.NotifyOrderChanged(order) + } } } } diff --git a/controllers/jd_callback.go b/controllers/jd_callback.go index 0c3655f92..2c87f9d77 100644 --- a/controllers/jd_callback.go +++ b/controllers/jd_callback.go @@ -39,9 +39,7 @@ func (c *DjswController) orderStatus() { if c.Ctx.Input.Method() == http.MethodPost { globals.SugarLogger.Debugf("jd deliverOrder 1") callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - globals.SugarLogger.Debugf("jd deliverOrder 2", utils.Format4Output(callbackResponse, false)) callbackResponse = jd.OnOrderMsg(obj.(*jdapi.CallbackOrderMsg), a) - globals.SugarLogger.Debugf("jd deliverOrder 3", utils.Format4Output(callbackResponse, false)) return callbackResponse }) c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)