- 后台主动取消运单后不会再重新创建

This commit is contained in:
gazebo
2019-05-07 10:22:39 +08:00
parent 295246ff40
commit a34a812260
5 changed files with 13 additions and 11 deletions

View File

@@ -490,12 +490,7 @@ func (c *OrderManager) loadOrderFinancial(vendorOrderID, vendorOrderID2 string,
}
func (c *OrderManager) UpdateOrderStatusAndFlag(order *model.GoodsOrder) (err error) {
db := orm.NewOrm()
utils.CallFuncLogError(func() error {
_, err = db.Update(order, "Status", "DeliveryFlag")
return err
}, "UpdateOrderStatusAndFlag orderID:%s failed with error:%v", order.VendorOrderID, err)
return err
return c.UpdateOrderFields(order, []string{"Status", "DeliveryFlag"})
}
func (c *OrderManager) UpdateOrderFields(order *model.GoodsOrder, fieldList []string) (err error) {

View File

@@ -5,6 +5,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
)
@@ -170,6 +171,8 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c
return handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason)
}, "CancelWaybill bill:%v", bill); err == nil {
bill.Status = model.WaybillStatusCanceled
bill.DeliveryFlag |= model.WaybillDeliveryFlagMaskActiveCancel
_, err = dao.UpdateEntity(nil, bill, "Status", "DeliveryFlag")
}
globals.SugarLogger.Debugf("CancelWaybill bill:%v canceled by myself", bill)
}

View File

@@ -390,9 +390,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
if !isPending {
bill.WaybillVendorID = model.VendorIDUnknown
s.updateOrderByBill(order, bill, false)
// 取消抢单应该不需要发3方运单
// s.createWaybillOn3rdProviders(savedOrderInfo, bill)
}
} else if s.IsOrderHasWaybill(order) {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
@@ -420,8 +417,10 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
// 现在发现饿百取消订单后不会再创建运单了,所以饿百运单取消也允许直接创建三方运单
// 之前的条件是order.Status < model.OrderStatusDelivering但像订单902322817000122确实有在配送中取消状态改成非订单结束状态都可以
// OrderStatusFinishedPickup状态的订单依赖于TIMER重新建运单
if order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin && (bill.WaybillVendorID != order.VendorID || order.VendorID == model.VendorIDEBAI) {
s.createWaybillOn3rdProviders(savedOrderInfo, nil)
if bill.DeliveryFlag&model.WaybillDeliveryFlagMaskActiveCancel == 0 {
if order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin && (bill.WaybillVendorID != order.VendorID || order.VendorID == model.VendorIDEBAI) {
s.createWaybillOn3rdProviders(savedOrderInfo, nil)
}
}
}
}

View File

@@ -268,6 +268,10 @@ const (
OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送)
)
const (
WaybillDeliveryFlagMaskActiveCancel = 1 // 主动取消
)
const (
OrderFlagMaskPrinted = 1 // 已经打印

View File

@@ -124,6 +124,7 @@ type Waybill struct {
ActualFee int64 `json:"actualFee"` // 实际要支付给快递公司的费用
DesiredFee int64 `json:"desiredFee"` // 运单总费用
DuplicatedCount int `json:"-"` // 重复新订单消息数这个一般不是由于消息重发造成的消息重发由OrderStatus过滤一般是业务逻辑造成的
DeliveryFlag int8 `json:"deliveryFlag"`
WaybillCreatedAt time.Time `orm:"type(datetime);index" json:"waybillCreatedAt"`
WaybillFinishedAt time.Time `orm:"type(datetime)" json:"waybillFinishedAt"`
StatusTime time.Time `orm:"type(datetime)" json:"-"` // last status time