From 9c1182bd7f79b68b771364c44fcca1e36f3acbc9 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 1 Aug 2019 10:14:39 +0800 Subject: [PATCH] + jdapi.MaxPageSize4QuerySku, MaxSkuIDsCount4QueryListBySkuIds --- platformapi/jdapi/sku.go | 31 ++++++++++------------------- platformapi/jdapi/sku_test.go | 8 ++++---- platformapi/mtpsapi/mtpsapi_test.go | 2 +- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/platformapi/jdapi/sku.go b/platformapi/jdapi/sku.go index 14311f7c..06d9be00 100644 --- a/platformapi/jdapi/sku.go +++ b/platformapi/jdapi/sku.go @@ -1,12 +1,10 @@ package jdapi import ( - "fmt" "regexp" "strings" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" ) const ( @@ -65,6 +63,8 @@ const ( const ( MaxBatchSize4BatchUpdateOutSkuId = 50 + MaxPageSize4QuerySku = 50 + MaxSkuIDsCount4QueryListBySkuIds = 25 ) const ( @@ -123,11 +123,11 @@ type CategoryInfo struct { } type CreateByUpcParam struct { - Upc string - OutSkuId string - Price int // 单位为分 - ShopCategoryId int64 - IsSale bool + UniqueUpc string `json:"uniqueCode"` // 商品UPC码 + OutSku string `json:"outSku"` // 商家商品编码,商家系统中唯一编码,限1-35字符,与到家商品编码一对一对应 + JdPrice string `json:"jdPrice"` // 商家商品价格(单位:元),用于初始商品门店价格,所有的商品门店价格都会初始化成该值。后续修改商品门店价格需要通过价格类接口修改。 + ShopCategoryID int64 `json:"shopCategoryId"` // 商家店内分类编码,店内分类编码通过查询商家店内分类信息接口获取 + IsSale bool `json:"isSale"` // 门店商品可售状态,true为可售,false为不可售,默认为可售。 } type CreateByUpcPair struct { @@ -152,6 +152,7 @@ type SkuMain struct { BrandID int64 `json:"brandId"` ShopCategories []int64 `json:"shopCategories"` SkuName string `json:"skuName"` + Slogan string `json:"slogan"` FixedStatus int `json:"fixedStatus"` // 商家商品上下架状态(1:上架;2:下架;4:删除;) FixedUpTime string `json:"fixedUpTime"` OrgCode int `json:"orgCode"` @@ -373,7 +374,7 @@ func (a *API) QuerySkuInfos(queryParam *QuerySkuParam) (skuList []*SkuMain, tota queryParam.PageNo = 1 } if queryParam.PageSize == 0 { - queryParam.PageSize = 50 + queryParam.PageSize = MaxPageSize4QuerySku } result, totalCount, err := a.AccessAPIHavePage("pms/querySkuInfos", utils.Struct2MapByJson(queryParam), nil, nil, nil) if err == nil { @@ -575,22 +576,12 @@ func (a *API) GetSpuSaleAttr(outSpuId string) (attrList []map[string]interface{} return nil, err } -func (a *API) BatchAddSku(paramList []*CreateByUpcParam) (pairs []*CreateByUpcPair, err error) { - batchSkuRequestList := make([]map[string]interface{}, len(paramList)) - for k, v := range paramList { - batchSkuRequestList[k] = map[string]interface{}{ - "uniqueCode": v.Upc, - "outSku": v.OutSkuId, - "jdPrice": fmt.Sprintf("%.2f", float32(v.Price)/100), - "shopCategoryId": v.ShopCategoryId, - "isSale": v.IsSale, - } - } +func (a *API) BatchAddSku(batchSkuRequestList []*CreateByUpcParam) (pairs []*CreateByUpcPair, err error) { result, err := a.AccessAPINoPage("PmsSkuMainService/batchAddSku", map[string]interface{}{ "batchSkuRequestList": batchSkuRequestList, }, nil, nil, genNoPageResultParser("code", "result", "detail", "0")) if err == nil { - globals.SugarLogger.Debug(utils.Format4Output(result, false)) + // globals.SugarLogger.Debug(utils.Format4Output(result, false)) // todo 这个API在找不到UPC创建失败时,code也是0,底层不能判断失败 if result2, ok := result.([]interface{}); ok && len(result2) > 0 { detail := utils.Slice2MapSlice(result2) diff --git a/platformapi/jdapi/sku_test.go b/platformapi/jdapi/sku_test.go index b15f7043..b44cb514 100644 --- a/platformapi/jdapi/sku_test.go +++ b/platformapi/jdapi/sku_test.go @@ -159,10 +159,10 @@ func TestGetSpuSaleAttr(t *testing.T) { func TestBatchAddSku(t *testing.T) { paramList := []*CreateByUpcParam{ &CreateByUpcParam{ - Upc: "6948939649102", - OutSkuId: "50001", - Price: 213, - ShopCategoryId: 4247719, + UniqueUpc: "6948939649102", + OutSku: "50001", + JdPrice: "2.13", + ShopCategoryID: 4247719, IsSale: true, }, } diff --git a/platformapi/mtpsapi/mtpsapi_test.go b/platformapi/mtpsapi/mtpsapi_test.go index ee9fbde6..c8731a7f 100644 --- a/platformapi/mtpsapi/mtpsapi_test.go +++ b/platformapi/mtpsapi/mtpsapi_test.go @@ -25,7 +25,7 @@ func init() { // prod // api = New("3c0a05d464c247c19d7ec13accc78605", "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE") - api.SetCookie("token", "jWQx6ao1-BFeuFg1iOHX207ocrPXlJPY-f41EaF1769C13Gw-irr5QnfQzmZOvOqt99cdN4XdQW0n8wvy-Hl_A") + api.SetCookie("token", "M0p9VatZSeSHfrosD5IViAVl73IcA8mlcuHIV5sG6Zpv83a7JE0wY3t26aEhrrs_MR5gtLSFF1UIkt8HAjaXow") } func handleError(t *testing.T, err error) {