蜂鸟回到
This commit is contained in:
@@ -3,8 +3,6 @@ package fn
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"github.com/astaxie/beego/client/orm"
|
|
||||||
beego "github.com/astaxie/beego/server/web"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -154,22 +152,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
|||||||
return bill, err
|
return bill, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DeliveryHandler) getMTPSShopID(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
|
||||||
saleStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
|
||||||
storeCourierList, err2 := dao.GetOpenedStoreCouriersByStoreID(db, saleStoreID, model.VendorIDFengNiao)
|
|
||||||
if err = err2; err != nil && err != orm.ErrNoRows {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if len(storeCourierList) == 0 {
|
|
||||||
return "", partner.ErrStoreHaveNoCourier
|
|
||||||
}
|
|
||||||
retVal = storeCourierList[0].VendorStoreID
|
|
||||||
if beego.BConfig.RunMode == "dev" {
|
|
||||||
retVal = "test_0001"
|
|
||||||
}
|
|
||||||
return retVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 预下单获取配送费
|
// 预下单获取配送费
|
||||||
func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||||
preCreateOrder := &fnpsapi.PreCreateOrder{
|
preCreateOrder := &fnpsapi.PreCreateOrder{
|
||||||
@@ -204,6 +186,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
|||||||
return deliveryFeeInfo, err
|
return deliveryFeeInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 订单状态
|
||||||
func OnWaybillMsg(msg map[string]interface{}) (resp *fnpsapi.CallbackResponse) {
|
func OnWaybillMsg(msg map[string]interface{}) (resp *fnpsapi.CallbackResponse) {
|
||||||
order := &model.Waybill{
|
order := &model.Waybill{
|
||||||
VendorWaybillID: utils.Interface2String(msg["open_order_code"]),
|
VendorWaybillID: utils.Interface2String(msg["open_order_code"]),
|
||||||
@@ -253,6 +236,29 @@ func OnWaybillMsg(msg map[string]interface{}) (resp *fnpsapi.CallbackResponse) {
|
|||||||
return fnpsapi.Err2CallbackResponse(nil, "")
|
return fnpsapi.Err2CallbackResponse(nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 异常报备
|
||||||
|
func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
|
||||||
|
return curDeliveryHandler.OnWaybillExcept(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
|
||||||
|
jxutils.CallMsgHandler(func() {
|
||||||
|
order := &model.Waybill{
|
||||||
|
VendorWaybillID: msg.PartnerOrderCode,
|
||||||
|
VendorWaybillID2: utils.Int64ToStr(msg.OrderId),
|
||||||
|
WaybillVendorID: model.VendorIDFengNiao,
|
||||||
|
CourierName: string(msg.CarrierDriverId),
|
||||||
|
CourierMobile: "",
|
||||||
|
Status: model.WaybillStatusUnknown, // todo 这里要再确定一下是否只要收到订单异常消息就只简单当成一个消息
|
||||||
|
VendorStatus: msg.AbnormalCode,
|
||||||
|
StatusTime: utils.Timestamp2Time(msg.AbnormalReportTime),
|
||||||
|
}
|
||||||
|
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.PartnerOrderCode)
|
||||||
|
retVal = fnpsapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), "fn OnWaybillExcept")
|
||||||
|
}, jxutils.ComposeUniversalOrderID(msg.PartnerOrderCode, model.VendorIDFengNiao))
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
// 查询订单配送费
|
// 查询订单配送费
|
||||||
func GetDesiredFee(vendorOrderID string) (desiredFee int64) {
|
func GetDesiredFee(vendorOrderID string) (desiredFee int64) {
|
||||||
if result, err := api.FnAPI.QueryOrder(vendorOrderID); err == nil {
|
if result, err := api.FnAPI.QueryOrder(vendorOrderID); err == nil {
|
||||||
|
|||||||
@@ -3,48 +3,120 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/delivery/fn"
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/fn"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FnController struct {
|
type FnController struct {
|
||||||
web.Controller
|
web.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FnController) Msg() {
|
// 订单状态
|
||||||
//if c.Ctx.Input.Method() == http.MethodPost {
|
func (c *FnController) FnOrderStatus() {
|
||||||
fmt.Println("开始回调==========================")
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
msg, callbackResponse := api.FnAPI.GetChainstoreStatusNotify(c.Ctx.Request)
|
fmt.Println("开始回调订单状态==========================")
|
||||||
fmt.Println("开始回调==========================msg", msg)
|
msg, callbackResponse := api.FnAPI.GetChainstoreStatusNotify(c.Ctx.Request)
|
||||||
fmt.Println("开始回调==========================callbackResponse", callbackResponse)
|
fmt.Println("开始回调订单状态==========================msg", msg)
|
||||||
if callbackResponse.Code != 1 {
|
fmt.Println("开始回调订单状态==========================callbackResponse", callbackResponse)
|
||||||
|
if callbackResponse.Code != 1 {
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单回调
|
||||||
|
if msg["callback_business_type"] != nil {
|
||||||
|
callbackResponse = fn.OnWaybillMsg(msg)
|
||||||
|
}
|
||||||
|
|
||||||
c.Data["json"] = callbackResponse
|
c.Data["json"] = callbackResponse
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch msg["callback_business_type"] {
|
|
||||||
case fnpsapi.ChainstoreStatus: // 门店状态变更回调
|
|
||||||
callbackResponse = fn.OnStoreStatus(msg)
|
|
||||||
break
|
|
||||||
case fnpsapi.AbnormalStatus: // 异常报备回调
|
|
||||||
case fnpsapi.CookingFinishStatus: // 商户出餐回调
|
|
||||||
break
|
|
||||||
case fnpsapi.ChainstoreServiceStatus: // 门店采购服务变更回调
|
|
||||||
break
|
|
||||||
case fnpsapi.NoServiceStatus: // 城市屏蔽区域调整回调通知
|
|
||||||
break
|
|
||||||
case fnpsapi.OrderStatus: // 订单状态回调
|
|
||||||
fn.OnWaybillMsg(msg)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Data["json"] = callbackResponse
|
|
||||||
c.ServeJSON()
|
|
||||||
//} else {
|
|
||||||
c.Abort("404")
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 异常回调
|
||||||
|
func (c *FnController) FnAbnormal() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
fmt.Println("开始回调异常回调==========================")
|
||||||
|
msg, callbackResponse := api.FnAPI.GetChainstoreStatusNotify(c.Ctx.Request)
|
||||||
|
fmt.Println("开始回调异常回调==========================msg", msg)
|
||||||
|
fmt.Println("开始回调异常回调==========================callbackResponse", callbackResponse)
|
||||||
|
if callbackResponse.Code != 1 {
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单回调
|
||||||
|
if msg["callback_business_type"] != nil {
|
||||||
|
data := &fnpsapi.AbnormalReportNotify{}
|
||||||
|
if err := utils.Map2StructByJson(msg, data, true); err != nil {
|
||||||
|
callbackResponse = &fnpsapi.CallbackResponse{Code: -1}
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callbackResponse = fn.OnWaybillExceptFn(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 门店回掉
|
||||||
|
func (c *FnController) FnStoreStatus() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
fmt.Println("开始回调门店回掉==========================")
|
||||||
|
msg, callbackResponse := api.FnAPI.GetChainstoreStatusNotify(c.Ctx.Request)
|
||||||
|
fmt.Println("开始回调门店回掉==========================msg", msg)
|
||||||
|
fmt.Println("开始回调门店回掉==========================callbackResponse", callbackResponse)
|
||||||
|
if callbackResponse.Code != 1 {
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if msg["callback_business_type"] != nil {
|
||||||
|
callbackResponse = fn.OnStoreStatus(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Data["json"] = callbackResponse
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//switch msg["callback_business_type"] {
|
||||||
|
//case fnpsapi.ChainstoreStatus: // 门店状态变更回调
|
||||||
|
//callbackResponse = fn.OnStoreStatus(msg)
|
||||||
|
//break
|
||||||
|
//case fnpsapi.AbnormalStatus: // 异常报备回调
|
||||||
|
//data := &fnpsapi.AbnormalReportNotify{}
|
||||||
|
//if err := utils.Map2StructByJson(msg, data, true); err != nil {
|
||||||
|
//callbackResponse = &fnpsapi.CallbackResponse{Code: -1}
|
||||||
|
//break
|
||||||
|
//}
|
||||||
|
//callbackResponse = fn.OnWaybillExceptFn(data)
|
||||||
|
//break
|
||||||
|
//case fnpsapi.CookingFinishStatus: // 商户出餐回调
|
||||||
|
//break
|
||||||
|
//case fnpsapi.ChainstoreServiceStatus: // 门店采购服务变更回调
|
||||||
|
//break
|
||||||
|
//case fnpsapi.NoServiceStatus: // 城市屏蔽区域调整回调通知
|
||||||
|
//break
|
||||||
|
//case fnpsapi.OrderStatus: // 订单状态回调
|
||||||
|
//callbackResponse = fn.OnWaybillMsg(msg)
|
||||||
|
//break
|
||||||
|
//default:
|
||||||
|
//break
|
||||||
|
//}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ func init() {
|
|||||||
web.AutoRouter(&controllers.FnController{})
|
web.AutoRouter(&controllers.FnController{})
|
||||||
web.AutoRouter(&controllers.KnowUploadController{})
|
web.AutoRouter(&controllers.KnowUploadController{})
|
||||||
web.AutoRouter(&controllers.AliApiController{})
|
web.AutoRouter(&controllers.AliApiController{})
|
||||||
web.AutoRouter(&controllers.BiddingController{})
|
//web.AutoRouter(&controllers.BiddingController{})
|
||||||
|
|
||||||
// 如下都是用于检测存活的空接口
|
// 如下都是用于检测存活的空接口
|
||||||
web.Any("/", func(ctx *beecontext.Context) {
|
web.Any("/", func(ctx *beecontext.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user