From a34a8122603941d48e3529db35a9c948b9d18ead Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 7 May 2019 10:22:39 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=90=8E=E5=8F=B0=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=BF=90=E5=8D=95=E5=90=8E=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=86=8D=E9=87=8D=E6=96=B0=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 7 +------ business/jxcallback/scheduler/basesch/basesch.go | 3 +++ business/jxcallback/scheduler/defsch/defsch.go | 9 ++++----- business/model/const.go | 4 ++++ business/model/order.go | 1 + 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 7bad91b80..1c0b76a4a 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -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) { diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index 67d3965bd..466621e57 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -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) } diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index cd2d051d9..47068af71 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -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) + } } } } diff --git a/business/model/const.go b/business/model/const.go index 62916902d..530c3d818 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -268,6 +268,10 @@ const ( OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送) ) +const ( + WaybillDeliveryFlagMaskActiveCancel = 1 // 主动取消 +) + const ( OrderFlagMaskPrinted = 1 // 已经打印 diff --git a/business/model/order.go b/business/model/order.go index cc5fc7eeb..ba182961e 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -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