- 饿百售后单
- 售后单重构一下下
This commit is contained in:
@@ -82,7 +82,7 @@ func (p *PurchaseHandler) GetOrder4PartRefund(vendorOrderID string) (order *mode
|
||||
if taskID == 1 {
|
||||
result1, err1 = api.EbaiAPI.OrderGet(vendorOrderID)
|
||||
} else if taskID == 2 {
|
||||
result2, err2 = api.EbaiAPI.OrderPartrefundGet(vendorOrderID)
|
||||
result2, err2 = api.EbaiAPI.OrderPartRefundGet(vendorOrderID)
|
||||
}
|
||||
return nil, nil
|
||||
}, taskIDs)
|
||||
@@ -295,22 +295,26 @@ func (p *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName
|
||||
|
||||
//
|
||||
func (c *PurchaseHandler) onOrderMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiapi.CallbackResponse) {
|
||||
if ebaiapi.CmdOrderCreate == msg.Cmd {
|
||||
retVal = c.onOrderNew(msg)
|
||||
if c.isAfsMsg(msg) {
|
||||
retVal = c.OnAfsOrderMsg(msg)
|
||||
} else {
|
||||
status := c.callbackMsg2Status(msg)
|
||||
var err error
|
||||
if status != nil {
|
||||
if status.Status == model.OrderStatusAdjust {
|
||||
var order *model.GoodsOrder
|
||||
if order, err = c.GetOrder4PartRefund(GetOrderIDFromMsg(msg)); err == nil {
|
||||
err = partner.CurOrderManager.OnOrderAdjust(order, status)
|
||||
if ebaiapi.CmdOrderCreate == msg.Cmd {
|
||||
retVal = c.onOrderNew(msg)
|
||||
} else {
|
||||
var err error
|
||||
status := c.callbackMsg2Status(msg)
|
||||
if status != nil {
|
||||
if status.Status == model.OrderStatusAdjust {
|
||||
var order *model.GoodsOrder
|
||||
if order, err = c.GetOrder4PartRefund(GetOrderIDFromMsg(msg)); err == nil {
|
||||
err = partner.CurOrderManager.OnOrderAdjust(order, status)
|
||||
}
|
||||
} else {
|
||||
err = partner.CurOrderManager.OnOrderStatusChanged(status)
|
||||
}
|
||||
} else {
|
||||
err = partner.CurOrderManager.OnOrderStatusChanged(status)
|
||||
}
|
||||
retVal = api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, nil)
|
||||
}
|
||||
retVal = api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, nil)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
@@ -342,13 +346,10 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
|
||||
VendorStatus: msg.Cmd,
|
||||
}
|
||||
if msg.Cmd == ebaiapi.CmdOrderUserCancel {
|
||||
msgType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
|
||||
cancelType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"]))
|
||||
orderStatus.Remark = utils.Interface2String(msg.Body["cancel_reason"])
|
||||
orderStatus.VendorStatus = msg.Cmd + "-" + msgType
|
||||
if additionReason := utils.Interface2String(msg.Body["addition_reason"]); additionReason != "" {
|
||||
orderStatus.Remark += ",额外原因:" + additionReason
|
||||
}
|
||||
msgType := int(utils.MustInterface2Int64(msg.Body["type"]))
|
||||
cancelType := int(utils.MustInterface2Int64(msg.Body["cancel_type"]))
|
||||
orderStatus.Remark = buildFullReason(utils.Interface2String(msg.Body["cancel_reason"]), utils.Interface2String(msg.Body["addition_reason"]))
|
||||
orderStatus.VendorStatus = msg.Cmd + "-" + utils.Int2Str(msgType)
|
||||
if cancelType == ebaiapi.OrderUserCancelTypeBeforeSale {
|
||||
if msgType == ebaiapi.OrderUserCancelApply ||
|
||||
msgType == ebaiapi.OrderUserCancelCSIntervene {
|
||||
@@ -360,12 +361,9 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
|
||||
}
|
||||
}
|
||||
} else if msg.Cmd == ebaiapi.CmdOrderPartRefund {
|
||||
msgType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
|
||||
status := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"]))
|
||||
orderStatus.Remark = utils.Interface2String(msg.Body["reason"])
|
||||
if additionReason := utils.Interface2String(msg.Body["addition_reason"]); additionReason != "" {
|
||||
orderStatus.Remark += ",额外原因:" + additionReason
|
||||
}
|
||||
msgType := int(utils.MustInterface2Int64(msg.Body["type"]))
|
||||
status := int(utils.MustInterface2Int64(msg.Body["status"]))
|
||||
orderStatus.Remark = buildFullReason(utils.Interface2String(msg.Body["reason"]), utils.Interface2String(msg.Body["addition_reason"]))
|
||||
if msgType == ebaiapi.OrderPartRefuncTypeMerchant && status == ebaiapi.OrderPartRefundSuccess {
|
||||
orderStatus.VendorStatus = fakeOrderAdjustFinished
|
||||
}
|
||||
@@ -381,6 +379,14 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
|
||||
return orderStatus
|
||||
}
|
||||
|
||||
func buildFullReason(reason, addReason string) (fullReason string) {
|
||||
fullReason = reason
|
||||
if addReason != "" {
|
||||
fullReason += ",额外原因:" + addReason
|
||||
}
|
||||
return fullReason
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *partner.StatusActionParams) {
|
||||
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted {
|
||||
params = &partner.StatusActionParams{ // PickDeadline没有设置时才有效,饿百要求在5分钟内拣货,不然订单会被取消
|
||||
|
||||
Reference in New Issue
Block a user