- purchase platform waybill has highest priority.

- CancelWaybill in Swtich2SelfDeliver should update order waybill state.
This commit is contained in:
gazebo
2018-07-27 15:31:24 +08:00
parent 7ac054afed
commit f98e26fb0a

View File

@@ -162,9 +162,9 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
switch bill.Status {
case model.WaybillStatusAccepted:
if !isPending {
if order.WaybillVendorID == model.VendorIDUnknown {
s.cancelOtherWaybills(savedOrderInfo, bill)
if order.WaybillVendorID == model.VendorIDUnknown || bill.WaybillVendorID == order.VendorID { // 购买平台的运单,优先级最高
s.updateOrderByBill(order, bill, false)
s.cancelOtherWaybills(savedOrderInfo, bill)
} else if !(order.WaybillVendorID == bill.WaybillVendorID && order.VendorWaybillID == bill.VendorWaybillID) && bill.WaybillVendorID != order.VendorID {
// todo 当前逻辑加载PENDING的ORDER时正常状态也可能进这里
s.CancelWaybill(bill)
@@ -310,7 +310,13 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(order *model.GoodsOrder, bill
// 当前先不加RETRY逻辑
if err := s.Swtich2SelfDeliver(order); err != nil {
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry failed, cancel bill:%v, err:%v", bill, err)
s.CancelWaybill(bill)
if s.CancelWaybill(bill) == nil {
// 转自送失败的取消,要将订单中的运单状态更新
if order.WaybillVendorID == bill.WaybillVendorID && order.VendorWaybillID == bill.VendorWaybillID {
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, false)
}
}
}
}
@@ -505,10 +511,11 @@ func (s *DefScheduler) isOrderSupportAutoPickup(order *model.GoodsOrder) (retVal
db := orm.NewOrm()
utils.CallFuncLogError(func() error {
err := db.Read(storefeature, "Id")
if err == nil {
if err == nil || err == orm.ErrNoRows {
if storefeature.Autopickup == 0 {
retVal = false
}
err = nil
}
return err
}, "isOrderSupportAutoPickup")