From 5361c0cabbadd2bdde31421bc06b5be65a2e4d0d Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 26 Dec 2019 17:28:28 +0800 Subject: [PATCH] =?UTF-8?q?Waybill=E6=B7=BB=E5=8A=A0TipFee=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E8=AE=A2=E5=8D=95=E5=AE=8C=E6=88=90=E6=97=B6=E4=B9=9F?= =?UTF-8?q?=E4=BC=9A=E6=9B=B4=E6=96=B0=EF=BC=8CActualFee=E8=82=AF=E5=AE=9A?= =?UTF-8?q?=E4=BC=9A=E6=9C=89=E5=80=BC=EF=BC=8C=E5=BD=93=E6=88=90=E6=80=BB?= =?UTF-8?q?=E8=B4=B9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 15 +++++++++++++++ business/jxcallback/orderman/waybill.go | 3 +++ business/model/order.go | 1 + 3 files changed, 19 insertions(+) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index ecaed2d7f..b025a3ed4 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -173,6 +173,21 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } } + } else if orderStatus.Status == model.OrderStatusFinished { + if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil { + if order.WaybillVendorID >= 0 && order.VendorWaybillID != "" && order.WaybillVendorID != order.VendorID { + if waybill, err2 := c.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID); err2 == nil { + if handler := partner.GetWaybillTipUpdater(waybill.WaybillVendorID); handler != nil { + tipFee, err2 := handler.GetWaybillTip(jxcontext.AdminCtx, waybill.VendorOrgCode, "", order.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2) + if err2 == nil && waybill.TipFee != tipFee { + waybill.ActualFee += tipFee - waybill.TipFee + waybill.TipFee = tipFee + dao.UpdateEntity(db, waybill, "TipFee", "ActualFee") + } + } + } + } + } } if !isDuplicated { if order != nil { diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 23d0c3042..3aef00441 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -102,6 +102,9 @@ func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDupl func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) { var isDuplicated bool + if bill.ActualFee == 0 { + bill.ActualFee = bill.DesiredFee + bill.TipFee + } bill.CourierMobile = jxutils.FormalizeMobile(bill.CourierMobile) db := dao.GetDB() dao.Begin(db) diff --git a/business/model/order.go b/business/model/order.go index 264140f9d..9d92f058e 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -173,6 +173,7 @@ type Waybill struct { VendorStatus string `orm:"size(255)" json:"-"` ActualFee int64 `json:"actualFee"` // 实际要支付给快递公司的费用 DesiredFee int64 `json:"desiredFee"` // 运单总费用 + TipFee int64 `json:"tipFee"` // 运单小费,不含在上两项中 DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的 DeliveryFlag int8 `json:"deliveryFlag"` WaybillCreatedAt time.Time `orm:"type(datetime);index" json:"waybillCreatedAt"`