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

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

@@ -392,7 +392,7 @@ func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, reson
return err
}
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
order, err := api.DadaAPI.QueryOrderInfo2(vendorOrderID)
if err == nil {
tipFee = jxutils.StandardPrice2Int(order.Tips)
@@ -400,13 +400,9 @@ func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
return tipFee, err
}
func (c *DeliveryHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
curTip, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2)
if err == nil {
totalTip := curTip + tipFee2Add
if globals.EnableStoreWrite {
err = api.DadaAPI.AddTip(vendorOrderID, jxutils.IntPrice2Standard(totalTip), cityCode, "")
}
func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
if globals.EnableStoreWrite {
err = api.DadaAPI.AddTip(vendorOrderID, jxutils.IntPrice2Standard(tipFee), cityCode, "")
}
return err
}

View File

@@ -58,8 +58,8 @@ type IPurchasePlatformOrderHandler interface {
}
type IAddWaybillTip interface {
GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error)
GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error)
}
type IRidderPositionGetter interface {

View File

@@ -661,7 +661,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
return vendorOrderIDs, err
}
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
orderInfo, err := api.EbaiAPI.GetStoreOrderInfo(vendorOrderID)
if err == nil {
if orderBasic, _ := orderInfo["order_basic"].(map[string]interface{}); orderBasic != nil {
@@ -671,12 +671,9 @@ func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
return tipFee, err
}
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
tipFee, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2)
if err == nil {
if globals.EnableEbaiStoreWrite {
err = api.EbaiAPI.ModifyTip4OrderWaybill(vendorOrderID, "", jxutils.IntPrice2Standard(tipFee), 0)
}
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
if globals.EnableEbaiStoreWrite {
err = api.EbaiAPI.ModifyTip4OrderWaybill(vendorOrderID, "", jxutils.IntPrice2Standard(tipFee), 0)
}
return err
}

View File

@@ -484,21 +484,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
return vendorOrderIDs, err
}
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
a := getAPI(order.VendorOrgCode)
orderInfo, err := a.QuerySingleOrder2(order.VendorOrderID)
if err == nil {
tip2Add := int(tipFee) - orderInfo.Tips
if tip2Add != 0 {
if globals.EnableJdStoreWrite {
err = a.OrderAddTips(order.VendorOrderID, tip2Add, ctx.GetUserName())
}
}
}
return err
}
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
orderInfo, err := getAPI(vendorOrgCode).QuerySingleOrder2(vendorOrderID)
if err == nil {
tipFee = int64(orderInfo.Tips)
@@ -506,9 +492,14 @@ func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
return tipFee, err
}
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
if globals.EnableJdStoreWrite {
err = getAPI(vendorOrgCode).OrderAddTips(vendorOrderID, int(tipFee2Add), ctx.GetUserName())
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
curTipFee, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2)
if err == nil {
if tipFee2Add := tipFee - curTipFee; tipFee2Add > 0 {
if globals.EnableJdStoreWrite {
err = getAPI(vendorOrgCode).OrderAddTips(vendorOrderID, int(tipFee2Add), ctx.GetUserName())
}
}
}
return err
}

View File

@@ -755,3 +755,18 @@ func (p *PurchaseHandler) onNumberDowngrade(msg *mtwmapi.CallbackMsg) (response
tasksch.HandleTask(task, nil, true).Run()
return response
}
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
orderInfo, err := api.MtwmAPI.GetDistributeOrderDetail(vendorOrderID, vendorStoreID)
if err == nil {
tipFee = jxutils.StandardPrice2Int(orderInfo.TipAmount)
}
return tipFee, err
}
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
if globals.EnableMtwmStoreWrite {
err = api.MtwmAPI.OrderModityTips(vendorOrderID, vendorStoreID, jxutils.IntPrice2Standard(tipFee))
}
return err
}