- use auto router for callback msg.
- first normal demo api FinishedPickup added.
This commit is contained in:
@@ -1,72 +1,40 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/http"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery/mtps"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/legacy/mtps/controller"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
// Operations about ELMOrder
|
||||
type MTPSOrderController struct {
|
||||
type MtpsController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *MTPSOrderController) URLMapping() {
|
||||
c.Mapping("Status", c.Status)
|
||||
c.Mapping("Except", c.Except)
|
||||
func (c *MtpsController) Status() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
obj, callbackResponse := api.MtpsAPI.GetOrderCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = mtps.OnWaybillMsg(obj)
|
||||
}
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
|
||||
// @Title all msg
|
||||
// @Description create object
|
||||
// @Success 200 {string} models.Object.Id
|
||||
// @Failure 403 body is empty
|
||||
// @router /status [post]
|
||||
func (c *MTPSOrderController) Status() {
|
||||
obj, callbackResponse := api.MtpsAPI.GetOrderCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
cc := &controller.OrderController{}
|
||||
callbackResponse = cc.OrderStatusChanged(obj)
|
||||
}
|
||||
if globals.CallNewMsgHandler {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
utils.CallFuncAsync(func() {
|
||||
mtps.OnWaybillMsg(obj)
|
||||
})
|
||||
} else {
|
||||
callbackResponse = mtps.OnWaybillMsg(obj)
|
||||
}
|
||||
func (c *MtpsController) Except() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
obj, callbackResponse := api.MtpsAPI.GetOrderExceptionCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = mtps.OnWaybillExcept(obj)
|
||||
}
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title all msg test
|
||||
// @Description create object
|
||||
// @Success 200 {string} models.Object.Id
|
||||
// @Failure 403 body is empty
|
||||
// @router /except [Post]
|
||||
func (c *MTPSOrderController) Except() {
|
||||
obj, callbackResponse := api.MtpsAPI.GetOrderExceptionCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
cc := &controller.OrderController{}
|
||||
callbackResponse = cc.OrderException(obj)
|
||||
}
|
||||
if globals.CallNewMsgHandler {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
utils.CallFuncAsync(func() {
|
||||
mtps.OnWaybillExcept(obj)
|
||||
})
|
||||
} else {
|
||||
callbackResponse = mtps.OnWaybillExcept(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user