- add remark in orderstatus table.

- check order.waybill vendor id in swtich2SelfDeliverWithRetry.
This commit is contained in:
gazebo
2018-08-02 18:07:54 +08:00
parent ba98cf1e27
commit fbef61c768
5 changed files with 35 additions and 25 deletions

View File

@@ -245,7 +245,8 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.resetTimer(savedOrderInfo, bill, isPending)
if !isPending {
// todo 购买平台的运单优先级最高但这样写也可能带来问题即在这个时间因为之前3方已经接单已经发出了转自送请求而且可能成功了所以加个isSwitched2SelfDelivery状态判断
if order.WaybillVendorID == model.VendorIDUnknown || (bill.WaybillVendorID == order.VendorID && !savedOrderInfo.isSwitched2SelfDelivery) {
if order.WaybillVendorID == model.VendorIDUnknown ||
(order.VendorID == bill.WaybillVendorID && order.VendorID != order.WaybillVendorID && !savedOrderInfo.isSwitched2SelfDelivery) {
if order.WaybillVendorID != model.VendorIDUnknown {
globals.SugarLogger.Warnf("OnWaybillStatusChanged orderID:%s purchase platform waybill arrvied later, may case problem", order.VendorOrderID)
}
@@ -402,35 +403,39 @@ func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2
func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInfo, bill *model.Waybill, retryCount int, duration time.Duration) {
order := savedOrderInfo.order
globals.SugarLogger.Debugf("swtich2SelfDeliverWithRetry orderID:%s", order.VendorOrderID)
if err := s.Swtich2SelfDeliver(order); err != nil {
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
if retryCount > 0 {
time.AfterFunc(duration, func() {
jxutils.CallMsgHandlerAsync(func() {
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
}, order.VendorOrderID)
})
} else {
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry finally failed, orderID:%s bill:%v, err:%v", order.VendorOrderID, bill, err)
if order.WaybillVendorID != order.VendorID {
if err := s.Swtich2SelfDeliver(order); err != nil {
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, bill:%v, err:%v", bill, err)
if retryCount > 0 {
time.AfterFunc(duration, func() {
jxutils.CallMsgHandlerAsync(func() {
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration)
}, order.VendorOrderID)
})
} else {
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry finally failed, orderID:%s bill:%v, err:%v", order.VendorOrderID, bill, err)
tmpLog := &legacymodel.TempLog{
VendorOrderID: bill.VendorWaybillID,
RefVendorOrderID: order.VendorOrderID,
Msg: fmt.Sprintf("swtich2SelfDeliverWithRetry finally failed, orderID:%s bill:%v, err:%v", order.VendorOrderID, bill, err),
}
db := orm.NewOrm()
db.Insert(tmpLog)
tmpLog := &legacymodel.TempLog{
VendorOrderID: bill.VendorWaybillID,
RefVendorOrderID: order.VendorOrderID,
Msg: fmt.Sprintf("swtich2SelfDeliverWithRetry finally failed, orderID:%s bill:%v, err:%v", order.VendorOrderID, bill, err),
}
db := orm.NewOrm()
db.Insert(tmpLog)
if s.CancelWaybill(bill) == nil {
// 转自送失败的取消,要将订单中的运单状态更新
if s.isBillCandidate(order, bill) {
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, false)
if s.CancelWaybill(bill) == nil {
// 转自送失败的取消,要将订单中的运单状态更新
if s.isBillCandidate(order, bill) {
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, false)
}
}
}
} else {
savedOrderInfo.isSwitched2SelfDelivery = true
}
} else {
savedOrderInfo.isSwitched2SelfDelivery = true
globals.SugarLogger.Warnf("swtich2SelfDeliverWithRetry orderID:%s status is wrong, order details:%v", order.VendorOrderID, order)
}
}