- 防止重复发送订单取消通知消息
This commit is contained in:
@@ -325,7 +325,8 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
|
||||
} else if order.Status > model.OrderStatusUnknown && status.Status > model.OrderStatusUnknown && order.Status != status.Status {
|
||||
globals.SugarLogger.Warnf("OnOrderStatusChanged strange order:%s, status:%s", utils.Format4Output(order, true), utils.Format4Output(status, true))
|
||||
}
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(status, false)
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(status, false) // 可能会有重复的消息(比如订单取消)
|
||||
statusChanged := savedOrderInfo.order == nil || savedOrderInfo.order.Status != order.Status
|
||||
savedOrderInfo.SetOrder(order)
|
||||
|
||||
if (model.IsOrderUnlockStatus(status.Status)) ||
|
||||
@@ -366,7 +367,7 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
|
||||
}
|
||||
if !isPending {
|
||||
if status.Status == model.OrderStatusFinishedPickup || status.Status == model.OrderStatusCanceled {
|
||||
if status.Status == model.OrderStatusCanceled {
|
||||
if statusChanged && status.Status == model.OrderStatusCanceled {
|
||||
s.notifyOrderCanceled(savedOrderInfo.order)
|
||||
}
|
||||
msghub.OnFinishedPickup(savedOrderInfo.order)
|
||||
@@ -374,7 +375,7 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
|
||||
status.Status == model.OrderStatusApplyFailedGetGoods || //model.IsOrderUnlockStatus(status.Status) ||
|
||||
status.Status == model.OrderStatusAgreeFailedGetGoods ||
|
||||
status.Status == model.OrderStatusDeliverFailed {
|
||||
if status.Status == model.OrderStatusApplyCancel {
|
||||
if statusChanged && status.Status == model.OrderStatusApplyCancel {
|
||||
s.notifyUserApplyCancel(savedOrderInfo.order, status.Remark)
|
||||
}
|
||||
msghub.OnKeyOrderStatusChanged(savedOrderInfo.order)
|
||||
|
||||
@@ -471,9 +471,8 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
||||
ORDER BY MIN(t2.seq), t1.id DESC
|
||||
LIMIT ? OFFSET ?`
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
skuNamesInfo = &SkuNamesInfo{}
|
||||
dao.Begin(db) // todo 这里用事务的原因是,SQL_CALC_FOUND_ROWS会出错
|
||||
|
||||
@@ -330,7 +330,7 @@ func NotifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) (err er
|
||||
},
|
||||
"keyword1": map[string]interface{}{ // 订单编号
|
||||
"value": fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, order.VendorOrderID),
|
||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||
"color": venderColors[order.VendorID],
|
||||
},
|
||||
"keyword2": map[string]interface{}{ // 订单日期
|
||||
"value": utils.Time2Str(order.OrderCreatedAt),
|
||||
@@ -338,7 +338,7 @@ func NotifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) (err er
|
||||
},
|
||||
"keyword3": map[string]interface{}{ // 订单内容
|
||||
"value": cancelReason,
|
||||
"color": venderColors[order.VendorID],
|
||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
"value": order.ConsigneeMobile,
|
||||
@@ -377,6 +377,10 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||
},
|
||||
"orderAddress": map[string]interface{}{
|
||||
"value": order.ConsigneeAddress,
|
||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||
},
|
||||
"orderName": map[string]interface{}{
|
||||
"value": fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, order.VendorOrderID),
|
||||
"color": venderColors[order.VendorID],
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
|
||||
@@ -365,7 +365,7 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *mtwmapi.CallbackMsg) (orderSta
|
||||
} else if notifyType == mtwmapi.NotifyTypeReject {
|
||||
vendorStatus = fakeRefuseUserApplyCancel
|
||||
} else if notifyType == mtwmapi.NotifyTypeSuccess {
|
||||
vendorStatus = fakeMerchantAgreeApplyCancel
|
||||
vendorStatus = fakeMerchantAgreeApplyCancel // todo 可能导致订单取消消息重复
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user