- 京东到家API回调接口改用http.Request
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
@@ -10,6 +12,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
"github.com/astaxie/beego/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Operations about JDOrder
|
// Operations about JDOrder
|
||||||
@@ -23,10 +26,11 @@ func (c *DjswController) orderStatus(isCancelOrder bool) {
|
|||||||
var callbackResponse *jdapi.CallbackResponse
|
var callbackResponse *jdapi.CallbackResponse
|
||||||
|
|
||||||
if isCancelOrder {
|
if isCancelOrder {
|
||||||
obj, callbackResponse = api.JdAPI.GetOrderApplyCancelCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse = api.JdAPI.GetOrderApplyCancelCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
} else {
|
} else {
|
||||||
obj, callbackResponse = api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse = api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug(utils.Format4Output(obj, false))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
callbackResponse = jd.OnOrderMsg(obj)
|
callbackResponse = jd.OnOrderMsg(obj)
|
||||||
}
|
}
|
||||||
@@ -79,7 +83,7 @@ func (c *DjswController) ApplyCancelOrder() {
|
|||||||
|
|
||||||
func (c *DjswController) PushDeliveryStatus() {
|
func (c *DjswController) PushDeliveryStatus() {
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetOrderDeliveryCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse := api.JdAPI.GetOrderDeliveryCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
callbackResponse = jd.OnWaybillMsg(obj)
|
callbackResponse = jd.OnWaybillMsg(obj)
|
||||||
}
|
}
|
||||||
@@ -106,7 +110,7 @@ func (c *DjswController) Token() {
|
|||||||
func (c *DjswController) StockIsHave() {
|
func (c *DjswController) StockIsHave() {
|
||||||
// globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody))
|
// globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody))
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetStoreStockCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse := api.JdAPI.GetStoreStockCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
|
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
|
||||||
callbackResponse = promotion.OnStoreStockMsg(obj)
|
callbackResponse = promotion.OnStoreStockMsg(obj)
|
||||||
@@ -120,7 +124,7 @@ func (c *DjswController) StockIsHave() {
|
|||||||
|
|
||||||
func (c *DjswController) SinglePromoteCreate() {
|
func (c *DjswController) SinglePromoteCreate() {
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
callbackResponse = promotion.OnNewPromotionMsg(obj)
|
callbackResponse = promotion.OnNewPromotionMsg(obj)
|
||||||
}
|
}
|
||||||
@@ -133,7 +137,7 @@ func (c *DjswController) SinglePromoteCreate() {
|
|||||||
|
|
||||||
func (c *DjswController) StoreCrud() {
|
func (c *DjswController) StoreCrud() {
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
callbackResponse = jd.OnStoreMsg(obj)
|
callbackResponse = jd.OnStoreMsg(obj)
|
||||||
}
|
}
|
||||||
@@ -157,7 +161,7 @@ func (c *DjswController) transferResponse(inCallbackResponse *jdapi.CallbackResp
|
|||||||
func (c *DjswController) afterSaleBillStatus() {
|
func (c *DjswController) afterSaleBillStatus() {
|
||||||
var obj *jdapi.CallbackOrderMsg
|
var obj *jdapi.CallbackOrderMsg
|
||||||
var callbackResponse *jdapi.CallbackResponse
|
var callbackResponse *jdapi.CallbackResponse
|
||||||
obj, callbackResponse = api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
obj, callbackResponse = api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
callbackResponse = jd.OnAfterSaleMsg(obj)
|
callbackResponse = jd.OnAfterSaleMsg(obj)
|
||||||
}
|
}
|
||||||
@@ -176,3 +180,8 @@ func (c *DjswController) AfterSaleBillStatus() {
|
|||||||
func (c *DjswController) OrderAccounting() {
|
func (c *DjswController) OrderAccounting() {
|
||||||
c.afterSaleBillStatus()
|
c.afterSaleBillStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUsefulRequest(ctx *context.Context) *http.Request {
|
||||||
|
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))
|
||||||
|
return ctx.Request
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user