添加淘鲜达

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
}

View File

@@ -69,7 +69,6 @@ func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int,
}
parameter.PartnerOrderCode = bill.VendorOrderID
if err = api.FnAPI.CancelOrder(parameter); err != nil {
globals.SugarLogger.Debugf("============err := %v ", err)
if strings.Contains(err.Error(), "运单暂未生成") {
err = nil
}
@@ -280,49 +279,55 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
return fnpsapi.Err2CallbackResponse(err, "")
}
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 orderStatus {
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case fnpsapi.OrderStatusAssigned: //20分配骑手 待取货
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case fnpsapi.OrderStatusDelivering: // 2 配送中 // 配送中
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case fnpsapi.OrderStatusDelivered: // 3 已经送达 // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case fnpsapi.OrderStatusAcceptCacle: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case fnpsapi.OrderStatusException: // 5 异常: // 配送异常返回值
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case fnpsapi.OrderStatusArrived: // 80 到店 // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
switch order.OrderVendorID {
case model.VendorIDDD:
tiktokStatusPush(order, orderStatus)
case model.VendorIDMTWM, model.VendorIDTaoVegetable:
delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
}
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
return fnpsapi.Err2CallbackResponse(nil, "")
}
// 抖音订单状态回传
func tiktokStatusPush(order *model.Waybill, orderStatus int64) {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: order.Status,
OpCode: "",
}
switch orderStatus {
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case fnpsapi.OrderStatusAssigned: //20分配骑手 待取货
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case fnpsapi.OrderStatusDelivering: // 2 配送中 // 配送中
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case fnpsapi.OrderStatusDelivered: // 3 已经送达 // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case fnpsapi.OrderStatusAcceptCacle: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case fnpsapi.OrderStatusException: // 5 异常: // 配送异常返回值
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case fnpsapi.OrderStatusArrived: // 80 到店 // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
}
// 异常报备
func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
return CurDeliveryHandler.OnWaybillExcept(msg)

View File

