uu
This commit is contained in:
@@ -905,7 +905,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
|||||||
if err = s.canOrderCreateWaybillNormally(order, savedOrderInfo); err == nil {
|
if err = s.canOrderCreateWaybillNormally(order, savedOrderInfo); err == nil {
|
||||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||||
if savedOrderInfo.retryCount <= maxWaybillRetryCount {
|
if savedOrderInfo.retryCount <= maxWaybillRetryCount {
|
||||||
var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao}
|
var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT}
|
||||||
savedOrderInfo.isNeedCreate3rdWaybill = true
|
savedOrderInfo.isNeedCreate3rdWaybill = true
|
||||||
excludeVendorIDs := savedOrderInfo.GetWaybillVendorIDs()
|
excludeVendorIDs := savedOrderInfo.GetWaybillVendorIDs()
|
||||||
//TODO 取消京西不自动发美团 2020-06-02
|
//TODO 取消京西不自动发美团 2020-06-02
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ var (
|
|||||||
VendorIDMTPS: "Mtps",
|
VendorIDMTPS: "Mtps",
|
||||||
VendorIDFengNiao: "Fn",
|
VendorIDFengNiao: "Fn",
|
||||||
VendorIDDYPS: "DYPS",
|
VendorIDDYPS: "DYPS",
|
||||||
|
VendorIDUUPT: "UUPT",
|
||||||
|
|
||||||
VendorIDFeiE: "Feie",
|
VendorIDFeiE: "Feie",
|
||||||
VendorIDXiaoWM: "XiaoWM",
|
VendorIDXiaoWM: "XiaoWM",
|
||||||
@@ -136,6 +137,7 @@ var (
|
|||||||
VendorIDJDWL: "京东物流",
|
VendorIDJDWL: "京东物流",
|
||||||
VendorIDFengNiao: "蜂鸟配送",
|
VendorIDFengNiao: "蜂鸟配送",
|
||||||
VendorIDDYPS: "抖音配送",
|
VendorIDDYPS: "抖音配送",
|
||||||
|
VendorIDUUPT: "UU跑腿",
|
||||||
|
|
||||||
VendorIDFeiE: "飞鹅",
|
VendorIDFeiE: "飞鹅",
|
||||||
VendorIDXiaoWM: "外卖管家",
|
VendorIDXiaoWM: "外卖管家",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ const (
|
|||||||
BrandOpenDaDa = 2 //达达
|
BrandOpenDaDa = 2 //达达
|
||||||
BrandOpenFN = 4 //蜂鸟
|
BrandOpenFN = 4 //蜂鸟
|
||||||
BrandOpenDYPS = 5 //抖音配送
|
BrandOpenDYPS = 5 //抖音配送
|
||||||
|
BrandOpenUUPT = 6 //uu跑腿
|
||||||
BrandOpenSMS = 8 //短信
|
BrandOpenSMS = 8 //短信
|
||||||
BrandOpenVoice = 16 //语音
|
BrandOpenVoice = 16 //语音
|
||||||
|
|
||||||
@@ -299,6 +300,7 @@ var (
|
|||||||
VendorIDDada: BrandOpenDaDa,
|
VendorIDDada: BrandOpenDaDa,
|
||||||
VendorIDFengNiao: BrandOpenFN,
|
VendorIDFengNiao: BrandOpenFN,
|
||||||
VendorIDDYPS: BrandOpenDYPS,
|
VendorIDDYPS: BrandOpenDYPS,
|
||||||
|
VendorIDUUPT: BrandOpenUUPT,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
package uupt
|
package uupt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -96,48 +103,196 @@ func (d DeliveryHandler) GetVendorID() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
func (d DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||||
//TODO implement me
|
return "", 0, fmt.Errorf("uu跑腿暂不支持此操作")
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
|
func (d DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
|
||||||
//TODO implement me
|
//uu跑腿无门店概念
|
||||||
panic("implement me")
|
store, err := dao.GetStoreDetail(dao.GetDB(), utils.Str2Int(vendorStoreID), model.VendorIDUUPT, "")
|
||||||
|
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.VendorIDUUPT,
|
||||||
|
VendorStoreID: utils.Int2Str(storeID),
|
||||||
|
CourierStatus: model.StoreStatusOpened,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storeDetail, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
func (d DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
||||||
//TODO implement me
|
return false
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) IsErrStoreExist(err error) bool {
|
func (d DeliveryHandler) IsErrStoreExist(err error) bool {
|
||||||
//TODO implement me
|
return false
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||||
//TODO implement me
|
//获取金额令牌,实际需要支付金额
|
||||||
panic("implement me")
|
price, err := getOrderPrice(order)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
param := map[string]interface{}{
|
||||||
|
"price_token": price.PriceToken,
|
||||||
|
"order_price": price.TotalMoney,
|
||||||
|
"balance_paymoney": price.NeedPayMoney,
|
||||||
|
"receiver": order.ConsigneeName,
|
||||||
|
"receiver_phone": order.ConsigneeMobile,
|
||||||
|
"callback_url": uuptapi.WaybillCallbackURL,
|
||||||
|
"push_type": uuptapi.PushTypeOpen,
|
||||||
|
"special_type": uuptapi.SpecialTypeNo,
|
||||||
|
"callme_withtake": uuptapi.CallMeWithTakeYes,
|
||||||
|
}
|
||||||
|
if orderCode, originID, err := api.UuAPI.AddOrder(param); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
bill = &model.Waybill{
|
||||||
|
VendorOrderID: order.VendorOrderID,
|
||||||
|
OrderVendorID: order.VendorID,
|
||||||
|
VendorWaybillID: orderCode,
|
||||||
|
VendorWaybillID2: originID,
|
||||||
|
WaybillVendorID: model.VendorIDUUPT,
|
||||||
|
DesiredFee: utils.Str2Int64(price.NeedPayMoney),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delivery.OnWaybillCreated(bill)
|
||||||
|
return bill, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||||
//if err = api.UuAPI.CancelOrder(bill.VendorWaybillID, uuptapi.CancelReasonNormal); err != nil {
|
if err = api.UuAPI.CancelOrder(bill.VendorWaybillID, uuptapi.CancelReasonNormal); err != nil {
|
||||||
//
|
return err
|
||||||
//}
|
}
|
||||||
|
bill.Status = model.WaybillStatusCanceled
|
||||||
|
bill.Remark = cancelReason
|
||||||
|
partner.CurOrderManager.OnWaybillStatusChanged(bill)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||||
//TODO implement me
|
if orderPrice, err := getOrderPrice(order); err != nil {
|
||||||
panic("implement me")
|
return nil, err
|
||||||
|
} else {
|
||||||
|
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||||
|
deliveryFeeInfo.DeliveryFee = utils.Str2Int64(orderPrice.NeedPayMoney)
|
||||||
|
}
|
||||||
|
return deliveryFeeInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||||
//TODO implement me
|
return fmt.Errorf("UU跑腿暂不支持此操作")
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||||
//TODO implement me
|
waybill, err := api.UuAPI.GetOrderDetail(orderId)
|
||||||
panic("implement me")
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
temp := strings.Split(waybill.DriverLastloc, ",") //格式:113.71776,34.767501
|
||||||
|
param := &mtpsapi.RiderInfo{
|
||||||
|
OrderId: orderId,
|
||||||
|
ThirdCarrierOrderId: waybill.OrderCode,
|
||||||
|
CourierName: waybill.DriverName,
|
||||||
|
CourierPhone: waybill.DriverMobile,
|
||||||
|
LogisticsProviderCode: mtpsapi.UUPTCode,
|
||||||
|
LogisticsStatus: utils.Str2Int(waybill.State),
|
||||||
|
Longitude: temp[0],
|
||||||
|
Latitude: temp[1],
|
||||||
|
}
|
||||||
|
switch waybill.State {
|
||||||
|
case uuptapi.StateConfirmSuccess:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusNew
|
||||||
|
param.LogisticsContext = model.RiderWaitRider
|
||||||
|
case uuptapi.StateRMGrabsOrder:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusCourierAssigned
|
||||||
|
param.LogisticsContext = model.RiderGetOrder
|
||||||
|
case uuptapi.StateArrivedStore:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusCourierArrived
|
||||||
|
param.LogisticsContext = model.RiderToStore
|
||||||
|
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusDelivering
|
||||||
|
param.LogisticsContext = model.RiderGetOrderDelivering
|
||||||
|
case uuptapi.StateReceiverGetGoods:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusDelivered
|
||||||
|
param.LogisticsContext = model.RiderGetOrderDelivered
|
||||||
|
case uuptapi.StateOrderCancel:
|
||||||
|
param.LogisticsStatus = model.WaybillStatusCanceled
|
||||||
|
param.LogisticsContext = model.RiderGetOrderCanceled
|
||||||
|
}
|
||||||
|
return param, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//辅助函数
|
||||||
|
func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceResp, err error) {
|
||||||
|
store, err := dao.GetStoreDetail(dao.GetDB(), order.StoreID, 0, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
address, _, err := dao.QueryUserDeliveryAddress(dao.GetDB(), order.AddressID, nil, 0, 0)
|
||||||
|
if err != nil || len(address) == 0 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
param := map[string]interface{}{
|
||||||
|
"origin_id": order.VendorOrderID,
|
||||||
|
"from_address": store.Address,
|
||||||
|
"to_address": order.ConsigneeAddress,
|
||||||
|
"city_name": address[0].CityName,
|
||||||
|
"send_type": uuptapi.SendTypeHelpMeDeliver,
|
||||||
|
"to_lat": order.ConsigneeLat,
|
||||||
|
"to_lng": order.ConsigneeLng,
|
||||||
|
"from_lat": store.Lat,
|
||||||
|
"from_lng": store.Lng,
|
||||||
|
}
|
||||||
|
if orderPrice, err = api.UuAPI.GetOrderPrice(param); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return orderPrice, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResponse) {
|
||||||
|
param := &model.Waybill{
|
||||||
|
VendorOrderID: req.OriginID,
|
||||||
|
VendorWaybillID: req.OrderCode,
|
||||||
|
WaybillVendorID: model.VendorIDUUPT,
|
||||||
|
CourierName: req.DriverName,
|
||||||
|
CourierMobile: req.DriverMobile,
|
||||||
|
VendorStatus: req.State,
|
||||||
|
StatusTime: time.Now(),
|
||||||
|
Remark: req.StateText,
|
||||||
|
}
|
||||||
|
switch req.State {
|
||||||
|
case uuptapi.StateConfirmSuccess:
|
||||||
|
param.Status = model.WaybillStatusNew //5 待调度
|
||||||
|
case uuptapi.StateRMGrabsOrder:
|
||||||
|
param.Status = model.WaybillStatusCourierAssigned
|
||||||
|
param.Remark = req.DriverName + "," + req.DriverMobile
|
||||||
|
case uuptapi.StateArrivedStore:
|
||||||
|
param.Status = model.WaybillStatusCourierArrived
|
||||||
|
param.Remark = model.RiderToStore
|
||||||
|
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination:
|
||||||
|
param.Status = model.WaybillStatusDelivering
|
||||||
|
param.Remark = model.RiderGetOrderDelivering
|
||||||
|
case uuptapi.StateReceiverGetGoods:
|
||||||
|
param.Status = model.WaybillStatusDelivered
|
||||||
|
param.Remark = model.RiderGetOrderDelivered
|
||||||
|
case uuptapi.StateOrderCancel:
|
||||||
|
param.Status = model.WaybillStatusCanceled
|
||||||
|
param.Remark = model.RiderGetOrderCanceled
|
||||||
|
default:
|
||||||
|
globals.SugarLogger.Warnf("onWaybillMsg unknown State:%v", req.State)
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("UUPT onWaybillMsg param=====%s", utils.Format4Output(param, false))
|
||||||
|
if err := partner.CurOrderManager.OnWaybillStatusChanged(param); err != nil {
|
||||||
|
return uuptapi.Err2CallbackResponse(err)
|
||||||
|
}
|
||||||
|
return uuptapi.Err2CallbackResponse(nil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,30 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
//
|
import (
|
||||||
//import (
|
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
||||||
// "git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/uupt"
|
||||||
// "git.rosy.net.cn/jx-callback/business/partner/delivery/uupt"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
// "git.rosy.net.cn/jx-callback/globals/api"
|
"github.com/astaxie/beego/server/web"
|
||||||
// "github.com/astaxie/beego/server/web"
|
"net/http"
|
||||||
// "net/http"
|
)
|
||||||
//)
|
|
||||||
//
|
type UuPtController struct {
|
||||||
//type UuPtController struct {
|
web.Controller
|
||||||
// web.Controller
|
}
|
||||||
//}
|
|
||||||
//
|
//运单状态回调
|
||||||
////运单状态回调
|
func (c *UuPtController) UuWaybillCallback() {
|
||||||
//func (c *UuPtController) UuWaybillCallback() {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
// if c.Ctx.Input.Method() == http.MethodPost {
|
resp, callbackResponse := api.UuAPI.WaybillCallback(c.Ctx.Request)
|
||||||
// resp, callbackResponse := api.UuAPI.WaybillCallback(c.Ctx.Request)
|
if callbackResponse.ReturnCode == uuptapi.ReturnFail {
|
||||||
// if callbackResponse.ReturnCode == uuptapi.ReturnFail {
|
c.Data["code"] = callbackResponse
|
||||||
// c.Data["code"] = callbackResponse
|
c.ServeJSON()
|
||||||
// c.ServeJSON()
|
return
|
||||||
// return
|
}
|
||||||
// }
|
callbackResponse = uupt.OnWaybillMsg(resp)
|
||||||
// callbackResponse = uupt.OnWaybillMsg(resp)
|
c.Data["code"] = callbackResponse
|
||||||
// c.Data["code"] = callbackResponse
|
c.ServeJSON()
|
||||||
// c.ServeJSON()
|
} else {
|
||||||
// } else {
|
c.Abort("404")
|
||||||
// c.Abort("404")
|
}
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ func init() {
|
|||||||
web.AutoRouter(&controllers.EclpController{})
|
web.AutoRouter(&controllers.EclpController{})
|
||||||
web.AutoRouter(&controllers.JdsController{})
|
web.AutoRouter(&controllers.JdsController{})
|
||||||
web.AutoRouter(&controllers.FnController{})
|
web.AutoRouter(&controllers.FnController{})
|
||||||
|
web.AutoRouter(&controllers.UuPtController{})
|
||||||
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