+ jdapi.MaxPageSize4QuerySku, MaxSkuIDsCount4QueryListBySkuIds
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user