33 lines
951 B
Go
33 lines
951 B
Go
package controllers
|
||
|
||
import (
|
||
"net/http"
|
||
|
||
"git.rosy.net.cn/baseapi/platformapi/elmapi"
|
||
"git.rosy.net.cn/jx-callback/business/partner/purchase/elm"
|
||
"git.rosy.net.cn/jx-callback/globals/api"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
// Operations about ELMOrder
|
||
type ElemeController struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// https://open.shop.ele.me/openapi/documents/httppushmethod
|
||
func (c *ElemeController) Msg() {
|
||
if c.Ctx.Input.Method() == http.MethodPost {
|
||
obj, callbackResponse := api.ElmAPI.GetCallbackMsg(c.Ctx.Input.RequestBody)
|
||
if callbackResponse == nil {
|
||
callbackResponse = elm.OnCallbackMsg(obj)
|
||
}
|
||
c.Data["json"] = callbackResponse
|
||
c.ServeJSON()
|
||
} else if c.Ctx.Input.Method() == http.MethodGet { // 应用需要支持推送地址的GET访问,当GET请求访问时,请直接返回{“message”:“ok”},用于推送地址的可用性测试。
|
||
c.Data["json"] = elmapi.SuccessResponse
|
||
c.ServeJSON()
|
||
} else {
|
||
c.Abort("404")
|
||
}
|
||
}
|