From 899e0d83626282c9364222c49bed31fdf727ab2b Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Mar 2019 09:40:24 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E8=B0=83=E6=95=B4=E5=88=B0=E5=AE=B6?= =?UTF-8?q?=E2=80=9C=E6=96=B0=E5=A2=9E=E6=88=96=E4=BF=AE=E6=94=B9=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E6=B6=88=E6=81=AF=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jd/jd.go | 6 ++++++ controllers/jd_callback.go | 30 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/business/partner/purchase/jd/jd.go b/business/partner/purchase/jd/jd.go index 6e162e4be..0d9bb948f 100644 --- a/business/partner/purchase/jd/jd.go +++ b/business/partner/purchase/jd/jd.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" + "git.rosy.net.cn/jx-callback/globals" ) var ( @@ -70,3 +71,8 @@ func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) { return 0, 0 } } + +func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { + globals.SugarLogger.Debugf("OnStoreMsg, msg:%s", utils.Format4Output(msg, false)) + return jdapi.Err2CallbackResponse(nil, "") +} diff --git a/controllers/jd_callback.go b/controllers/jd_callback.go index 811bb0725..0b60c4663 100644 --- a/controllers/jd_callback.go +++ b/controllers/jd_callback.go @@ -30,7 +30,7 @@ func (c *DjswController) orderStatus(isCancelOrder bool) { if callbackResponse == nil { callbackResponse = jd.OnOrderMsg(obj) } - c.Data["json"] = callbackResponse + c.Data["json"] = c.transferResponse(callbackResponse) c.ServeJSON() } else { c.Abort("404") @@ -83,7 +83,7 @@ func (c *DjswController) PushDeliveryStatus() { if callbackResponse == nil { callbackResponse = jd.OnWaybillMsg(obj) } - c.Data["json"] = callbackResponse + c.Data["json"] = c.transferResponse(callbackResponse) c.ServeJSON() } else { c.Abort("404") @@ -99,7 +99,7 @@ func (c *DjswController) Token() { if err == nil { globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false)) } - c.Data["json"] = jdapi.Err2CallbackResponse(err, "") + c.Data["json"] = c.transferResponse(nil) c.ServeJSON() } @@ -111,7 +111,7 @@ func (c *DjswController) StockIsHave() { // globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false)) callbackResponse = promotion.OnStoreStockMsg(obj) } - c.Data["json"] = callbackResponse + c.Data["json"] = c.transferResponse(callbackResponse) c.ServeJSON() } else { c.Abort("404") @@ -124,9 +124,29 @@ func (c *DjswController) SinglePromoteCreate() { if callbackResponse == nil { callbackResponse = promotion.OnNewPromotionMsg(obj) } - c.Data["json"] = callbackResponse + c.Data["json"] = c.transferResponse(callbackResponse) c.ServeJSON() } else { c.Abort("404") } } + +func (c *DjswController) StoreCrud() { + if c.Ctx.Input.Method() == http.MethodPost { + obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody) + if callbackResponse == nil { + callbackResponse = jd.OnStoreMsg(obj) + } + c.Data["json"] = c.transferResponse(callbackResponse) + c.ServeJSON() + } else { + c.Abort("404") + } +} + +func (c *DjswController) transferResponse(inCallbackResponse *jdapi.CallbackResponse) (outCallbackResponse *jdapi.CallbackResponse) { + if inCallbackResponse == nil { + return jdapi.Err2CallbackResponse(nil, "") + } + return inCallbackResponse +}