From 7afa99620a2a8b652ee91dec063e6ee7fc1f729b Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 31 Jul 2018 20:29:55 +0800 Subject: [PATCH] - add poi_seq when creating mtps waybill. - cancel waybill in new msg when order status already end. --- business/controller/mtps/waybill.go | 3 ++- business/scheduler/defsch/defsch.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/business/controller/mtps/waybill.go b/business/controller/mtps/waybill.go index 358a26d89..be20b1a23 100644 --- a/business/controller/mtps/waybill.go +++ b/business/controller/mtps/waybill.go @@ -2,6 +2,7 @@ package mtps import ( "errors" + "fmt" "math" "time" @@ -194,7 +195,7 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) { item.GoodCount += goodItem.GoodCount } } - addParams := utils.Params2Map("note", order.BuyerComment, "goods_detail", string(utils.MustMarshal(goods))) + addParams := utils.Params2Map("note", order.BuyerComment, "goods_detail", string(utils.MustMarshal(goods)), "poi_seq", fmt.Sprintf("%s#%d", model.VendorChineseNames[order.VendorID], order.OrderSeq)) _, err = api.MtpsAPI.CreateOrderByShop(billParams, addParams) if err != nil { globals.SugarLogger.Debugf("CreateWaybill, orderID:%s, billParams:%v, addParams:%v", order.VendorOrderID, billParams, addParams) diff --git a/business/scheduler/defsch/defsch.go b/business/scheduler/defsch/defsch.go index 3c4c4b518..4d964aa33 100644 --- a/business/scheduler/defsch/defsch.go +++ b/business/scheduler/defsch/defsch.go @@ -222,7 +222,9 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo if bill.Status == model.WaybillStatusNew { s.addWaybill2Map(savedOrderInfo, bill) if !isPending { - if order.WaybillVendorID != model.VendorIDUnknown { + if order.Status > model.OrderStatusEndBegin { + s.CancelWaybill(bill) + } else if order.WaybillVendorID != model.VendorIDUnknown { globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill) if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID { s.CancelWaybill(bill)