From 054aac4e3c8badeeb6fec3ca6ae17e547f69d85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 28 Feb 2025 09:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E7=BE=8E=E5=9B=A2=E5=92=8C=E9=A5=BF?= =?UTF-8?q?=E7=99=BE=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=B4=A2=E8=B5=94=E6=95=B4=E5=90=88=E5=88=B0interface=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 19 ++++------ business/partner/delivery/fn/waybill.go | 30 ++++++++++++++++ business/partner/partner_order.go | 3 ++ business/partner/purchase/ebai/order.go | 35 +++++++++++++++++-- business/partner/purchase/elm/order.go | 5 +++ business/partner/purchase/jd/order.go | 5 +++ business/partner/purchase/jdshop/order.go | 5 +++ business/partner/purchase/jx/order.go | 5 +++ business/partner/purchase/mtwm/order.go | 12 +++++++ .../partner/purchase/tao_vegetable/order.go | 5 +++ .../partner/purchase/tiktok_store/order.go | 5 +++ business/partner/purchase/weimob/wsc/order.go | 5 +++ business/partner/purchase/yb/order.go | 5 +++ 13 files changed, 125 insertions(+), 14 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 84715f7c1..3e1d5f183 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -4,13 +4,10 @@ import ( "crypto/md5" "errors" "fmt" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "math" - "strconv" "strings" "time" @@ -281,18 +278,16 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m order2.OrderFinishedAt = time.Now() dao.UpdateEntity(db, order2, "OrderFinishedAt") } - if orderStatus.Status == model.OrderStatusCanceled && orderStatus.VendorID == model.VendorIDMTWM { - num, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", utils.Int64ToFloat64(order2.TotalShopMoney)/float64(100)), 64) - applyErr := mtwm.GetAPI(order2.VendorOrgCode, order2.StoreID, order2.VendorStoreID).ApplyCompensation(&mtwmapi.ApplyCompensationRes{ - OrderId: utils.Str2Int64(order2.VendorOrderID), - Reason: "商户申请", - ApplyStatus: mtwmapi.ApplyCompensationStatusOne, - Amount: num, - }) + + if handler := partner.GetPurchaseOrderHandlerFromVendorID(orderStatus.VendorID); handler != nil && (orderStatus.VendorID == model.VendorIDMTWM || orderStatus.VendorID == model.VendorIDEBAI) { + compensation, applyErr := handler.ApplyCompensationOrder(order2) if applyErr != nil { partner.CurOrderManager.OnOrderMsg(order2, utils.Int2Str(order2.Status), fmt.Sprintf("取消订单申请赔付失败:%s", applyErr.Error())) } else { - partner.CurOrderManager.OnOrderMsg(order2, utils.Int2Str(order2.Status), fmt.Sprintf("取消订单申请赔付:%s", "成功")) + if compensation == "" { + compensation = "成功" + } + partner.CurOrderManager.OnOrderMsg(order2, utils.Int2Str(order2.Status), fmt.Sprintf("取消订单申请赔付:%s", compensation)) } if order2.Status != model.OrderStatusCanceled { diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index 31eca50ad..6a6c128ac 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -544,6 +544,36 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } } } + + // 已经分配骑手,且超过十五分钟,不扣款 + var cancelTime int64 = 0 + var assignedTime int64 = 0 + for i := 0; i < len(order.EventLogDetails); i++ { + switch order.EventLogDetails[i].OrderStatus { + case fnpsapi.OrderStatusAcceptCacle, fnpsapi.OrderStatusException: // 取消和异常状态,跳过查看上一状态 + cancelTime = order.EventLogDetails[i].OccurTime + case fnpsapi.OrderStatusAssigned: + assignedTime = order.EventLogDetails[i].OccurTime + } + } + // 还没分配骑手 + nowTime := time.Now().UnixNano() / 1e6 + if assignedTime == 0 { + return 0, nil + } else if cancelTime == 0 && assignedTime != 0 { + if nowTime-assignedTime > fnpsapi.WayBillPressureOrderTime || nowTime-assignedTime <= fnpsapi.WayBillPressureOrderTime2 { + return 0, nil + } else { + return 200, nil + } + } else if assignedTime != 0 && cancelTime != 0 { + if cancelTime-assignedTime > fnpsapi.WayBillPressureOrderTime || cancelTime-assignedTime > fnpsapi.WayBillPressureOrderTime2 { + return 0, nil + } else { + return 200, nil + } + } + if localPrice > vendorPrice { return localPrice, nil } diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index 17e335020..db55bd709 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -91,6 +91,9 @@ type IPurchasePlatformOrderHandler interface { GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) // GetPlatformLogisticsFee 获取美团自配送订单的配送费 GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) + + // 美团和饿百的订单索赔 + ApplyCompensationOrder(order *model.GoodsOrder) (string, error) } type IAddWaybillTip interface { diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 0942846d0..7e012bf95 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -83,8 +83,6 @@ func (p *PurchaseHandler) getStatusFromVendorStatus(vendorStatus string) int { func (p *PurchaseHandler) GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error) { order, _, err = p.getOrder(vendorOrderID) - globals.SugarLogger.Debugf("---------order GetOrder := %s", utils.Format4Output(order, false)) - globals.SugarLogger.Debugf("---------order err := %v", err) return order, err } @@ -1012,3 +1010,36 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + afsOrderList, err := dao.GetAfsOrders(dao.GetDB(), order.VendorID, order.VendorOrderID, "") + if err != nil { + return "", err + } + refundList := make([]*ebaiapi.ApplyCompensationList, 0, 0) + for _, v := range afsOrderList { + if v.AfsOrderID != v.VendorOrderID { + refundList = append(refundList, &ebaiapi.ApplyCompensationList{ + RefundId: v.AfsOrderID, + CompensationReason: ebaiapi.CompensationCodeE1, + Description: "分配骑手缓慢/骑手到店缓慢", + }) + } + } + + if len(refundList) > 0 { + result, err := api.EbaiAPI.ApplyCompensation(order.VendorOrderID, refundList) + if err != nil { + return "", err + } + + compensationStation := make([]string, 0, 0) + for _, r := range result { + compensationStation = append(compensationStation, fmt.Sprintf("售后ID:%s,索赔状态:%s,失败:%s", r.RefundId, r.CompensationStatusDesc, r.CompensationFailDesc)) + } + + return strings.Join(compensationStation, ","), nil + } + return "", err +} diff --git a/business/partner/purchase/elm/order.go b/business/partner/purchase/elm/order.go index 1a7416072..f7853a1d6 100644 --- a/business/partner/purchase/elm/order.go +++ b/business/partner/purchase/elm/order.go @@ -349,3 +349,8 @@ func (c *PurchaseHandler) OrderLogisticsStatus(orderId string) (*utils.RiderInfo func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "", nil +} diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index 093db77a1..237d0aaf7 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -697,3 +697,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(goods *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "",nil +} diff --git a/business/partner/purchase/jdshop/order.go b/business/partner/purchase/jdshop/order.go index 95f0904af..80882b6ba 100644 --- a/business/partner/purchase/jdshop/order.go +++ b/business/partner/purchase/jdshop/order.go @@ -338,3 +338,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "", nil +} diff --git a/business/partner/purchase/jx/order.go b/business/partner/purchase/jx/order.go index b4ade77ed..bc5d58a24 100644 --- a/business/partner/purchase/jx/order.go +++ b/business/partner/purchase/jx/order.go @@ -166,3 +166,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "",nil +} diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 952370370..38bfcb4ef 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg" "net/url" "regexp" + "strconv" "strings" "time" @@ -1030,3 +1031,14 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6 return utils.Float64TwoInt64(fee * 100), nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + num, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", utils.Int64ToFloat64(order.TotalShopMoney)/float64(100)), 64) + return "", getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").ApplyCompensation(&mtwmapi.ApplyCompensationRes{ + OrderId: utils.Str2Int64(order.VendorOrderID), + Reason: "商户申请", + ApplyStatus: mtwmapi.ApplyCompensationStatusOne, + Amount: num, + }) +} diff --git a/business/partner/purchase/tao_vegetable/order.go b/business/partner/purchase/tao_vegetable/order.go index 6c6c07cce..46de76fff 100644 --- a/business/partner/purchase/tao_vegetable/order.go +++ b/business/partner/purchase/tao_vegetable/order.go @@ -986,3 +986,8 @@ func GetOrderTotalShopMoney(appOrgCode string, vendorStoreID string, start, end func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "",nil +} diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index e1c7100b4..325a293bf 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -1111,3 +1111,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "", nil +} diff --git a/business/partner/purchase/weimob/wsc/order.go b/business/partner/purchase/weimob/wsc/order.go index 06404b3ef..08e70c592 100644 --- a/business/partner/purchase/weimob/wsc/order.go +++ b/business/partner/purchase/weimob/wsc/order.go @@ -317,3 +317,8 @@ func (c *PurchaseHandler) OrderLogisticsStatus(orderId string) (*utils.RiderInfo func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "", nil +} diff --git a/business/partner/purchase/yb/order.go b/business/partner/purchase/yb/order.go index 0c7b427b4..f0fc554f4 100644 --- a/business/partner/purchase/yb/order.go +++ b/business/partner/purchase/yb/order.go @@ -117,3 +117,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64 func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error) { return 0, nil } + +// ApplyCompensationOrder 订单索赔 +func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) { + return "", nil +}