From ae58b41ac64039a7f1d4d8dc9076f31053ed57d5 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 14:06:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E7=9B=9F?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 4 ++++ controllers/weimob_callback.go | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index e5d89e979..8d088336b 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -26,11 +26,14 @@ func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResp } func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { + globals.SugarLogger.Debugf("onOrderMsg:%s", utils.Format4Output(msg, true)) if msg.Event == weimobapi.MsgEventOrderStatusChange { if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { changeStoreSkusByOrder(orderDetail) } + } else { + response = weimobapi.Err2CallbackResponse(err, "") } } return response @@ -43,6 +46,7 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { if len(storeList) == 1 { var skuBindInfos []*cms.StoreSkuBindInfo storeID := storeList[0].ID + globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID) for _, v := range order.ItemList { nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0)) unitPrice := v.OriginalPrice diff --git a/controllers/weimob_callback.go b/controllers/weimob_callback.go index 7989ae264..ff3c8b5b5 100644 --- a/controllers/weimob_callback.go +++ b/controllers/weimob_callback.go @@ -2,8 +2,8 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/weimobapi" - "git.rosy.net.cn/jx-callback/business/jxutils/tasks" "git.rosy.net.cn/jx-callback/business/cs" + "git.rosy.net.cn/jx-callback/business/jxutils/tasks" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego" @@ -15,12 +15,14 @@ type WeimobController struct { func (c *WeimobController) onCallbackMsg() { if true { //c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := weimobapi.SuccessResponse msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) if callbackResponse == nil { // callbackResponse = wsc.OnCallbackMsg(msg) callbackResponse = cs.OnCallbackMsg(msg) } + if callbackResponse == nil { + callbackResponse = weimobapi.SuccessResponse + } c.Data["json"] = callbackResponse c.ServeJSON() } else { From a2c3107ee06c2023b93b10bc68b050779a853479 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 14:20:50 +0800 Subject: [PATCH 2/2] up --- business/cs/weimob_order.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 8d088336b..cdcb2e0ec 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -13,8 +13,8 @@ import ( ) const ( - minCSOrderPayment = 0 // 供货订单的最小金额 - maxUnitPrice = 3000 // 为防止误填单价,限制单价最高 + minCSOrderPayment = 0 // 供货订单的最小金额(单位为元) + maxUnitPrice = 3000 // 为防止误填单价,限制单价最高(单位为分) ) func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { @@ -33,6 +33,7 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons changeStoreSkusByOrder(orderDetail) } } else { + globals.SugarLogger.Debugf("onOrderMsg order:%s failed with err:%v", msg.OrderNo, err) response = weimobapi.Err2CallbackResponse(err, "") } } @@ -40,6 +41,7 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons } func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { + globals.SugarLogger.Debugf("changeStoreSkusByOrder order:%s", utils.Format4Output(order, true)) receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, "") if err != nil { @@ -64,9 +66,13 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { } if len(skuBindInfos) > 0 { cms.UpdateStoreSkus(jxcontext.NewWithUserName(nil, utils.LimitStringLen(utils.Int64ToStr(order.OrderNo), 32), nil, nil), storeID, skuBindInfos, true, true) + } else { + globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d is empty", storeID) } } else { globals.SugarLogger.Infof("[运营],微商城订单:%s,手机:%s找不到唯一一个京西门店%d", order.OrderNo, receiverMobile, len(storeList)) } + } else { + globals.SugarLogger.Warnf("changeStoreSkusByOrder receiverMobile:%s failed with err:%v", receiverMobile, err) } }