修改配送费收取规则
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
@@ -546,14 +547,48 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
// 待接单,待取货(小于一分钟,大于十五分钟)不扣钱
|
||||
// 待取货1-15分钟内取消扣两元
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
orderStatus, err := orderman.FixedOrderManager.GetWayBillStatusList(orderId, deliverId, model.VendorIDDada)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dadaOrder, err := api.DadaAPI.QueryOrderInfo(orderId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 本地状态兑换金额
|
||||
var localPrice int64 = 0
|
||||
for i := len(orderStatus) - 1; i >= 0; i-- {
|
||||
if orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusCanceled) {
|
||||
continue
|
||||
}
|
||||
if orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusFinished) || orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusDelivering) || orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusReturningInOrder) {
|
||||
localPrice = utils.Float64TwoInt64(dadaOrder.DeliveryFee * float64(100))
|
||||
break
|
||||
}
|
||||
if orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusAccepted) {
|
||||
nowTime := time.Now().Unix()
|
||||
fetchTime := orderStatus[i].StatusTime.Unix()
|
||||
timeDiffer := nowTime - fetchTime
|
||||
if timeDiffer > 15*60 || timeDiffer < 60 {
|
||||
localPrice = 0
|
||||
} else {
|
||||
localPrice = 200
|
||||
}
|
||||
break
|
||||
}
|
||||
if orderStatus[i].VendorStatus == utils.Int2Str(dadaapi.OrderStatusWaitingForAccept) {
|
||||
localPrice = 0
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 平台状态兑换金额
|
||||
var vendorPrice int64 = 0
|
||||
// 未接单不扣款
|
||||
if dadaOrder.AcceptTime == "" {
|
||||
return 0, nil
|
||||
vendorPrice = 0
|
||||
}
|
||||
|
||||
// 有了接单时间,订单变成了待取货
|
||||
@@ -562,20 +597,19 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
|
||||
fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
|
||||
timeDiffer := nowTime - fetchTime
|
||||
if timeDiffer > 15*60 || timeDiffer < 60 {
|
||||
return 0, nil
|
||||
vendorPrice = 0
|
||||
}
|
||||
return 200, nil
|
||||
vendorPrice = 200
|
||||
}
|
||||
|
||||
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
|
||||
// 达达存在多个订单的运单违约金额统计在一起的情况
|
||||
if dadaOrder.FetchTime != "" {
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDDada)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bill.DesiredFee, nil
|
||||
vendorPrice = utils.Float64TwoInt64(dadaOrder.DeliveryFee * float64(100))
|
||||
}
|
||||
|
||||
return 0, err
|
||||
if localPrice > vendorPrice {
|
||||
return localPrice, nil
|
||||
}
|
||||
return vendorPrice, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user