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"`