From 14b364724d67639f59d45bb326139ebce9340f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 26 Mar 2021 15:12:19 +0800 Subject: [PATCH] aa --- business/partner/purchase/jd/jd.go | 8 ++++++++ controllers/jd_callback.go | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/jd/jd.go b/business/partner/purchase/jd/jd.go index b20207974..4e0ec840e 100644 --- a/business/partner/purchase/jd/jd.go +++ b/business/partner/purchase/jd/jd.go @@ -40,6 +40,14 @@ func GetAPI(appOrgCode string) (apiObj *jdapi.API) { return getAPI(appOrgCode) } +func GetAPIbyKey(appKey string) (apiObj *jdapi.API) { + if code, err := dao.GetVendorOrgCodeByKey(dao.GetDB(), model.VendorIDJD, appKey); err == nil && code != nil { + return jdapi.New(code.Token, code.AppKey, code.AppSecret) + } + globals.SugarLogger.Warnf("GetAPIbyKey appKey:%s get empty vendorOrgCode", appKey) + return nil +} + func AppKey2OrgCode(appKey string) (vendorOrgCode string) { // apiList := partner.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) // for _, v := range apiList { diff --git a/controllers/jd_callback.go b/controllers/jd_callback.go index 0a50203ba..b46eb09bf 100644 --- a/controllers/jd_callback.go +++ b/controllers/jd_callback.go @@ -23,7 +23,7 @@ func (c *DjswController) handleMsg(handler func(*jdapi.API, interface{}) *jdapi. callbackMsg, mapData, callbackResponse := jdapi.GetCallbackMsg(getUsefulRequest(c.Ctx)) globals.SugarLogger.Debug(utils.Format4Output(callbackMsg, true)) if callbackResponse == nil { - if jdAPI := jd.GetAPI(jd.AppKey2OrgCode(callbackMsg.AppKey)); jdAPI != nil { + if jdAPI := jd.GetAPIbyKey(callbackMsg.AppKey); jdAPI != nil { if callbackResponse = jdAPI.CheckCallbackValidation(mapData, callbackMsg.Sign); callbackResponse == nil { callbackResponse = handler(jdAPI, callbackMsg.Param) } @@ -38,7 +38,6 @@ func (c *DjswController) orderStatus() { if c.Ctx.Input.Method() == http.MethodPost { callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { callbackResponse = jd.OnOrderMsg(obj.(*jdapi.CallbackOrderMsg)) - globals.SugarLogger.Debugf("22222", utils.Format4Output(callbackResponse, true)) return callbackResponse }) c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)