- GoodsOrder.WaybillTipMoney的含义改为京西主动加的小费

- partner.IUpdateWaybillTip改为IAddWaybillTip
This commit is contained in:
gazebo
2019-08-01 18:09:23 +08:00
parent 45948e4b09
commit 1d0aa132f9
6 changed files with 42 additions and 15 deletions

View File

@@ -521,6 +521,7 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
"waybillFinishedAt",
"status2",
"skuInfo",
"waybillTipMoney",
},
}
excelBin = excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf})

View File

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

View File

@@ -5,5 +5,5 @@ import (
)
func TestStartOrEndOpStore(t *testing.T) {
StartOrEndOpStore(true, 0, 0)
StartOrEndOpStore(true, 0, 0, false, true)
}

View File

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

View File

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

View File

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