sfps
This commit is contained in:
@@ -130,8 +130,6 @@ func AutoSettingFakeDelivery() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("==========%s,%d", riderKey, len(riderListInfo[riderKey]))
|
|
||||||
globals.SugarLogger.Debug("==========%s", utils.Format4Output(riderListInfo[riderKey], false))
|
|
||||||
randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey]))))
|
randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey]))))
|
||||||
randTime := randNumber.Int64()
|
randTime := randNumber.Int64()
|
||||||
if randTime < 0 {
|
if randTime < 0 {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const (
|
|||||||
VendorIDFengNiao = 103 // 蜂鸟配送
|
VendorIDFengNiao = 103 // 蜂鸟配送
|
||||||
//VendorIDDYPS = 104 // 抖音配送
|
//VendorIDDYPS = 104 // 抖音配送
|
||||||
VendorIDUUPT = 105 //uu跑腿
|
VendorIDUUPT = 105 //uu跑腿
|
||||||
|
VendorIDSFPS = 106 //顺丰派送
|
||||||
VendorJXFakeWL = 300 // 京西假物流
|
VendorJXFakeWL = 300 // 京西假物流
|
||||||
VendorIDJDWL = 401 // 京东物流
|
VendorIDJDWL = 401 // 京东物流
|
||||||
VendorIDTotalWl = 402 // (综合物流[京东,圆通,申通....])
|
VendorIDTotalWl = 402 // (综合物流[京东,圆通,申通....])
|
||||||
|
|||||||
@@ -109,10 +109,10 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
|||||||
|
|
||||||
riderInfo := &mtpsapi.RiderInfo{}
|
riderInfo := &mtpsapi.RiderInfo{}
|
||||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handlerInfo != nil {
|
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handlerInfo != nil {
|
||||||
if v.WaybillVendorID == model.VendorIDDada || v.WaybillVendorID == model.VendorIDFengNiao || v.WaybillVendorID == model.VendorIDUUPT {
|
if v.WaybillVendorID == model.VendorIDDada || v.WaybillVendorID == model.VendorIDFengNiao || v.WaybillVendorID == model.VendorIDUUPT || v.WaybillVendorID == model.VendorIDSFPS {
|
||||||
riderInfo, err = handlerInfo.Handler.GetRiderInfo(v.VendorOrderID, 0, v.VendorWaybillID)
|
riderInfo, err = handlerInfo.Handler.GetRiderInfo(v.VendorOrderID, 0, v.VendorWaybillID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Debug("Get Order waybill rider info err FN/DADA/DYPS :%v", err)
|
globals.SugarLogger.Debug("Get Order waybill rider info err FN/DADA/SFPS :%v", err)
|
||||||
}
|
}
|
||||||
} else if v.WaybillVendorID == model.VendorIDMTPS {
|
} else if v.WaybillVendorID == model.VendorIDMTPS {
|
||||||
if v.VendorWaybillID != "" {
|
if v.VendorWaybillID != "" {
|
||||||
|
|||||||
401
business/partner/delivery/sfps/waybill.go
Normal file
401
business/partner/delivery/sfps/waybill.go
Normal file
@@ -0,0 +1,401 @@
|
|||||||
|
package sfps
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/sfps2"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeliveryHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
curDeliveryHandler *DeliveryHandler
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if api.SfPsAPI != nil {
|
||||||
|
curDeliveryHandler = new(DeliveryHandler)
|
||||||
|
partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) GetVendorID() int {
|
||||||
|
return model.VendorIDSFPS
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||||
|
return "", 0, fmt.Errorf("顺丰派送暂不支持此操作")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
|
||||||
|
store, err := dao.GetStoreDetail(dao.GetDB(), utils.Str2Int(vendorStoreID), model.VendorIDSFPS, "")
|
||||||
|
if err == nil {
|
||||||
|
storeDetail = &dao.StoreDetail2{
|
||||||
|
Store: model.Store{
|
||||||
|
Name: store.Name,
|
||||||
|
Tel1: store.Tel1,
|
||||||
|
Address: store.Address,
|
||||||
|
Lat: store.Lat,
|
||||||
|
Lng: store.Lng,
|
||||||
|
},
|
||||||
|
VendorID: model.VendorIDSFPS,
|
||||||
|
VendorStoreID: utils.Int2Str(storeID),
|
||||||
|
CourierStatus: model.StoreStatusOpened,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storeDetail, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) IsErrStoreExist(err error) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||||
|
vendorOrgCode, err := dao.GetVendorOrgCode(dao.GetDB(), model.VendorIDSFPS, "", model.VendorOrgTypeDelivery)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(vendorOrgCode) > 0 && vendorOrgCode[0].IsOpen == model.YES {
|
||||||
|
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||||
|
}
|
||||||
|
|
||||||
|
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
weight int
|
||||||
|
productDetail []*sfps2.ProductDetail
|
||||||
|
)
|
||||||
|
if order.Weight >= 49500 {
|
||||||
|
weight = 49500
|
||||||
|
} else {
|
||||||
|
weight = order.Weight
|
||||||
|
}
|
||||||
|
|
||||||
|
param := &sfps2.CreateOrderReq{
|
||||||
|
ShopId: sfps2.SFShopStoreID,
|
||||||
|
ShopOrderId: order.VendorOrderID,
|
||||||
|
OrderSource: GetVendorSource(order.VendorID),
|
||||||
|
OrderTime: order.CreatedAt.Unix(),
|
||||||
|
Receive: &sfps2.ReceiveAddress{
|
||||||
|
UserName: order.ConsigneeName,
|
||||||
|
UserPhone: order.ConsigneeMobile,
|
||||||
|
UserAddress: order.ConsigneeAddress,
|
||||||
|
UserLat: utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLat)),
|
||||||
|
UserLng: utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLng)),
|
||||||
|
},
|
||||||
|
Shop: &sfps2.SfShopInfo{
|
||||||
|
ShopName: order.StoreName,
|
||||||
|
ShopPhone: store.Tel1,
|
||||||
|
ShopAddress: store.Address,
|
||||||
|
ShopLat: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)),
|
||||||
|
ShopLng: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
||||||
|
},
|
||||||
|
OrderDetail: &sfps2.OrderDetail{
|
||||||
|
TotalPrice: order.ActualPayPrice,
|
||||||
|
ProductType: sfps2.ProductTypeFresh,
|
||||||
|
WeightGram: int64(weight),
|
||||||
|
ProductNum: int64(order.GoodsCount),
|
||||||
|
ProductTypeNum: int64(order.SkuCount),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range order.Skus {
|
||||||
|
productDetail = append(productDetail, &sfps2.ProductDetail{
|
||||||
|
ProductName: v.SkuName,
|
||||||
|
ProductNum: int64(v.Count),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
param.OrderDetail.ProductDetail = productDetail
|
||||||
|
|
||||||
|
sfOrderID, sfBillID, sfTotalPrice, err := api.SfPsAPI.CreateOrder(param)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
bill = &model.Waybill{
|
||||||
|
VendorOrderID: order.VendorOrderID,
|
||||||
|
OrderVendorID: order.VendorID,
|
||||||
|
VendorWaybillID: sfOrderID,
|
||||||
|
VendorWaybillID2: sfBillID,
|
||||||
|
WaybillVendorID: model.VendorIDFengNiao,
|
||||||
|
DesiredFee: int64(sfTotalPrice),
|
||||||
|
}
|
||||||
|
delivery.OnWaybillCreated(bill)
|
||||||
|
return bill, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||||
|
if err = api.SfPsAPI.CancelOrder(bill.VendorWaybillID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
bill.Status = model.WaybillStatusCanceled
|
||||||
|
bill.Remark = cancelReason
|
||||||
|
partner.CurOrderManager.OnWaybillStatusChanged(bill)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||||
|
var (
|
||||||
|
weight int
|
||||||
|
//productDetail []*sfps2.ProductDetail
|
||||||
|
)
|
||||||
|
if order.Weight >= 49500 {
|
||||||
|
weight = 49500
|
||||||
|
} else {
|
||||||
|
weight = order.Weight
|
||||||
|
}
|
||||||
|
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
param := &sfps2.PreCreateOrderReq{
|
||||||
|
ShopId: sfps2.SFShopStoreID,
|
||||||
|
UserLng: utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLng)),
|
||||||
|
UserLat: utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLat)),
|
||||||
|
UserAddress: order.ConsigneeAddress,
|
||||||
|
Weight: int64(weight),
|
||||||
|
ProductType: sfps2.ProductTypeFresh,
|
||||||
|
Shop: &sfps2.SfShopInfo{
|
||||||
|
ShopName: order.StoreName,
|
||||||
|
ShopPhone: store.Tel1,
|
||||||
|
ShopAddress: store.Address,
|
||||||
|
ShopLat: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)),
|
||||||
|
ShopLng: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||||
|
price, err := api.SfPsAPI.PreCreateOrder(param)
|
||||||
|
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(price)
|
||||||
|
return deliveryFeeInfo, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||||
|
order, err := dao.GetWaybills(dao.GetDB(), orderId)
|
||||||
|
if len(order) == 0 || err != nil {
|
||||||
|
return nil, errors.New("顺丰 订单id无效,请检查")
|
||||||
|
}
|
||||||
|
//获取顺丰运单详情
|
||||||
|
sfOrder, err := api.SfPsAPI.GetOrderStatus(order[0].VendorWaybillID)
|
||||||
|
//获取顺丰骑手实时位置
|
||||||
|
sfRider, err := api.SfPsAPI.GetRiderLatestPosition(sfOrder.OrderID)
|
||||||
|
|
||||||
|
result := &mtpsapi.RiderInfo{
|
||||||
|
OrderId: orderId,
|
||||||
|
ThirdCarrierOrderId: sfOrder.OrderID,
|
||||||
|
CourierName: sfOrder.RiderName,
|
||||||
|
CourierPhone: sfOrder.RiderPhone,
|
||||||
|
LogisticsProviderCode: mtpsapi.SFPSCode,
|
||||||
|
LogisticsStatus: utils.Float64TwoInt(sfOrder.OrderStatus), // 默认正在配送中
|
||||||
|
Latitude: sfRider.RiderLat,
|
||||||
|
Longitude: sfRider.RiderLng,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch sfOrder.OrderStatus {
|
||||||
|
case sfps2.OrderStatusNewOrder:
|
||||||
|
result.LogisticsStatus = model.WaybillStatusNew
|
||||||
|
result.LogisticsContext = model.RiderWaitRider
|
||||||
|
case sfps2.OrderStatusTakeOrder:
|
||||||
|
result.LogisticsStatus = model.WaybillStatusCourierAssigned
|
||||||
|
result.LogisticsContext = model.RiderGetOrder
|
||||||
|
case sfps2.OrderStatusArrivedStore:
|
||||||
|
result.LogisticsStatus = model.WaybillStatusCourierArrived
|
||||||
|
result.LogisticsContext = model.RiderToStore
|
||||||
|
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:
|
||||||
|
result.LogisticsStatus = model.WaybillStatusCanceled
|
||||||
|
result.LogisticsContext = model.RiderGetOrderCanceled
|
||||||
|
case sfps2.OrderStatusError:
|
||||||
|
result.LogisticsStatus = model.WaybillStatusDeliverFailed
|
||||||
|
result.LogisticsContext = model.RiderGetOrderDeliverFailed
|
||||||
|
default:
|
||||||
|
result.LogisticsStatus = 0
|
||||||
|
result.LogisticsContext = model.RiderGetOrderDeliverOther
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnWaybillMsg 配送状态更改回调
|
||||||
|
func OnWaybillMsg(msg *sfps2.RiderStatus) (resp *sfps2.CallbackResponse) {
|
||||||
|
|
||||||
|
order := &model.Waybill{
|
||||||
|
VendorWaybillID: msg.SFOrderID,
|
||||||
|
WaybillVendorID: model.VendorIDSFPS,
|
||||||
|
VendorOrderID: msg.ShopOrderID,
|
||||||
|
CourierName: msg.OperatorName,
|
||||||
|
CourierMobile: msg.OperatorPhone,
|
||||||
|
VendorStatus: utils.Int2Str(msg.OrderStatus),
|
||||||
|
StatusTime: utils.Timestamp2Time(int64(msg.PushTime)),
|
||||||
|
Remark: msg.StatusDesc,
|
||||||
|
}
|
||||||
|
if msg.PushTime == 0 {
|
||||||
|
order.StatusTime = time.Now()
|
||||||
|
}
|
||||||
|
//获取实时订单信息
|
||||||
|
sfOrder, err := api.SfPsAPI.GetOrderStatus(msg.SFOrderID)
|
||||||
|
if err != nil {
|
||||||
|
return sfps2.Err2CallbackResponse(err)
|
||||||
|
}
|
||||||
|
var good *model.GoodsOrder
|
||||||
|
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
||||||
|
sqlParams := []interface{}{msg.ShopOrderID}
|
||||||
|
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||||
|
order.OrderVendorID = good.VendorID
|
||||||
|
|
||||||
|
orderStatus := utils.Str2Int64(order.VendorStatus)
|
||||||
|
switch orderStatus {
|
||||||
|
case sfps2.OrderStatusNewOrder: //1:订单创建
|
||||||
|
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
|
||||||
|
order.Status = model.WaybillStatusNew //5 带调度
|
||||||
|
case sfps2.OrderStatusTakeOrder: //10:配送员接单
|
||||||
|
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
|
||||||
|
order.Status = model.WaybillStatusCourierAssigned //12
|
||||||
|
order.Remark = order.CourierName + "," + order.CourierMobile
|
||||||
|
case sfps2.OrderStatusArrivedStore:
|
||||||
|
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
|
||||||
|
order.Status = model.WaybillStatusCourierArrived
|
||||||
|
case sfps2.OrderStatusRiderArriving:
|
||||||
|
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
|
||||||
|
order.Status = model.WaybillStatusDelivering
|
||||||
|
case sfps2.OrderStatusFinished:
|
||||||
|
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
|
||||||
|
order.Status = model.WaybillStatusDelivered
|
||||||
|
case sfps2.OrderStatusOrderCancel:
|
||||||
|
order.Status = model.WaybillStatusCanceled
|
||||||
|
case sfps2.OrderStatusError:
|
||||||
|
order.Status = model.WaybillStatusDeliverFailed // 22
|
||||||
|
default:
|
||||||
|
globals.SugarLogger.Warnf("onWaybillMsg unknown msg:%v", msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
|
||||||
|
return sfps2.Err2CallbackResponse(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnWaybillExceptSF 异常报备
|
||||||
|
func OnWaybillExceptSF(msg *sfps2.RiderException) (retVal *sfps2.CallbackResponse) {
|
||||||
|
jxutils.CallMsgHandler(func() {
|
||||||
|
order := &model.Waybill{
|
||||||
|
VendorWaybillID: msg.SFOrderID,
|
||||||
|
VendorWaybillID2: utils.Int2Str(msg.ExID),
|
||||||
|
WaybillVendorID: model.VendorIDSFPS,
|
||||||
|
CourierName: msg.OperatorName,
|
||||||
|
CourierMobile: "",
|
||||||
|
Status: model.WaybillStatusUnknown, // todo 这里要再确定一下是否只要收到订单异常消息就只简单当成一个消息
|
||||||
|
VendorStatus: utils.Int2Str(msg.OrderStatus),
|
||||||
|
StatusTime: utils.Timestamp2Time(int64(msg.PushTime)),
|
||||||
|
}
|
||||||
|
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.ShopOrderID)
|
||||||
|
retVal = sfps2.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order))
|
||||||
|
}, jxutils.ComposeUniversalOrderID(msg.ShopOrderID, model.VendorIDSFPS))
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVendorSource 辅助函数
|
||||||
|
//获取订单来源标识符
|
||||||
|
func GetVendorSource(vendorID int) (source string) {
|
||||||
|
switch vendorID {
|
||||||
|
case model.VendorIDMTWM:
|
||||||
|
source = sfps2.OrderSourceMt
|
||||||
|
case model.VendorIDELM:
|
||||||
|
source = sfps2.OrderSourceELM
|
||||||
|
case model.VendorIDEBAI:
|
||||||
|
source = sfps2.OrderSourceEBAI
|
||||||
|
case model.VendorIDDD:
|
||||||
|
source = "抖音"
|
||||||
|
case model.VendorIDJD:
|
||||||
|
source = "京东"
|
||||||
|
case model.VendorIDJX:
|
||||||
|
source = "京西"
|
||||||
|
default:
|
||||||
|
source = "其他"
|
||||||
|
}
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
|
||||||
|
func getReallyStoreID(storeID, jxStoreID int) int {
|
||||||
|
if storeID == 0 && jxStoreID == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if storeID == 0 {
|
||||||
|
return jxStoreID
|
||||||
|
} else {
|
||||||
|
return storeID
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -320,11 +320,8 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
|||||||
case uuptapi.StateArrivedStore:
|
case uuptapi.StateArrivedStore:
|
||||||
param.Status = model.WaybillStatusCourierArrived
|
param.Status = model.WaybillStatusCourierArrived
|
||||||
param.DesiredFee = reallyPrice
|
param.DesiredFee = reallyPrice
|
||||||
case uuptapi.StatePickUp:
|
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination:
|
||||||
param.Status = model.WaybillStatusUuPickUp
|
param.Status = model.WaybillStatusDelivering
|
||||||
param.DesiredFee = reallyPrice
|
|
||||||
case uuptapi.StateArrivedDestination:
|
|
||||||
param.Status = model.WaybillStatusUuArrivedDestination
|
|
||||||
param.DesiredFee = reallyPrice
|
param.DesiredFee = reallyPrice
|
||||||
case uuptapi.StateReceiverGetGoods:
|
case uuptapi.StateReceiverGetGoods:
|
||||||
param.Status = model.WaybillStatusDelivered
|
param.Status = model.WaybillStatusDelivered
|
||||||
@@ -358,12 +355,9 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
|||||||
case uuptapi.StateArrivedStore: //骑手到店
|
case uuptapi.StateArrivedStore: //骑手到店
|
||||||
result.LogisticsStatus = model.WaybillStatusCourierArrived
|
result.LogisticsStatus = model.WaybillStatusCourierArrived
|
||||||
result.LogisticsContext = model.RiderToStore
|
result.LogisticsContext = model.RiderToStore
|
||||||
case uuptapi.StatePickUp: //已取件
|
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination: //已取件
|
||||||
result.LogisticsStatus = model.WaybillStatusUuPickUp
|
result.LogisticsStatus = model.WaybillStatusDelivering
|
||||||
result.LogisticsContext = model.RiderPickUp
|
result.LogisticsContext = model.RiderPickUp
|
||||||
case uuptapi.StateArrivedDestination: //到达取件人地址处
|
|
||||||
result.LogisticsStatus = model.WaybillStatusUuArrivedDestination
|
|
||||||
result.LogisticsContext = model.RiderArrivedDestination
|
|
||||||
case uuptapi.StateReceiverGetGoods: //取件人收货
|
case uuptapi.StateReceiverGetGoods: //取件人收货
|
||||||
result.LogisticsStatus = model.WaybillStatusDelivered
|
result.LogisticsStatus = model.WaybillStatusDelivered
|
||||||
result.LogisticsContext = model.RiderGetOrderDelivered
|
result.LogisticsContext = model.RiderGetOrderDelivered
|
||||||
|
|||||||
49
controllers/sfps_callback.go
Normal file
49
controllers/sfps_callback.go
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/sfps"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SFPSController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SFPSController) SfOrder() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
msg, callbackResponse := api.SfPsAPI.GetRiderStatusCallback(c.Ctx.Request)
|
||||||
|
if callbackResponse.ErrorCode == -1 {
|
||||||
|
c.Data["error_code"] = -1
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 订单回调
|
||||||
|
callbackResponse = sfps.OnWaybillMsg(msg)
|
||||||
|
c.Data["error_code"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SfAbnormal 异常回调
|
||||||
|
func (c *FnController) SfAbnormal() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
msg, callbackResponse := api.SfPsAPI.GetRiderExceptionCallback(c.Ctx.Request)
|
||||||
|
if callbackResponse.ErrorCode == -1 {
|
||||||
|
c.Data["error_code"] = -1
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
callbackResponse = sfps.OnWaybillExceptSF(msg)
|
||||||
|
c.Data["error_code"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/kuaishou_mini"
|
"git.rosy.net.cn/baseapi/platformapi/kuaishou_mini"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/sfps2"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tiktok"
|
"git.rosy.net.cn/baseapi/platformapi/tiktok"
|
||||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/trenditapi"
|
"git.rosy.net.cn/baseapi/platformapi/trenditapi"
|
||||||
@@ -91,6 +92,7 @@ var (
|
|||||||
TLpayAPI *tonglianpayapi.API //通联收银宝api
|
TLpayAPI *tonglianpayapi.API //通联收银宝api
|
||||||
FnAPI *fnpsapi.API //蜂鸟配送api
|
FnAPI *fnpsapi.API //蜂鸟配送api
|
||||||
UuAPI *uuptapi.API //uu跑腿api
|
UuAPI *uuptapi.API //uu跑腿api
|
||||||
|
SfPsAPI *sfps2.API //顺丰派送api
|
||||||
YinBaoAPI *yinbaoapi.API //银豹平台api
|
YinBaoAPI *yinbaoapi.API //银豹平台api
|
||||||
|
|
||||||
WeixinPageAPI *weixinapi.API // 用户微信扫码登录
|
WeixinPageAPI *weixinapi.API // 用户微信扫码登录
|
||||||
|
|||||||
@@ -6,25 +6,24 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego/client/orm"
|
"github.com/astaxie/beego/client/orm"
|
||||||
"github.com/astaxie/beego/server/web"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
// set default database
|
// set default database
|
||||||
// orm.RegisterDataBase(aliasName, driverName, dataSource, params)
|
// orm.RegisterDataBase(aliasName, driverName, dataSource, params)
|
||||||
//正式服务器
|
//正式服务器
|
||||||
orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
//orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
||||||
orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
//orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
//orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
// 本地测试服调试
|
// 本地测试服调试
|
||||||
// orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
// orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
||||||
//orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
//orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
//orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
//orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
|
|
||||||
//本地服务器测试用 -ysq
|
//本地服务器测试用 -ysq
|
||||||
//orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
//orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
//orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||||
|
|
||||||
// 开启sql打印
|
// 开启sql打印
|
||||||
//orm.Debug = true
|
//orm.Debug = true
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ func init() {
|
|||||||
web.AutoRouter(&controllers.JdsController{})
|
web.AutoRouter(&controllers.JdsController{})
|
||||||
web.AutoRouter(&controllers.FnController{})
|
web.AutoRouter(&controllers.FnController{})
|
||||||
web.AutoRouter(&controllers.UuPtController{})
|
web.AutoRouter(&controllers.UuPtController{})
|
||||||
|
web.AutoRouter(&controllers.SFPSController{})
|
||||||
web.AutoRouter(&controllers.KnowUploadController{})
|
web.AutoRouter(&controllers.KnowUploadController{})
|
||||||
web.AutoRouter(&controllers.AliApiController{})
|
web.AutoRouter(&controllers.AliApiController{})
|
||||||
web.AutoRouter(&controllers.TicTocController{})
|
web.AutoRouter(&controllers.TicTocController{})
|
||||||
|
|||||||
Reference in New Issue
Block a user