From 76da2af43e4bc8ee8b6131289cc72c47fd854d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 9 Dec 2020 11:50:19 +0800 Subject: [PATCH] a --- business/jxutils/tasks/configrefresh.go | 2 +- business/model/const.go | 12 ++++++---- business/partner/delivery/fn/waybill.go | 31 +++++++++++++++++++++++++ controllers/fn_callback.go | 7 +++++- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/business/jxutils/tasks/configrefresh.go b/business/jxutils/tasks/configrefresh.go index e38bc2f7f..a0a5f700b 100644 --- a/business/jxutils/tasks/configrefresh.go +++ b/business/jxutils/tasks/configrefresh.go @@ -29,7 +29,7 @@ const ( weimobTokenExpires = 7200 * time.Second yilianyunTokenExpires = 30 * 24 * 3600 * time.Second pushTokenExpires = 7200 * time.Second - fnTokenExpires = 12 * time.Hour + fnTokenExpires = 6 * time.Hour maxRefreshGap = 5 * 60 * time.Second errRefreshGap = 10 * time.Second diff --git a/business/model/const.go b/business/model/const.go index 5c5ffa6f5..517808e1d 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -77,6 +77,7 @@ var ( WaybillStatusPending: "压单", WaybillStatusAcceptCanceled: "取消接受", WaybillStatusAccepted: "已接单", + WaybillStatusCourierAssigned: "已分配骑手", WaybillStatusCourierArrived: "已到店", WaybillStatusApplyFailedGetGoods: "取货失败待审核", WaybillStatusAgreeFailedGetGoods: "取货失败", @@ -306,11 +307,12 @@ const ( WaybillStatusRefuseFailedGetGoods = -70 WaybillStatusUnknown = 0 - WaybillStatusNew = 5 - WaybillStatusPending = 7 - WaybillStatusAcceptCanceled = 8 - WaybillStatusAccepted = 10 - WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态 + WaybillStatusNew = 5 + WaybillStatusPending = 7 + WaybillStatusAcceptCanceled = 8 + WaybillStatusAccepted = 10 + WaybillStatusCourierAssigned = 12 //已分配骑手 + WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态 WaybillStatusApplyFailedGetGoods = 17 // 取货失败待审核 WaybillStatusAgreeFailedGetGoods = 18 // 取货失败 diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index 53828386a..358759b7b 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -114,3 +114,34 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf return deliveryFeeInfo, err } + +func OnWaybillMsg(msg *fnpsapi.WayBillInfo) { + order := &model.Waybill{ + VendorWaybillID: msg.PartnerOrderCode, + VendorWaybillID2: msg.PartnerOrderCode, + WaybillVendorID: model.VendorIDFengNiao, + CourierName: msg.CarrierDriverName, + CourierMobile: msg.CarrierDriverPhone, + VendorStatus: utils.Int2Str(msg.OrderStatus), + StatusTime: utils.Timestamp2Time(msg.PushTime), + Remark: msg.Description, + } + order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.PartnerOrderCode) + switch msg.OrderStatus { + case fnpsapi.OrderStatusAccept: + order.Status = model.WaybillStatusAccepted + case fnpsapi.OrderStatusAssigned: + order.Status = model.WaybillStatusCourierAssigned + case fnpsapi.OrderStatusArrived: + order.Status = model.WaybillStatusCourierArrived + case fnpsapi.OrderStatusDelivering: + order.Status = model.WaybillStatusDelivering + case fnpsapi.OrderStatusDelivered: + order.Status = model.WaybillStatusDelivered + case fnpsapi.OrderStatusException: + order.Status = model.WaybillStatusDeliverFailed + default: + globals.SugarLogger.Warnf("onWaybillMsg unknown msg:%v", msg) + } + partner.CurOrderManager.OnWaybillStatusChanged(order) +} diff --git a/controllers/fn_callback.go b/controllers/fn_callback.go index 6b4a5a269..2dc4ba9e7 100644 --- a/controllers/fn_callback.go +++ b/controllers/fn_callback.go @@ -3,6 +3,8 @@ package controllers import ( "net/http" + "git.rosy.net.cn/jx-callback/globals/api" + "github.com/astaxie/beego" ) @@ -12,7 +14,10 @@ type FnController struct { func (c *FnController) Msg() { if c.Ctx.Input.Method() == http.MethodPost { - + msg := api.FnAPI.GetOrderCallbackMsg(c.Ctx.Request) + if msg != nil { + fn.OnWaybillMsg(msg) + } c.Data["json"] = "" c.ServeJSON() } else {