将美团和饿百取消订单申请索赔整合到interface中

This commit is contained in:
邹宗楠
2025-02-28 09:54:01 +08:00
parent a4573224a6
commit 054aac4e3c
13 changed files with 125 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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