diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 156531b8c..c68ed69c2 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -521,6 +521,7 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS "waybillFinishedAt", "status2", "skuInfo", + "waybillTipMoney", }, } excelBin = excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf}) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 03d71753d..759ddecd5 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1032,14 +1032,25 @@ func (s *DefScheduler) handleWaybillTip(savedOrderInfo *WatchOrderInfo) { if !utils.IsTimeZero(savedOrderInfo.pmWaybillCreatedAt) && !savedOrderInfo.isAddWaybillTipDisabled { if tipFee := s.getWaybillTip(savedOrderInfo); tipFee > 0 { - if handler, ok := partner.GetPurchasePlatformFromVendorID(order.VendorID).(partner.IUpdateWaybillTip); ok && handler != nil { - err := handler.UpdateWaybillTip(jxcontext.AdminCtx, order, tipFee) - vendorStatus := fmt.Sprintf("添加小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee)) - remark := "" - if err == nil { - vendorStatus += "成功" - order.WaybillTipMoney = tipFee - partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"}) + if handler, ok := partner.GetPurchasePlatformFromVendorID(order.VendorID).(partner.IAddWaybillTip); ok && handler != nil { + var remark string + vendorStatus := fmt.Sprintf("设置小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee)) + if curTipFee, err := handler.GetWaybillTip(jxcontext.AdminCtx, order); err == nil { + tipFee2Add := tipFee - curTipFee + vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add)) + if tipFee2Add > 0 { + err := handler.AddWaybillTip(jxcontext.AdminCtx, order, tipFee2Add) + if err == nil { + vendorStatus += "成功" + order.WaybillTipMoney += tipFee2Add + partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"}) + } else { + vendorStatus += "失败" + remark = fmt.Sprint(err) + } + } else { + vendorStatus += "空操作" + } } else { vendorStatus += "失败" remark = fmt.Sprint(err) diff --git a/business/jxstore/misc/misc2_test.go b/business/jxstore/misc/misc2_test.go index 3973944c7..c683e0bb7 100644 --- a/business/jxstore/misc/misc2_test.go +++ b/business/jxstore/misc/misc2_test.go @@ -5,5 +5,5 @@ import ( ) func TestStartOrEndOpStore(t *testing.T) { - StartOrEndOpStore(true, 0, 0) + StartOrEndOpStore(true, 0, 0, false, true) } diff --git a/business/model/order.go b/business/model/order.go index 34ea315e8..b3dbcbdb6 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -23,7 +23,7 @@ type GoodsOrder struct { TotalShopMoney int64 `json:"totalShopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除) PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+ DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) - WaybillTipMoney int64 `json:"waybillTipMoney"` // 平台配送小费 + WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) Weight int `json:"weight"` // 单位为克 ConsigneeName string `orm:"size(32)" json:"consigneeName"` diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index a7bb1f987..dae76ee03 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -49,7 +49,7 @@ type IPurchasePlatformOrderHandler interface { ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error) } -type IUpdateWaybillTip interface { - // 添加快递小费,这个不是递增的,最后一次操作会覆盖之前的设置,但只能增加,不能减少,且tipFee只能为100的倍数 - UpdateWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) +type IAddWaybillTip interface { + GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) + AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) } diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index bc2a31016..28919bf05 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -52,7 +52,7 @@ func (c *PurchaseHandler) updateOrderFinancialInfo(orderID string) (err error) { if err == nil { if orderSettlement != nil { updateOrderBySettleMent(order, orderSettlement) - err = partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney", "TotalShopMoney", "PmSubsidyMoney"}) + err = partner.CurOrderManager.UpdateOrderFields(order, []string{ /*"WaybillTipMoney", */ "TotalShopMoney", "PmSubsidyMoney"}) } } return err @@ -95,7 +95,7 @@ func (c *PurchaseHandler) onOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi func updateOrderBySettleMent(order *model.GoodsOrder, orderSettlement *jdapi.OrderSettlementInfo) { if orderSettlement != nil { - order.WaybillTipMoney = orderSettlement.VenderPaidTips + // order.WaybillTipMoney = orderSettlement.VenderPaidTips order.TotalShopMoney = orderSettlement.SettlementAmount order.PmSubsidyMoney = orderSettlement.PlatOrderGoodsDiscountMoney + orderSettlement.PlatSkuGoodsDiscountMoney } @@ -456,3 +456,18 @@ func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model. } return err } + +func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) { + orderInfo, err := api.JdAPI.QuerySingleOrder2(order.VendorOrderID) + if err == nil { + tipFee = int64(orderInfo.Tips) + } + return tipFee, err +} + +func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) { + if globals.EnableJdStoreWrite { + err = api.JdAPI.OrderAddTips(order.VendorOrderID, int(tipFee2Add), ctx.GetUserName()) + } + return err +}