@@ -96,19 +96,13 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
}
order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.OrderVendorID)
//查不到订单可能就是果园的订单
if order2 == nil {
c.pushToGy(msg)
return mtpsapi.SuccessResponse
}
store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode)
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule:
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
if err != nil {
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
globals.SugarLogger.Debugf("获取运单信息错误,可能是果园运单:%s,%v", utils.Format4Output(msg, false), err)
break
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
@@ -117,7 +111,8 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
case mtpsapi.OrderStatusAccepted: // 已接单
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
if err != nil {
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
globals.SugarLogger.Debugf("获取运单信息错误,可能是果园运单:%s,%v", utils.Format4Output(msg, false), err)
break
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
@@ -134,17 +129,21 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
return mtpsapi.SuccessResponse
}
//if msg.Status == mtpsapi.OrderStatusPickedUp {
// order.Status = model.WaybillStatusCourierArrived
// mtpsapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
// delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
// msg.Status = mtpsapi.OrderStatusPickedUp
//}
order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.OrderVendorID)
//查不到订单可能就是果园的订单
if order2 == nil && beego.BConfig.RunMode != "jxgy" {
c.pushToGy(msg)
return mtpsapi.SuccessResponse
}
// 加入调度器
err := mtpsapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
if order.OrderVendorID == model.VendorIDDD {
switch order.OrderVendorID {
case model.VendorIDDD:
pushMTPSToTiktok(msg.Status, order)
case model.VendorIDMTWM, model.VendorIDTaoVegetable:
delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
}
return err

View File

@@ -3,7 +3,9 @@ package delivery
import (
"crypto/rand"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/globals/api"
"math/big"
"time"
@@ -19,6 +21,7 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
utilsTao "git.rosy.net.cn/jx-callback/business/partner/purchase/tao_vegetable"
"git.rosy.net.cn/jx-callback/globals"
)
@@ -88,9 +91,6 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
//3.当同一个订单已经上传了一次配送信息,如再次同步会更新配送信息,以最新的一次为准。
//4.如订单已完成、已取消等状态发货将失败。
for _, v := range orders {
//if v.Status >= model.OrderStatusFinished || v.Status < model.OrderStatusDelivering {
// continue
//}
if orderId == "" && v.VendorID == model.VendorIDDD { // 抖音门店订单除了三方配送回调时推送,不在主动推送配送消息
continue
}
@@ -134,6 +134,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
riderInfo.LogisticsStatus = v.Status
}
taoDeliveryStatus := ""
switch riderInfo.LogisticsStatus {
case 5: // 呼叫骑手
riderInfo.LogisticsStatus = 0
@@ -147,12 +148,15 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
case 20: //配送中
riderInfo.LogisticsStatus = 20
riderInfo.OpCode = tiktok_api.TiktokLogisticsRIDERPICKUP
taoDeliveryStatus = tao_vegetable.OrderStatusDelivery // 配送中
case 110: // 完成
riderInfo.LogisticsStatus = 40
riderInfo.OpCode = tiktok_api.TiktokLogisticsDELIVERED
taoDeliveryStatus = tao_vegetable.OrderStatusDeliveryOver // 完成
case 105: // 完成
riderInfo.LogisticsStatus = 40
riderInfo.OpCode = tiktok_api.TiktokLogisticsDELIVERED
taoDeliveryStatus = tao_vegetable.OrderStatusDeliveryOver // 完成
case 115: // 取消
riderInfo.CourierName = ""
riderInfo.CourierPhone = ""
@@ -161,24 +165,28 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
case 22, 0, 120: // 异常配送
riderInfo.LogisticsStatus = 22
riderInfo.OpCode = tiktok_api.TiktokLogisticsINDDELIVERYEXCEPTION
taoDeliveryStatus = tao_vegetable.OrderStatusUserRejection // 完成
default:
continue
}
if riderInfo.Longitude == "" {
riderInfo.Longitude = utils.Float64ToStr(utils.Int2Float64(v.ConsigneeLng) / 1000000)
}
if riderInfo.Latitude == "" {
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(v.ConsigneeLat) / 1000000)
}
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), v.JxStoreID, 0, "")
if riderInfo.CourierPhone == "" {
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), v.JxStoreID, 0, "")
if err == nil {
riderInfo.CourierPhone = storeDetail.Tel1
}
riderInfo.CourierName = "老板"
}
if riderInfo.Longitude == "" && riderInfo.LogisticsStatus != 105 {
riderInfo.Longitude = utils.Float64ToStr(utils.Int2Float64(storeDetail.Lng) / 1000000)
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(storeDetail.Lat) / 1000000)
}
if riderInfo.Longitude == "" && riderInfo.LogisticsStatus == 105 {
riderInfo.Longitude = utils.Float64ToStr(utils.Int2Float64(v.ConsigneeLng) / 1000000)
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(v.ConsigneeLat) / 1000000)
}
if riderInfo.CourierPhone == "" {
riderInfo.CourierName = "石锋"
riderInfo.CourierPhone = "18048531223"
@@ -186,6 +194,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
if riderInfo.ThirdCarrierOrderId == "" {
riderInfo.ThirdCarrierOrderId = riderInfo.OrderId + "_fake"
}
// 目前只推送美团骑手信息
switch v.VendorID {
case model.VendorIDMTWM: // 美团订单
@@ -212,6 +221,20 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
continue
case model.VendorIDJX: // 京西平台
continue
case model.VendorIDTaoVegetable: // 淘鲜达
// 定时任务刷新骑手坐标
if orderId == "" {
if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID); handler != nil {
if err := handler.GetOrderRider(v.VendorOrgCode, v.VendorStoreID, utils.Struct2Map(riderInfo, "", true)); err != nil {
globals.SugarLogger.Errorf("Error pushing meituan rider information :%s--%s--%v", v.VendorOrderID, utils.Format4Output(riderInfo, false), err)
}
}
} else { // 订单状态改变 [配送中/用户签收/用户拒收]
param := utilsTao.OrderStatusChangeDelivery(&v.GoodsOrder, taoDeliveryStatus)
if err := api.TaoVegetableApi.DeliveryFinish(param); err != nil {
globals.SugarLogger.Debugf("淘先达运单状态推送错误运单状态[%s],错误:%s", taoDeliveryStatus, err.Error())
}
}
default:
globals.SugarLogger.Errorf("Order source error, non system order: %s", v.VendorOrderID)
continue

View File

@@ -382,54 +382,58 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
globals.SugarLogger.Warnf("onWaybillMsg unknown msg:%v", msg)
}
globals.SugarLogger.Debugf("SFPS OnWaybillMsg order=%s", utils.Format4Output(order, false))
if err := partner.CurOrderManager.OnWaybillStatusChanged(order); err != nil {
return sfps2.Err2CallbackResponse(err)
}
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 orderStatus {
case sfps2.OrderStatusNewOrder:
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case sfps2.OrderStatusTakeOrder:
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case sfps2.OrderStatusRiderArriving:
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case sfps2.OrderStatusFinished:
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case sfps2.OrderStatusOrderCancel, sfps2.OrderStatusRiderCancel:
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case sfps2.OrderStatusError:
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case sfps2.OrderStatusArrivedStore:
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
switch order.OrderVendorID {
case model.VendorIDDD:
tiktokStatusPush(order, orderStatus)
case model.VendorIDTaoVegetable, model.VendorIDMTWM:
delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
}
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
return sfps2.Err2CallbackResponse(nil)
}
func tiktokStatusPush(order *model.Waybill, orderStatus int64) {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: order.Status,
OpCode: "",
}
switch orderStatus {
case sfps2.OrderStatusNewOrder:
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case sfps2.OrderStatusTakeOrder:
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case sfps2.OrderStatusRiderArriving:
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
case sfps2.OrderStatusFinished:
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case sfps2.OrderStatusOrderCancel, sfps2.OrderStatusRiderCancel:
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case sfps2.OrderStatusError:
result.LogisticsStatus = model.WaybillStatusDeliverFailed
result.LogisticsContext = model.RiderGetOrderDeliverFailed
case sfps2.OrderStatusArrivedStore:
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
}
// OnWaybillExceptSF 异常报备
func OnWaybillExceptSF(msg *sfps2.RiderException) (retVal *sfps2.CallbackResponse) {
jxutils.CallMsgHandler(func() {

View File

@@ -381,48 +381,54 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
return uuptapi.Err2CallbackResponse(err)
}
//推送抖音
if param.OrderVendorID == model.VendorIDDD {
result := &mtpsapi.RiderInfo{
OrderId: param.VendorOrderID,
ThirdCarrierOrderId: param.VendorOrderID,
CourierName: param.CourierName,
CourierPhone: param.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: param.Status,
OpCode: "",
}
switch req.State {
case uuptapi.StateConfirmSuccess: //下单成功
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case uuptapi.StateRMGrabsOrder: //骑手已接单
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case uuptapi.StateArrivedStore: //骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
case uuptapi.StatePickUp: //已取件
result.LogisticsStatus = model.WaybillStatusUuPickUp
result.LogisticsContext = model.RiderPickUp
case uuptapi.StateArrivedDestination: //到达取件人地址处
result.LogisticsStatus = model.WaybillStatusUuArrivedDestination
result.LogisticsContext = model.RiderArrivedDestination
case uuptapi.StateReceiverGetGoods: //取件人收货
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case uuptapi.StateOrderCancel: //运单取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
switch param.OrderVendorID {
case model.VendorIDDD:
tiktokStatusPush(param, req.State)
case model.VendorIDMTWM, model.VendorIDTaoVegetable:
delivery.GetOrderRiderInfoToPlatform(param.VendorOrderID, param.Status) // 骑手位置更新
}
defer delivery.GetOrderRiderInfoToPlatform(param.VendorOrderID, param.Status) // 骑手位置更新
return uuptapi.Err2CallbackResponse(nil)
}
func tiktokStatusPush(param *model.Waybill, orderStatus string) {
result := &mtpsapi.RiderInfo{
OrderId: param.VendorOrderID,
ThirdCarrierOrderId: param.VendorOrderID,
CourierName: param.CourierName,
CourierPhone: param.CourierMobile,
LogisticsProviderCode: "10002",
LogisticsStatus: param.Status,
OpCode: "",
}
switch orderStatus {
case uuptapi.StateConfirmSuccess: //下单成功
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case uuptapi.StateRMGrabsOrder: //骑手已接单
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case uuptapi.StateArrivedStore: //骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
case uuptapi.StatePickUp: //已取件
result.LogisticsStatus = model.WaybillStatusUuPickUp
result.LogisticsContext = model.RiderPickUp
case uuptapi.StateArrivedDestination: //到达取件人地址处
result.LogisticsStatus = model.WaybillStatusUuArrivedDestination
result.LogisticsContext = model.RiderArrivedDestination
case uuptapi.StateReceiverGetGoods: //取件人收货
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case uuptapi.StateOrderCancel: //运单取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
}
//辅助函数
func getReallyStoreID(storeID, jxStoreID int) int {
if storeID == 0 && jxStoreID == 0 {