This commit is contained in:
suyl
2021-06-15 10:15:47 +08:00
parent b4688c4a77
commit c57d3dabb5
3 changed files with 32 additions and 34 deletions

View File

@@ -2,14 +2,10 @@ package jd
import ( import (
"git.rosy.net.cn/baseapi/platformapi/jdapi" "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) { 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 { if CurPurchaseHandler != nil {
globals.SugarLogger.Debugf("jd deliverOrder 3.6 %v", utils.Format4Output(msg, true))
retVal = CurPurchaseHandler.OnOrderMsg(a, msg) retVal = CurPurchaseHandler.OnOrderMsg(a, msg)
} }
return retVal return retVal

View File

@@ -63,7 +63,6 @@ func (c *PurchaseHandler) OnOrderMsg(a *jdapi.API, msg *jdapi.CallbackOrderMsg)
primaryID := msg.BillID primaryID := msg.BillID
primaryID += utils.Int64ToStr(time.Now().Unix()) primaryID += utils.Int64ToStr(time.Now().Unix())
jxutils.CallMsgHandler(func() { jxutils.CallMsgHandler(func() {
globals.SugarLogger.Debugf("jd deliverOrder 3.7 ")
retVal = c.onOrderMsg(a, msg) retVal = c.onOrderMsg(a, msg)
}, primaryID) }, primaryID)
return retVal return retVal
@@ -143,33 +142,38 @@ func (c *PurchaseHandler) onOrderInfoChangeMsg(vendorOrgCode string, msg *jdapi.
order, err := dao.GetSimpleOrder(db, msg.BillID) order, err := dao.GetSimpleOrder(db, msg.BillID)
if err == nil { if err == nil {
globals.SugarLogger.Debugf("onOrderInfoChangeMsg msg:%v", utils.Format4Output(msg, false)) globals.SugarLogger.Debugf("onOrderInfoChangeMsg msg:%v", utils.Format4Output(msg, false))
if msg.BuyerFullAddress != "" { //任意一项变了
order.ConsigneeAddress = msg.BuyerFullAddress 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 ||
if msg.BuyerFullName != "" { msg.OrderBuyerRemark != order.BuyerComment {
order.ConsigneeName = msg.BuyerFullName if msg.BuyerFullAddress != "" {
} order.ConsigneeAddress = msg.BuyerFullAddress
if msg.BuyerMobile != "" { }
order.ConsigneeMobile = msg.BuyerMobile if msg.BuyerFullName != "" {
} order.ConsigneeName = msg.BuyerFullName
if msg.BuyerLat != "" { }
order.ConsigneeLat = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLat)) if msg.BuyerMobile != "" {
} order.ConsigneeMobile = msg.BuyerMobile
if msg.BuyerLng != "" { }
order.ConsigneeLng = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLng)) if msg.BuyerLat != "" {
} order.ConsigneeLat = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLat))
if msg.OrderBuyerRemark != "" { }
order.BuyerComment = msg.OrderBuyerRemark if msg.BuyerLng != "" {
} order.ConsigneeLng = jxutils.StandardCoordinate2Int(utils.Str2Float64(msg.BuyerLng))
_, err = dao.UpdateEntity(db, order, "ConsigneeAddress", "ConsigneeName", "ConsigneeMobile", "ConsigneeLat", "ConsigneeLng", "BuyerComment") }
if order.Status <= model.OrderStatusEndBegin { if msg.OrderBuyerRemark != "" {
if order.BusinessType == model.BusinessTypeImmediate { order.BuyerComment = msg.OrderBuyerRemark
if time.Now().Sub(order.OrderCreatedAt).Hours() <= 1 { }
weixinmsg.NotifyOrderChanged(order) _, err = dao.UpdateEntity(db, order, "ConsigneeAddress", "ConsigneeName", "ConsigneeMobile", "ConsigneeLat", "ConsigneeLng", "BuyerComment")
} if order.Status <= model.OrderStatusEndBegin {
} else { if order.BusinessType == model.BusinessTypeImmediate {
if order.ExpectedDeliveredTime.Sub(time.Now()).Hours() >= 1 { if time.Now().Sub(order.OrderCreatedAt).Hours() <= 1 {
weixinmsg.NotifyOrderChanged(order) weixinmsg.NotifyOrderChanged(order)
}
} else {
if order.ExpectedDeliveredTime.Sub(time.Now()).Hours() >= 1 {
weixinmsg.NotifyOrderChanged(order)
}
} }
} }
} }

View File

@@ -39,9 +39,7 @@ func (c *DjswController) orderStatus() {
if c.Ctx.Input.Method() == http.MethodPost { if c.Ctx.Input.Method() == http.MethodPost {
globals.SugarLogger.Debugf("jd deliverOrder 1") globals.SugarLogger.Debugf("jd deliverOrder 1")
callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { 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) callbackResponse = jd.OnOrderMsg(obj.(*jdapi.CallbackOrderMsg), a)
globals.SugarLogger.Debugf("jd deliverOrder 3", utils.Format4Output(callbackResponse, false))
return callbackResponse return callbackResponse
}) })
c.Data["json"] = c.transferResponse("orderStatus", callbackResponse) c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)