京东商城订单初接入
This commit is contained in:
35
business/partner/purchase/jdshop/callback.go
Normal file
35
business/partner/purchase/jdshop/callback.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package jdshop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *jdshopapi.CallBackResult) {
|
||||
fmt.Println("testcallback")
|
||||
// if CurPurchaseHandler != nil {
|
||||
// if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged {
|
||||
// response = CurPurchaseHandler.onStoreStatusChanged(msg)
|
||||
// } else if msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade {
|
||||
// response = CurPurchaseHandler.onNumberDowngrade(msg)
|
||||
// } else {
|
||||
// if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
// jxutils.CallMsgHandler(func() {
|
||||
// switch msg.Cmd {
|
||||
// case mtwmapi.MsgTypeWaybillStatus:
|
||||
// response = CurPurchaseHandler.onWaybillMsg(msg)
|
||||
// default:
|
||||
// response = CurPurchaseHandler.onOrderMsg(msg)
|
||||
// }
|
||||
// }, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
|
||||
// }
|
||||
// /*if msg.Cmd == mtwmapi.MsgTypeOrderRefund || msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund {
|
||||
// utils.CallFuncAsync(func() {
|
||||
// OnFinancialMsg(msg)
|
||||
// })
|
||||
// } */
|
||||
// }
|
||||
// }
|
||||
// return response
|
||||
}
|
||||
@@ -1,6 +1,15 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jdshop"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
@@ -8,15 +17,18 @@ type JdsController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *JdsController) Msg(msgType string) {
|
||||
// c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "")
|
||||
// msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request)
|
||||
// if callbackResponse == nil {
|
||||
// callbackResponse = mtwm.OnCallbackMsg(msg)
|
||||
// if callbackResponse == nil {
|
||||
// callbackResponse = mtwmapi.Err2CallbackResponse(nil, "")
|
||||
// }
|
||||
// }
|
||||
// c.Data["json"] = callbackResponse
|
||||
// c.ServeJSON()
|
||||
func (c *JdsController) Msg() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
ctx := c.Ctx
|
||||
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))
|
||||
call, err := api.JdShopAPI.GetCallbackMsg(ctx.Request)
|
||||
if err == nil {
|
||||
jdshop.OnCallbackMsg(call)
|
||||
}
|
||||
globals.SugarLogger.Debugf("jds callback callbackResponse:%s", utils.Format4Output(call, true))
|
||||
c.Data["json"] = call
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ func init() {
|
||||
beego.AutoRouter(&controllers.Djsw2Controller{})
|
||||
beego.AutoRouter(&controllers.TongLianController{})
|
||||
beego.AutoRouter(&controllers.EclpController{})
|
||||
beego.AutoRouter(&controllers.JdsController{})
|
||||
|
||||
// 如下都是用于检测存活的空接口
|
||||
beego.Any("/", func(ctx *beecontext.Context) {
|
||||
|
||||
Reference in New Issue
Block a user