Waybill添加TipFee,在订单完成时也会更新,ActualFee肯定会有值,当成总费用

This commit is contained in:
gazebo
2019-12-26 17:28:28 +08:00
parent 381d1b2f21
commit 5361c0cabb
3 changed files with 19 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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)

View File

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