调整加订单配送小费逻辑,添加美团外卖平台支持

This commit is contained in:
gazebo
2019-12-26 16:19:04 +08:00
parent f13a8bbea2
commit 381d1b2f21
10 changed files with 108 additions and 88 deletions

View File

@@ -459,24 +459,35 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
if !isPending {
if order.Status > model.OrderStatusEndBegin {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
} else if model.IsOrderHaveWaybill(order) {
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
if model.IsWaybillPlatformOwn(bill) { // 是购物平台运单
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
if oldBill != nil {
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
} else {
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
} else {
needAddTip := order.WaybillTipMoney > 0 && !model.IsWaybillPlatformOwn(bill)
if model.IsOrderHaveWaybill(order) {
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
if model.IsWaybillPlatformOwn(bill) { // 是购物平台运单
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
if oldBill != nil {
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
} else {
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
}
}
s.updateOrderByBill(order, nil, false)
if time.Now().Sub(order.OrderCreatedAt) < 2*time.Minute { // 京东一些门店设置成了接单即拣货完成,这种情况下自动调用拣货完成
s.autoPickupGood(savedOrderInfo)
}
} else {
needAddTip = false
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
}
}
if needAddTip {
if handler := partner.GetWaybillTipUpdater(bill.WaybillVendorID); handler != nil {
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID); err2 == nil {
handler.UpdateWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, bill.VendorWaybillID, bill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), order.WaybillTipMoney)
}
}
s.updateOrderByBill(order, nil, false)
if time.Now().Sub(order.OrderCreatedAt) < 2*time.Minute { // 京东一些门店设置成了接单即拣货完成,这种情况下自动调用拣货完成
s.autoPickupGood(savedOrderInfo)
}
} else {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
}
}
flag2Clear := model.WaybillVendorID2Mask(bill.WaybillVendorID)
@@ -1212,25 +1223,20 @@ func (s *DefScheduler) watchOrderWaybills(savedOrderInfo *WatchOrderInfo) {
var remark string
tipFee := getWaybillTip(order)
vendorStatus := fmt.Sprintf("设置小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee))
if curTipFee, err := handler.GetWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorOrderID, order.VendorOrderID, ""); err == nil {
tipFee2Add := tipFee - curTipFee
vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add))
if false { //tipFee2Add > 0 {
err := handler.AddWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorOrderID, order.VendorOrderID, "", "", tipFee2Add)
if err == nil {
vendorStatus += "成功"
order.WaybillTipMoney += tipFee2Add
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
} else {
vendorStatus += "失败"
remark = fmt.Sprint(err)
}
tipFee2Add := tipFee - order.WaybillTipMoney
vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add))
if false { //tipFee2Add > 0 {
err := handler.UpdateWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, order.VendorOrderID, "", "", tipFee)
if err == nil {
vendorStatus += "成功"
order.WaybillTipMoney = tipFee
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
} else {
vendorStatus += "空操作"
vendorStatus += "失败"
remark = fmt.Sprint(err)
}
} else {
vendorStatus += "失败"
remark = fmt.Sprint(err)
vendorStatus += "空操作"
}
partner.CurOrderManager.OnOrderMsg(order, vendorStatus, remark)
}