Waybill添加TipFee,在订单完成时也会更新,ActualFee肯定会有值,当成总费用
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user