修改配送费收取规则
This commit is contained in:
@@ -712,24 +712,6 @@ func (c *OrderManager) GetLogisticsOrderStatusList(orderId, LogisticsId string,
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWayBillStatusList 根据订单号和物流号查询运单的变化状态
|
|
||||||
func (c *OrderManager) GetWayBillStatusList(orderId, LogisticsId string, vendorId int) ([]*model.OrderStatus, error) {
|
|
||||||
sql := `SELECT *
|
|
||||||
FROM order_status t1
|
|
||||||
WHERE t1.vendor_order_id = ? AND t1.ref_vendor_order_id = ? AND t1.vendor_id = ?`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
LogisticsId,
|
|
||||||
orderId,
|
|
||||||
vendorId,
|
|
||||||
}
|
|
||||||
sql += ` ORDER BY status_time ASC `
|
|
||||||
var result []*model.OrderStatus
|
|
||||||
if err := dao.GetRows(dao.GetDB(), &result, sql, sqlParams...); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOrderStatusList2 查询订单流程 refVendorOrderID 订单Id
|
// GetOrderStatusList2 查询订单流程 refVendorOrderID 订单Id
|
||||||
func GetOrderStatusList2(refVendorOrderID string, wayBillId string, orderType int, vendorID int) (statusList []*model.OrderStatus, err error) {
|
func GetOrderStatusList2(refVendorOrderID string, wayBillId string, orderType int, vendorID int) (statusList []*model.OrderStatus, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
@@ -1718,3 +1700,21 @@ func GetOrderUserBuyFirst(ctx *jxcontext.Context, vendorOrderID string) (isFirst
|
|||||||
}
|
}
|
||||||
return isFirst, err
|
return isFirst, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetWayBillStatusList 根据订单号和物流号查询运单的变化状态
|
||||||
|
func (c *OrderManager) GetWayBillStatusList(orderId, LogisticsId string, vendorId int) ([]*model.OrderStatus, error) {
|
||||||
|
sql := `SELECT *
|
||||||
|
FROM order_status t1
|
||||||
|
WHERE t1.vendor_order_id = ? AND t1.ref_vendor_order_id = ? AND t1.vendor_id = ?`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
LogisticsId,
|
||||||
|
orderId,
|
||||||
|
vendorId,
|
||||||
|
}
|
||||||
|
sql += ` ORDER BY status_time ASC `
|
||||||
|
var result []*model.OrderStatus
|
||||||
|
if err := dao.GetRows(dao.GetDB(), &result, sql, sqlParams...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||||
@@ -546,14 +547,48 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
|||||||
// 待接单,待取货(小于一分钟,大于十五分钟)不扣钱
|
// 待接单,待取货(小于一分钟,大于十五分钟)不扣钱
|
||||||
// 待取货1-15分钟内取消扣两元
|
// 待取货1-15分钟内取消扣两元
|
||||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
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)
|
dadaOrder, err := api.DadaAPI.QueryOrderInfo(orderId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
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 == "" {
|
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()
|
fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
|
||||||
timeDiffer := nowTime - fetchTime
|
timeDiffer := nowTime - fetchTime
|
||||||
if timeDiffer > 15*60 || timeDiffer < 60 {
|
if timeDiffer > 15*60 || timeDiffer < 60 {
|
||||||
return 0, nil
|
vendorPrice = 0
|
||||||
}
|
}
|
||||||
return 200, nil
|
vendorPrice = 200
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
|
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
|
||||||
// 达达存在多个订单的运单违约金额统计在一起的情况
|
// 达达存在多个订单的运单违约金额统计在一起的情况
|
||||||
if dadaOrder.FetchTime != "" {
|
if dadaOrder.FetchTime != "" {
|
||||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDDada)
|
vendorPrice = utils.Float64TwoInt64(dadaOrder.DeliveryFee * float64(100))
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return bill.DesiredFee, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, err
|
if localPrice > vendorPrice {
|
||||||
|
return localPrice, nil
|
||||||
|
}
|
||||||
|
return vendorPrice, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -415,16 +416,49 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 本地状态兑换金额
|
||||||
|
var localPrice int64 = 0
|
||||||
|
orderStatus, err := orderman.FixedOrderManager.GetWayBillStatusList(orderId, deliverId, model.VendorIDFengNiao)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
for i := len(orderStatus) - 1; i >= 0; i-- {
|
||||||
|
if orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusAcceptCacle) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusArrived) || orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusDelivering) || orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusDelivered) {
|
||||||
|
localPrice = order.OrderTotalAmountCent
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusAssigned) {
|
||||||
|
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(fnpsapi.OrderStatusAcceptCreate) || orderStatus[i].VendorStatus == utils.Int2Str(fnpsapi.OrderStatusAccept) {
|
||||||
|
localPrice = 0
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 已经分配骑手,且超过十五分钟,不扣款
|
// 已经分配骑手,且超过十五分钟,不扣款
|
||||||
|
var vendorPrice int64 = 0
|
||||||
if len(order.EventLogDetails) != model.NO {
|
if len(order.EventLogDetails) != model.NO {
|
||||||
for i := len(order.EventLogDetails) - 1; i >= 0; i-- {
|
for i := len(order.EventLogDetails) - 1; i >= 0; i-- {
|
||||||
switch order.EventLogDetails[i].OrderStatus {
|
switch order.EventLogDetails[i].OrderStatus {
|
||||||
case fnpsapi.OrderStatusDelivered, fnpsapi.OrderStatusArrived, fnpsapi.OrderStatusDelivering: // 送达,到店,配送中 取消订单全额扣款
|
case fnpsapi.OrderStatusDelivered, fnpsapi.OrderStatusArrived, fnpsapi.OrderStatusDelivering: // 送达,到店,配送中 取消订单全额扣款
|
||||||
return order.OrderTotalAmountCent, nil
|
vendorPrice = order.OrderTotalAmountCent
|
||||||
|
break
|
||||||
case fnpsapi.OrderStatusAcceptCacle, fnpsapi.OrderStatusException: // 取消和异常状态,跳过查看上一状态
|
case fnpsapi.OrderStatusAcceptCacle, fnpsapi.OrderStatusException: // 取消和异常状态,跳过查看上一状态
|
||||||
continue
|
continue
|
||||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 生成运单和系统接单取消不扣除费用
|
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 生成运单和系统接单取消不扣除费用
|
||||||
return 0, nil
|
vendorPrice = 0
|
||||||
case fnpsapi.OrderStatusAssigned:
|
case fnpsapi.OrderStatusAssigned:
|
||||||
if time.Now().UnixNano()/1e6-order.EventLogDetails[i].OccurTime > fnpsapi.WayBillPressureOrderTime {
|
if time.Now().UnixNano()/1e6-order.EventLogDetails[i].OccurTime > fnpsapi.WayBillPressureOrderTime {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
@@ -433,8 +467,9 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if localPrice > vendorPrice {
|
||||||
return 0, err
|
return localPrice, nil
|
||||||
|
}
|
||||||
|
return vendorPrice, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,29 +493,33 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDMTPS)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
// 已经分配骑手,且超过十五分钟,不扣款
|
// 已经分配骑手,且超过十五分钟,不扣款
|
||||||
if len(statusList) != model.NO {
|
for i := len(statusList) - 1; i >= 0; i-- {
|
||||||
for i := len(statusList) - 1; i >= 0; i-- {
|
// 取消不管
|
||||||
switch statusList[i].VendorStatus {
|
if statusList[i].VendorStatus == utils.Int2Str(mtpsapi.OrderStatusCanceled) {
|
||||||
case utils.Int2Str(mtpsapi.OrderStatusWaitingForSchedule): // 待调度
|
continue
|
||||||
return 0, nil
|
}
|
||||||
case utils.Int2Str(mtpsapi.OrderStatusCanceled): // 取消不管
|
// 送达
|
||||||
continue
|
if statusList[i].VendorStatus == utils.Int2Str(mtpsapi.OrderStatusDeliverred) {
|
||||||
case utils.Int2Str(mtpsapi.OrderStatusDeliverred): // 送达
|
return bill.DesiredFee, nil
|
||||||
continue
|
}
|
||||||
case utils.Int2Str(mtpsapi.OrderStatusAccepted): // 接单
|
// 到店
|
||||||
// 接单取消扣凉快
|
if statusList[i].VendorStatus == utils.Int2Str(mtpsapi.OrderStatusPickedUp) {
|
||||||
return 200, nil
|
return bill.DesiredFee, nil
|
||||||
case utils.Int2Str(mtpsapi.OrderStatusPickedUp): // 取货
|
}
|
||||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDMTPS)
|
// 接单
|
||||||
if err != nil {
|
if statusList[i].VendorStatus == utils.Int2Str(mtpsapi.OrderStatusAccepted) {
|
||||||
return 0, err
|
return 200, nil
|
||||||
}
|
}
|
||||||
return bill.DesiredFee, nil
|
// 待调度
|
||||||
|
if statusList[i].VendorStatus == utils.Int2Str(mtpsapi.OrderStatusWaitingForSchedule) {
|
||||||
}
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user