添加淘鲜达

This commit is contained in:
邹宗楠
2023-06-28 10:04:08 +08:00
parent 64e4339aeb
commit c0a97b4fad
51 changed files with 2109 additions and 2007 deletions

View File

@@ -110,58 +110,68 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
default:
order.Status = model.WaybillStatusUnknown
}
err := dadaapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), utils.Int2Str(order.Status))
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
if order.OrderVendorID == model.VendorIDDD {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: order.Status,
OpCode: "",
}
switch msg.OrderStatus {
case dadaapi.OrderStatusWaitingForAccept: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case dadaapi.OrderStatusAccepted: // 待取货
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case dadaapi.OrderStatusDelivering: // 配送中
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case dadaapi.OrderStatusFinished: // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case dadaapi.OrderStatusCanceled: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case 8: // 指派单,不处理
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
case 9: // 配送异常返回值
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case 10: // 妥投异常之物品返回完成 - 不处理
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
case dadaapi.OrderStatusReturningInOrder: // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
case dadaapi.OrderStatusAddOrderFailed: // 创建达达运单失败 - 不处理
result.LogisticsStatus = model.WaybillStatusFailed
result.LogisticsContext = model.RiderGetOrderDeliverOther
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
switch order.OrderVendorID {
case model.VendorIDDD:
tiktokStatusPush(order, msg.OrderStatus)
case model.VendorIDMTWM, model.VendorIDTaoVegetable:
delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
}
return err
}
// 抖音订单状态回传
func tiktokStatusPush(order *model.Waybill, status int) {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: order.Status,
OpCode: "",
}
switch status {
case dadaapi.OrderStatusWaitingForAccept: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case dadaapi.OrderStatusAccepted: // 待取货
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case dadaapi.OrderStatusDelivering: // 配送中
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case dadaapi.OrderStatusFinished: // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case dadaapi.OrderStatusCanceled: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case 8: // 指派单,不处理
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
case 9: // 配送异常返回值
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case 10: // 妥投异常之物品返回完成 - 不处理
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
case dadaapi.OrderStatusReturningInOrder: // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
case dadaapi.OrderStatusAddOrderFailed: // 创建达达运单失败 - 不处理
result.LogisticsStatus = model.WaybillStatusFailed
result.LogisticsContext = model.RiderGetOrderDeliverOther
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
}
func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill, goods *model.GoodsOrder) {
retVal = &model.Waybill{
VendorWaybillID: msg.ClientID,
@@ -604,32 +614,32 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
// 直接返回的 原因是,一个订单在达达发布多次运单时,QueryOrderInfo获取到的运单始终是最后一个运单的配送价格!所以直接返回算了!
return localPrice, nil
// 平台状态兑换金额
var vendorPrice int64 = 0
// 未接单不扣款
if dadaOrder.AcceptTime == "" {
vendorPrice = 0
}
// 有了接单时间,订单变成了待取货
if dadaOrder.AcceptTime != "" && dadaOrder.FetchTime == "" {
nowTime := time.Now().Unix()
fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
timeDiffer := nowTime - fetchTime
if timeDiffer > 15*60 || timeDiffer < 60 {
vendorPrice = 0
}
vendorPrice = 200
}
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
// 达达存在多个订单的运单违约金额统计在一起的情况
if dadaOrder.FetchTime != "" {
vendorPrice = utils.Float64TwoInt64(dadaOrder.DeliveryFee * float64(100))
}
if localPrice > vendorPrice {
return localPrice, nil
}
return vendorPrice, nil
//// 平台状态兑换金额
//var vendorPrice int64 = 0
//// 未接单不扣款
//if dadaOrder.AcceptTime == "" {
// vendorPrice = 0
//}
//
//// 有了接单时间,订单变成了待取货
//if dadaOrder.AcceptTime != "" && dadaOrder.FetchTime == "" {
// nowTime := time.Now().Unix()
// fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
// timeDiffer := nowTime - fetchTime
// if timeDiffer > 15*60 || timeDiffer < 60 {
// vendorPrice = 0
// }
// vendorPrice = 200
//}
//
//// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
//// 达达存在多个订单的运单违约金额统计在一起的情况
//if dadaOrder.FetchTime != "" {
// vendorPrice = utils.Float64TwoInt64(dadaOrder.DeliveryFee * float64(100))
//}
//
//if localPrice > vendorPrice {
// return localPrice, nil
//}
//return vendorPrice, nil
}