Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -350,6 +350,9 @@ func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isP
|
|||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
retVal = jsonResult1
|
retVal = jsonResult1
|
||||||
|
if jsonResult1["errno"] == nil {
|
||||||
|
baseapi.SugarLogger.Warnf("ebai AccessStorePage2, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
|
}
|
||||||
code := int(utils.MustInterface2Int64(jsonResult1["errno"]))
|
code := int(utils.MustInterface2Int64(jsonResult1["errno"]))
|
||||||
if code == ResponseCodeSuccess {
|
if code == ResponseCodeSuccess {
|
||||||
if subURL == swithShopURL {
|
if subURL == swithShopURL {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ type OpSkuParam struct {
|
|||||||
IsSale int `json:"-"` // 创建:0,1可售,-1不可售,更新:0忽略,1可售,-1不可售
|
IsSale int `json:"-"` // 创建:0,1可售,-1不可售,更新:0忽略,1可售,-1不可售
|
||||||
DontUseThisFieldDirectlyIsSale bool `json:"isSale"` // 门店商品可售状态(true/false);新建商品时,如果为true,门店商品可售状态初始为可售,如果为false, 门店商品可售状态初始为不可售。后续修改各个门店商品可售状态时,请使用根据京东到家商品编码批量修改门店商品可售状态接口。
|
DontUseThisFieldDirectlyIsSale bool `json:"isSale"` // 门店商品可售状态(true/false);新建商品时,如果为true,门店商品可售状态初始为可售,如果为false, 门店商品可售状态初始为不可售。后续修改各个门店商品可售状态时,请使用根据京东到家商品编码批量修改门店商品可售状态接口。
|
||||||
|
|
||||||
Upc string `json:"upc,omitempty"` // UPC编码(商品条码),限1-35个字符,包装类的商品要求UPC编码必填,且要符合条码编写的校验,否则商品会不予通过,接口返回错误状态码code为10059。
|
Upc string `json:"upcCode,omitempty"` // TODO 老版与新版接口参数不一致,UPC编码(商品条码),限1-35个字符,包装类的商品要求UPC编码必填,且要符合条码编写的校验,否则商品会不予通过,接口返回错误状态码code为10059。
|
||||||
Images []string `json:"images,omitempty"`
|
Images []string `json:"images,omitempty"`
|
||||||
ProductDesc string `json:"productDesc,omitempty"`
|
ProductDesc string `json:"productDesc,omitempty"`
|
||||||
IfViewDesc int `json:"ifViewDesc"`
|
IfViewDesc int `json:"ifViewDesc"`
|
||||||
|
|||||||
@@ -133,6 +133,14 @@ func TestGetProductStatust(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddShopCategory(t *testing.T) {
|
||||||
|
result, err := api.AddShopCategory(0, "hello", 1, 0, "test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(result)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDelShopCategory(t *testing.T) {
|
func TestDelShopCategory(t *testing.T) {
|
||||||
err := api.DelShopCategory(4784689)
|
err := api.DelShopCategory(4784689)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -156,6 +164,32 @@ func TestGetSpuSaleAttr(t *testing.T) {
|
|||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddSku(t *testing.T) {
|
||||||
|
str := `
|
||||||
|
{"brandId":35247,
|
||||||
|
"categoryId":20847,
|
||||||
|
"fixedStatus":1,
|
||||||
|
"ifViewDesc":0,
|
||||||
|
"images":["http://image.jxc4.com/e42be71501d0fbb841743bfb7a9ebbcf.jpg"],
|
||||||
|
"isSale":false,
|
||||||
|
"outSkuId":"29935",
|
||||||
|
"shopCategories":[4247719],
|
||||||
|
"skuName":"黑2龙江冰宝珍珠米10kg/袋",
|
||||||
|
"skuPrice":7245,"traceId":"4414AEAD1CCA11EAB689525400E86DC0,xujianhua","weight":1}
|
||||||
|
`
|
||||||
|
var param *OpSkuParam
|
||||||
|
err := utils.UnmarshalUseNumber([]byte(str), ¶m)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
param.Upc = "6666000029935"
|
||||||
|
result, err := api.AddSku2(param)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
func TestBatchAddSku(t *testing.T) {
|
func TestBatchAddSku(t *testing.T) {
|
||||||
paramList := []*CreateByUpcParam{
|
paramList := []*CreateByUpcParam{
|
||||||
&CreateByUpcParam{
|
&CreateByUpcParam{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
@@ -81,15 +80,14 @@ var (
|
|||||||
ErrStrCallbackSignatureIsWrong = "wrong signature"
|
ErrStrCallbackSignatureIsWrong = "wrong signature"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getClonedData(requestURL *url.URL, r *bytes.Buffer) string {
|
func getClonedData(requestURL *url.URL, data []byte) string {
|
||||||
if strings.Index(requestURL.String(), "uploadImg") >= 0 {
|
if strings.Index(requestURL.String(), "uploadImg") >= 0 {
|
||||||
return "binary content"
|
return "binary content"
|
||||||
}
|
}
|
||||||
retVal := string(r.Bytes())
|
if len(data) > maxDataSizeDontOutput {
|
||||||
if len(retVal) > maxDataSizeDontOutput {
|
|
||||||
return "request data is too large"
|
return "request data is too large"
|
||||||
}
|
}
|
||||||
return retVal
|
return string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefAPIConfig() (conf *APIConfig) {
|
func NewDefAPIConfig() (conf *APIConfig) {
|
||||||
@@ -101,10 +99,16 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
|
|||||||
exceedLimitRetryCount := 0
|
exceedLimitRetryCount := 0
|
||||||
recoverableErrorRetryCount := 0
|
recoverableErrorRetryCount := 0
|
||||||
for {
|
for {
|
||||||
savedBuf := new(bytes.Buffer)
|
var savedBuf []byte
|
||||||
request := handleRequest()
|
request := handleRequest()
|
||||||
if request.Body != nil {
|
if request.Body != nil {
|
||||||
request.Body = ioutil.NopCloser(io.TeeReader(request.Body, savedBuf))
|
savedBuf2, err2 := ioutil.ReadAll(request.Body)
|
||||||
|
if err2 == nil {
|
||||||
|
savedBuf = savedBuf2
|
||||||
|
request.Body = ioutil.NopCloser(bytes.NewReader(savedBuf))
|
||||||
|
} else {
|
||||||
|
baseapi.SugarLogger.Warnf("AccessPlatformAPIWithRetry failed with err:%v", err2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
beginTime := time.Now()
|
beginTime := time.Now()
|
||||||
trackInfo := request.Header.Get(KeyTrackInfo)
|
trackInfo := request.Header.Get(KeyTrackInfo)
|
||||||
|
|||||||
Reference in New Issue
Block a user