- 饿百常量命名修改,支持用户申请取消与调整单

This commit is contained in:
gazebo
2019-04-18 17:39:23 +08:00
parent aedf0547e6
commit e5fbdec9ba
4 changed files with 49 additions and 19 deletions

View File

@@ -245,6 +245,7 @@ func (s *DefScheduler) OnOrderStatusChanged(status *model.OrderStatus, isPending
if status.LockStatus != model.OrderStatusUnknown || status.Status > model.OrderStatusUnknown {
globals.SugarLogger.Debugf("OnOrderStatusChanged orderID:%s %s, status:%v", status.VendorOrderID, model.OrderStatusName[status.Status], status)
savedOrderInfo := s.loadSavedOrderFromMap(status, true)
s.updateOrderByStatus(savedOrderInfo.order, status)
// if status.Status == model.OrderStatusNew {
// if !isPending {
// utils.CallFuncAsync(func() {
@@ -252,7 +253,6 @@ func (s *DefScheduler) OnOrderStatusChanged(status *model.OrderStatus, isPending
// })
// }
// }
s.updateOrderByStatus(savedOrderInfo.order, status)
if status.LockStatus == model.OrderStatusUnknown && status.Status > model.OrderStatusUnknown { // 只处理状态转换,一般消息不处理
s.resetTimer(savedOrderInfo, nil, isPending)
if status.Status >= model.OrderStatusDelivering {
@@ -280,9 +280,11 @@ func (s *DefScheduler) OnOrderStatusChanged(status *model.OrderStatus, isPending
} else if status.Status == model.OrderStatusApplyCancel {
globals.SugarLogger.Debugf("OnOrderStatusChanged orderID:%s %s, status:%v", status.VendorOrderID, model.OrderStatusName[status.Status], status)
savedOrderInfo := s.loadSavedOrderFromMap(status, true)
s.updateOrderByStatus(savedOrderInfo.order, status)
utils.CallFuncAsync(func() {
weixinmsg.NotifyUserApplyCancel(savedOrderInfo.order, status.Remark)
})
msghub.OnUserApplyCancel(savedOrderInfo.order)
}
return err
}

View File

@@ -15,8 +15,10 @@ const (
ServerMsgRegister = "register"
ServerMsgUnregister = "unregister"
ServerMsgPing = "ping"
ServerMsgNewOrder = "newOrder"
ServerMsgPing = "ping"
ServerMsgNewOrder = "newOrder"
ServerMsgUserApplyCancel = "userApplyCancel"
)
const (
@@ -162,3 +164,19 @@ func OnNewOrder(order *model.GoodsOrder) {
}
})
}
func OnUserApplyCancel(order *model.GoodsOrder) {
globals.SugarLogger.Debugf("msghub OnUserApplyCancel, order:%s", utils.Format4Output(order, false))
utils.CallFuncAsync(func() {
msgChan <- &ServerMsg{
Type: ServerMsgUserApplyCancel,
StoreID: jxutils.GetSaleStoreIDFromOrder(order),
MsgData: 1,
// MsgData: []*model.GoodsOrderExt{
// &model.GoodsOrderExt{
// GoodsOrder: *order,
// },
// },
}
})
}

View File

@@ -21,8 +21,8 @@ func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
}
} else if msg.Cmd == ebaiapi.CmdOrderUserCancel { // 全额退款处理
messageType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"])) == ebaiapi.AfterOrderFinishedCancelType &&
(messageType == ebaiapi.OrderUserCancelSuccessA || messageType == ebaiapi.OrderUserCancelSuccessB) {
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"])) == ebaiapi.OrderUserCancelTypeAfterSale &&
(messageType == ebaiapi.OrderUserCancelCSAgreed || messageType == ebaiapi.OrderUserCancelMerchantAgreed) {
globals.SugarLogger.Debug(utils.Interface2String(msg.Body["order_id"])) // 获得退款订单ID去本地数据库拿饿百消息推送只给了订单号但是没有查询全额退款的接口只有部分退款才可以查询
afsOrderID := utils.Interface2String(msg.Body["order_id"])
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDEBAI)

View File

@@ -23,19 +23,20 @@ const (
callDeliveryDelay = 10 * time.Minute
callDeliveryDelayGap = 30
// fakePickedUp = "9527"
fakeUserApplyCancel = "fake_user_apply_cancel"
fakeAcceptOrder = "fake_accept_order"
fakePartRefundFinished = "fake_part_refund_finished"
fakeUserApplyCancel = "fake_user_apply_cancel"
fakeAcceptOrder = "fake_accept_order"
fakeOrderAdjustFinished = "fake_order_adjust_finished"
)
// 饿百的接单会直接召唤配送,为了统一将饿百的接单影射成拣货完成,然后模拟一个接单消息
var (
VendorStatus2StatusMap = map[string]int{
ebaiapi.OrderStatusNew: model.OrderStatusNew,
fakeAcceptOrder: model.OrderStatusAccepted,
// fakePartRefundFinished: model.OrderStatusAdjust,
fakeOrderAdjustFinished: model.OrderStatusAdjust,
ebaiapi.OrderStatusNew: model.OrderStatusNew,
fakeAcceptOrder: model.OrderStatusAccepted,
ebaiapi.OrderStatusAccepted: model.OrderStatusFinishedPickup,
fakeUserApplyCancel: model.OrderStatusApplyCancel,
ebaiapi.OrderStatusCourierAccepted: model.OrderStatusDelivering,
@@ -263,19 +264,26 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
StatusTime: utils.Timestamp2Time(msg.Timestamp),
}
if msg.Cmd == ebaiapi.CmdOrderUserCancel {
cancelType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
if cancelType == ebaiapi.OrderUserApplyCancel {
msgType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
cancelType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"]))
if msgType == ebaiapi.OrderUserCancelApply && cancelType == ebaiapi.OrderUserCancelTypeBeforeSale {
orderStatus.VendorStatus = fakeUserApplyCancel
orderStatus.Status = c.GetStatusFromVendorStatus(orderStatus.VendorStatus)
orderStatus.Remark = utils.Interface2String(msg.Body["cancel_reason"])
if additionReason := utils.Interface2String(msg.Body["addition_reason"]); additionReason != "" {
orderStatus.Remark += ",额外原因:" + additionReason
}
} else {
orderStatus = nil
}
} else if msg.Cmd == ebaiapi.CmdOrderPartRefund {
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"])) == ebaiapi.OrderPartRefundSuccess {
orderStatus.VendorStatus = fakePartRefundFinished
orderStatus.Status = c.GetStatusFromVendorStatus(orderStatus.VendorStatus)
msgType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
status := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"]))
if msgType == ebaiapi.OrderPartRefuncTypeMerchant && status == ebaiapi.OrderPartRefundSuccess {
orderStatus.VendorStatus = fakeOrderAdjustFinished
orderStatus.Remark = utils.Interface2String(msg.Body["reason"])
if additionReason := utils.Interface2String(msg.Body["addition_reason"]); additionReason != "" {
orderStatus.Remark += ",额外原因:" + additionReason
}
} else {
orderStatus = nil
}
@@ -285,12 +293,14 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
} else {
orderStatus.VendorStatus = utils.Int64ToStr(utils.MustInterface2Int64(status))
}
orderStatus.Status = c.GetStatusFromVendorStatus(orderStatus.VendorStatus)
orderStatus.Remark = utils.Interface2String(msg.Body["reason"])
} else {
orderStatus = nil
globals.SugarLogger.Infof("ebai callbackMsg2Status can not find status field in msg:%s", utils.Format4Output(msg, false))
}
if orderStatus != nil {
orderStatus.Status = c.GetStatusFromVendorStatus(orderStatus.VendorStatus)
}
return orderStatus
}