From c799328eabef53edeab214f503e49832be1b9e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 17 Nov 2022 13:35:09 +0800 Subject: [PATCH] 1 --- platformapi/jdapi/jdapi.go | 19 +++++++++++++------ platformapi/jdapi/sku.go | 8 -------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/platformapi/jdapi/jdapi.go b/platformapi/jdapi/jdapi.go index 02b9b96d..a1d648ed 100644 --- a/platformapi/jdapi/jdapi.go +++ b/platformapi/jdapi/jdapi.go @@ -7,7 +7,6 @@ import ( "encoding/json" "errors" "fmt" - "git.rosy.net.cn/jx-callback/globals" "net/http" "reflect" "sort" @@ -392,15 +391,23 @@ func (a *API) AccessAPIHavePage(apiStr string, jdParams map[string]interface{}, localJdParams[KeyPageNo] = curPage localJdParams[KeyPageSize] = pageSize jsonResult, err := a.AccessAPI(apiStr, localJdParams) - globals.SugarLogger.Debugf("============jsonResult====%s", utils.Format4Output(jsonResult, false)) - globals.SugarLogger.Debugf("============err====%s", err) if err != nil { return nil, totalCount, err } var data map[string]interface{} - encryptData, err := JDDecodeToData(a.appSecret, jsonResult["encryptData"].(string)) - - if err := utils.UnmarshalUseNumber(encryptData, &data); err != nil { + if jsonResult["encryptData"] != nil { + encryptData, err := JDDecodeToData(a.appSecret, jsonResult["encryptData"].(string)) + if err != nil { + return nil, totalCount, platformapi.ErrResponseDataFormatWrong + } + if err := utils.UnmarshalUseNumber(encryptData, &data); err != nil { + return nil, totalCount, platformapi.ErrResponseDataFormatWrong + } + } else if jsonResult["encryptData"] == nil && jsonResult["data"] != nil { + if err := utils.UnmarshalUseNumber([]byte(jsonResult["data"].(string)), &data); err != nil { + return nil, totalCount, platformapi.ErrResponseDataFormatWrong + } + } else { return nil, totalCount, platformapi.ErrResponseDataFormatWrong } diff --git a/platformapi/jdapi/sku.go b/platformapi/jdapi/sku.go index a02ba662..27d711ef 100644 --- a/platformapi/jdapi/sku.go +++ b/platformapi/jdapi/sku.go @@ -2,7 +2,6 @@ package jdapi import ( "fmt" - "git.rosy.net.cn/jx-callback/globals" "regexp" "strings" @@ -321,7 +320,6 @@ func (a *API) AddShopCategory(pid int64, shopCategoryName string, shopCategoryLe params["createPin"] = utils.GetAPIOperator(userName) } result, err := a.AccessAPINoPage("pms/addShopCategory", params, nil, nil, nil) - globals.SugarLogger.Debugf("========result : %s", utils.Format4Output(result, false)) if err == nil { return (result.(map[string]interface{}))["id"].(string), nil } @@ -338,8 +336,6 @@ func (a *API) QueryCategoriesByOrgCode() (catList []*CategoryInfo, err error) { "SHOP_CATEGORY_LEVEL", "SORT", }), nil, nil, nil) - globals.SugarLogger.Debugf("=========result := %s", utils.Format4Output(result, false)) - globals.SugarLogger.Debugf("=========result := %s", err) if err == nil { return interface2CatList(result, 1, nil), nil } @@ -454,7 +450,6 @@ func (a *API) BatchUpdateOutSkuId(skuInfoList []*SkuIDPair) (failedList []*Batch // https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=e433b95f74524dab91718432c0358977 // pageNo 从1开始 func (a *API) QuerySkuInfos(queryParam *QuerySkuParam) (skuList []*SkuMain, totalCount int, err error) { - globals.SugarLogger.Debugf("============queryParam====%s", utils.Format4Output(queryParam, false)) if queryParam.PageNo <= 0 { queryParam.PageNo = 1 } @@ -462,11 +457,8 @@ func (a *API) QuerySkuInfos(queryParam *QuerySkuParam) (skuList []*SkuMain, tota queryParam.PageSize = MaxPageSize4QuerySku } result, totalCount, err := a.AccessAPIHavePage("pms/querySkuInfos", utils.Struct2MapByJson(queryParam), nil, nil, nil) - globals.SugarLogger.Debugf("============QuerySkuInfos====%s", utils.Format4Output(result, false)) - globals.SugarLogger.Debugf("============QuerySkuInfos====%s", err) if err == nil { err = JdMap2StructByJson(result, &skuList, false) - globals.SugarLogger.Debugf("============JdMap2StructByJson====%s", err) } return skuList, totalCount, err }