美团配送推送抖店配送信息

This commit is contained in:
邹宗楠
2022-11-25 10:16:56 +08:00
parent 20a71bdb2c
commit 3538b5a809
4 changed files with 56 additions and 160 deletions

View File

@@ -126,6 +126,44 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
// 加入调度器
err := mtpsapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
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: "10032",
LogisticsStatus: order.Status,
OpCode: "",
}
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case mtpsapi.OrderStatusAccepted: // 已接单
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case mtpsapi.OrderStatusDeliverred: // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case mtpsapi.OrderStatusCanceled: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case mtpsapi.OrderStatusPickedUp: // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
delivery.PullTiktokRiderInfo(result)
if result.LogisticsStatus == model.WaybillStatusCourierArrived {
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
delivery.PullTiktokRiderInfo(result)
}
}
return err
}

View File

@@ -27,7 +27,7 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
// 当前订单所属门店不属于菜市时,将消息推送到果园
gyMsg := map[string]interface{}{"tag": msgId, "msg_id": utils.Int64ToStr(time.Now().Unix()) + msgId, "data": msg}
// 通知到果园
gyResult, err := HttpToGuoYuan(gyMsg)
gyResult, err := HttpToGuoYuan(gyMsg, "order")
if err != nil {
return tiktokShop.Err2CallbackResponse(err, "")
}
@@ -46,14 +46,23 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
return response
}
func HttpToGuoYuan(param map[string]interface{}) (*http.Response, error) {
func HttpToGuoYuan(param map[string]interface{}, requestType string) (*http.Response, error) {
paramData, err := json.Marshal(param)
if err != nil {
return nil, err
}
body := strings.NewReader(string(paramData))
httpReq, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg", body)
url := ""
switch requestType {
case "order": // 订单相关
url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg"
case "token": // 授权相关
case "wayBill": // 授权相关
}
httpReq, err := http.NewRequest(http.MethodPost, url, body)
if err != nil {
return nil, err
}