- 输出京东回调的返回结果

This commit is contained in:
gazebo
2019-05-31 09:51:12 +08:00
parent 3abc670bb4
commit 3e39423369

View File

@@ -34,7 +34,7 @@ func (c *DjswController) orderStatus(isCancelOrder bool) {
if callbackResponse == nil {
callbackResponse = jd.OnOrderMsg(obj)
}
c.Data["json"] = c.transferResponse(callbackResponse)
c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
@@ -87,7 +87,7 @@ func (c *DjswController) PushDeliveryStatus() {
if callbackResponse == nil {
callbackResponse = jd.OnWaybillMsg(obj)
}
c.Data["json"] = c.transferResponse(callbackResponse)
c.Data["json"] = c.transferResponse("PushDeliveryStatus", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
@@ -103,7 +103,7 @@ func (c *DjswController) Token() {
if err == nil {
globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false))
}
c.Data["json"] = c.transferResponse(nil)
c.Data["json"] = c.transferResponse("Token", nil)
c.ServeJSON()
}
@@ -115,7 +115,7 @@ func (c *DjswController) StockIsHave() {
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
callbackResponse = promotion.OnStoreStockMsg(obj)
}
c.Data["json"] = c.transferResponse(callbackResponse)
c.Data["json"] = c.transferResponse("StockIsHave", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
@@ -128,7 +128,7 @@ func (c *DjswController) SinglePromoteCreate() {
if callbackResponse == nil {
callbackResponse = promotion.OnNewPromotionMsg(obj)
}
c.Data["json"] = c.transferResponse(callbackResponse)
c.Data["json"] = c.transferResponse("SinglePromoteCreate", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
@@ -141,20 +141,21 @@ func (c *DjswController) StoreCrud() {
if callbackResponse == nil {
callbackResponse = jd.OnStoreMsg(obj)
}
c.Data["json"] = c.transferResponse(callbackResponse)
c.Data["json"] = c.transferResponse("StoreCrud", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
}
}
func (c *DjswController) transferResponse(inCallbackResponse *jdapi.CallbackResponse) (outCallbackResponse *jdapi.CallbackResponse) {
func (c *DjswController) transferResponse(funcName string, inCallbackResponse *jdapi.CallbackResponse) (outCallbackResponse *jdapi.CallbackResponse) {
if globals.IsCallbackAlwaysReturnSuccess() {
return jdapi.SuccessResponse
}
if inCallbackResponse == nil {
return jdapi.SuccessResponse
}
globals.SugarLogger.Debugf("%s callbackResponse:%s", funcName, utils.Format4Output(inCallbackResponse, true))
return inCallbackResponse
}
@@ -196,6 +197,6 @@ func getUsefulRequest(ctx *context.Context) *http.Request {
}
func (c *DjswController) nullOperation() {
c.Data["json"] = c.transferResponse(nil)
c.Data["json"] = c.transferResponse("nullOperation", nil)
c.ServeJSON()
}