+ jdapi.MaxPageSize4QuerySku, MaxSkuIDsCount4QueryListBySkuIds

This commit is contained in:
gazebo
2019-08-01 10:14:39 +08:00
parent d28c352b3e
commit 9c1182bd7f
3 changed files with 16 additions and 25 deletions

View File

@@ -1,12 +1,10 @@
package jdapi package jdapi
import ( import (
"fmt"
"regexp" "regexp"
"strings" "strings"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
) )
const ( const (
@@ -65,6 +63,8 @@ const (
const ( const (
MaxBatchSize4BatchUpdateOutSkuId = 50 MaxBatchSize4BatchUpdateOutSkuId = 50
MaxPageSize4QuerySku = 50
MaxSkuIDsCount4QueryListBySkuIds = 25
) )
const ( const (
@@ -123,11 +123,11 @@ type CategoryInfo struct {
} }
type CreateByUpcParam struct { type CreateByUpcParam struct {
Upc string UniqueUpc string `json:"uniqueCode"` // 商品UPC码
OutSkuId string OutSku string `json:"outSku"` // 商家商品编码商家系统中唯一编码限1-35字符与到家商品编码一对一对应
Price int // 单位为分 JdPrice string `json:"jdPrice"` // 商家商品价格(单位:元),用于初始商品门店价格,所有的商品门店价格都会初始化成该值。后续修改商品门店价格需要通过价格类接口修改。
ShopCategoryId int64 ShopCategoryID int64 `json:"shopCategoryId"` // 商家店内分类编码,店内分类编码通过查询商家店内分类信息接口获取
IsSale bool IsSale bool `json:"isSale"` // 门店商品可售状态true为可售false为不可售默认为可售。
} }
type CreateByUpcPair struct { type CreateByUpcPair struct {
@@ -152,6 +152,7 @@ type SkuMain struct {
BrandID int64 `json:"brandId"` BrandID int64 `json:"brandId"`
ShopCategories []int64 `json:"shopCategories"` ShopCategories []int64 `json:"shopCategories"`
SkuName string `json:"skuName"` SkuName string `json:"skuName"`
Slogan string `json:"slogan"`
FixedStatus int `json:"fixedStatus"` // 商家商品上下架状态(1:上架;2:下架;4:删除;) FixedStatus int `json:"fixedStatus"` // 商家商品上下架状态(1:上架;2:下架;4:删除;)
FixedUpTime string `json:"fixedUpTime"` FixedUpTime string `json:"fixedUpTime"`
OrgCode int `json:"orgCode"` OrgCode int `json:"orgCode"`
@@ -373,7 +374,7 @@ func (a *API) QuerySkuInfos(queryParam *QuerySkuParam) (skuList []*SkuMain, tota
queryParam.PageNo = 1 queryParam.PageNo = 1
} }
if queryParam.PageSize == 0 { if queryParam.PageSize == 0 {
queryParam.PageSize = 50 queryParam.PageSize = MaxPageSize4QuerySku
} }
result, totalCount, err := a.AccessAPIHavePage("pms/querySkuInfos", utils.Struct2MapByJson(queryParam), nil, nil, nil) result, totalCount, err := a.AccessAPIHavePage("pms/querySkuInfos", utils.Struct2MapByJson(queryParam), nil, nil, nil)
if err == nil { if err == nil {
@@ -575,22 +576,12 @@ func (a *API) GetSpuSaleAttr(outSpuId string) (attrList []map[string]interface{}
return nil, err return nil, err
} }
func (a *API) BatchAddSku(paramList []*CreateByUpcParam) (pairs []*CreateByUpcPair, err error) { func (a *API) BatchAddSku(batchSkuRequestList []*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,
}
}
result, err := a.AccessAPINoPage("PmsSkuMainService/batchAddSku", map[string]interface{}{ result, err := a.AccessAPINoPage("PmsSkuMainService/batchAddSku", map[string]interface{}{
"batchSkuRequestList": batchSkuRequestList, "batchSkuRequestList": batchSkuRequestList,
}, nil, nil, genNoPageResultParser("code", "result", "detail", "0")) }, nil, nil, genNoPageResultParser("code", "result", "detail", "0"))
if err == nil { if err == nil {
globals.SugarLogger.Debug(utils.Format4Output(result, false)) // globals.SugarLogger.Debug(utils.Format4Output(result, false))
// todo 这个API在找不到UPC创建失败时code也是0底层不能判断失败 // todo 这个API在找不到UPC创建失败时code也是0底层不能判断失败
if result2, ok := result.([]interface{}); ok && len(result2) > 0 { if result2, ok := result.([]interface{}); ok && len(result2) > 0 {
detail := utils.Slice2MapSlice(result2) detail := utils.Slice2MapSlice(result2)

View File

@@ -159,10 +159,10 @@ func TestGetSpuSaleAttr(t *testing.T) {
func TestBatchAddSku(t *testing.T) { func TestBatchAddSku(t *testing.T) {
paramList := []*CreateByUpcParam{ paramList := []*CreateByUpcParam{
&CreateByUpcParam{ &CreateByUpcParam{
Upc: "6948939649102", UniqueUpc: "6948939649102",
OutSkuId: "50001", OutSku: "50001",
Price: 213, JdPrice: "2.13",
ShopCategoryId: 4247719, ShopCategoryID: 4247719,
IsSale: true, IsSale: true,
}, },
} }

View File

@@ -25,7 +25,7 @@ func init() {
// prod // prod
// api = New("3c0a05d464c247c19d7ec13accc78605", "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE") // 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) { func handleError(t *testing.T, err error) {