- use auto router for callback msg.
- first normal demo api FinishedPickup added.
This commit is contained in:
@@ -1,49 +1,32 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery/dada"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/legacy/dada/controller"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
// Operations about ELMOrder
|
||||
type DadaOrderController struct {
|
||||
type DadaDeliveryController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *DadaOrderController) URLMapping() {
|
||||
c.Mapping("OrderStatusChanged", c.OrderStatusChanged)
|
||||
}
|
||||
|
||||
// @Title all msg
|
||||
// @Description create object
|
||||
// @Success 200 {string} models.Object.Id
|
||||
// @Failure 403 body is empty
|
||||
// @router /msg [post]
|
||||
func (c *DadaOrderController) OrderStatusChanged() {
|
||||
obj, callbackResponse := api.DadaAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
||||
if callbackResponse == nil {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
cc := &controller.OrderController{}
|
||||
callbackResponse = cc.OrderStatusChanged(obj)
|
||||
func (c *DadaDeliveryController) Msg() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
obj, callbackResponse := api.DadaAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = dada.OnWaybillMsg(obj)
|
||||
}
|
||||
if globals.CallNewMsgHandler {
|
||||
if globals.CallLegacyMsgHandler {
|
||||
utils.CallFuncAsync(func() {
|
||||
dada.OnWaybillMsg(obj)
|
||||
})
|
||||
} else {
|
||||
callbackResponse = dada.OnWaybillMsg(obj)
|
||||
}
|
||||
if callbackResponse != nil && callbackResponse.Code != 200 {
|
||||
c.CustomAbort(callbackResponse.Code, string(utils.MustMarshal(callbackResponse)))
|
||||
} else {
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
}
|
||||
}
|
||||
if callbackResponse != nil && callbackResponse.Code != 200 {
|
||||
c.CustomAbort(callbackResponse.Code, string(utils.MustMarshal(callbackResponse)))
|
||||
} else {
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user