From d81bad8f1cfb97ff2e3de487fcf8bae5f2b49e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 5 Jun 2023 17:25:40 +0800 Subject: [PATCH] 1 --- business/partner/delivery/fn/store.go | 2 +- business/partner/delivery/fn/waybill.go | 39 +++++++++++++++++++---- business/partner/delivery/mtps/waybill.go | 10 ++++++ business/partner/partner_order.go | 2 ++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/business/partner/delivery/fn/store.go b/business/partner/delivery/fn/store.go index 52f41bb10..36b7d70e8 100644 --- a/business/partner/delivery/fn/store.go +++ b/business/partner/delivery/fn/store.go @@ -148,7 +148,7 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S // 蜂鸟门店状态改变 func OnStoreStatus(msg *fnpsapi.ChainstoreStatusNotify) (retVal *fnpsapi.CallbackResponse) { - return curDeliveryHandler.OnStoreStatus(msg) + return CurDeliveryHandler.OnStoreStatus(msg) } // 修改本地门店审核状态 diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index ad0727bb7..03497baee 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -5,6 +5,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/mtpsapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "strings" "time" @@ -35,7 +36,7 @@ const ( ) var ( - curDeliveryHandler *DeliveryHandler + CurDeliveryHandler *DeliveryHandler complaintReson2FnResonMap = map[int]int{ model.ComplaintReasons1: ComplaintReasonsFn160, model.ComplaintReasons2: ComplaintReasonsFn130, @@ -53,10 +54,8 @@ type DeliveryHandler struct { } func init() { - if api.FnAPI != nil { - curDeliveryHandler = new(DeliveryHandler) - partner.RegisterDeliveryPlatform(curDeliveryHandler, true) - } + CurDeliveryHandler = new(DeliveryHandler) + partner.RegisterDeliveryPlatform(CurDeliveryHandler, true) } func (c *DeliveryHandler) GetVendorID() int { @@ -323,7 +322,7 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta // 异常报备 func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) { - return curDeliveryHandler.OnWaybillExcept(msg) + return CurDeliveryHandler.OnWaybillExcept(msg) } func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) { @@ -487,3 +486,31 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } return vendorPrice, nil } + +func (c *DeliveryHandler) GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error) { + order, err := api.FnAPI.GetKnightInfo(&fnpsapi.GetOrderDetailReq{ + PartnerOrderCode: vendorOrderID, + }) + if err == nil { + lng = utils.Str2Float64WithDefault(order.CarrierDriverLongitude, 0) + lat = utils.Str2Float64WithDefault(order.CarrierDriverLatitude, 0) + } + return lng, lat, err +} + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + return api.FnAPI.AddTip(&fnpsapi.AddTipRes{ + OrderId: "", + PartnerOrderCode: vendorOrderID, + AddTipAmountCent: tipFee, + ThirdIndexId: time.Now().Unix(), + }) +} + +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + order, err := api.FnAPI.QueryOrder(vendorOrderID) + if err == nil { + tipFee = order.OrderTipAmountCent + } + return tipFee, err +} diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index bdd90496b..071f877a8 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -548,3 +548,13 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } return 0, err } + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + // 无法获取已经添加的小费金额 + return fmt.Errorf("美团暂不支持添加小费") + //return api.MtpsAPI.AddTip(vendorOrderID, vendorWaybillID, tipFee) +} + +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + return tipFee, err +} diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index 8eaf6bc3e..552130339 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -95,7 +95,9 @@ type IPurchasePlatformOrderHandler interface { } type IAddWaybillTip interface { + // GetWaybillTip 获取添加小费 GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) + // UpdateWaybillTip 添加小费 UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) }