- 修复SkuStockUpdateBatch与SkuStockUpdateOne中错误使用PriceString的bug
This commit is contained in:
@@ -450,7 +450,7 @@ func (a *API) SkuPriceUpdateOne(shopID string, priceInfo *ShopSkuInfo) (err erro
|
|||||||
func (a *API) SkuStockUpdateBatch(shopID string, stockList ShopSkuInfoList, skuIDType int) (opResult *BatchOpResult, err error) {
|
func (a *API) SkuStockUpdateBatch(shopID string, stockList ShopSkuInfoList, skuIDType int) (opResult *BatchOpResult, err error) {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
KeyShopID: shopID,
|
KeyShopID: shopID,
|
||||||
stockUpdateKeyIDMap[skuIDType]: stockList.PriceString(skuIDType),
|
stockUpdateKeyIDMap[skuIDType]: stockList.StockString(skuIDType),
|
||||||
}
|
}
|
||||||
result, err := a.AccessAPI("sku.stock.update.batch", params)
|
result, err := a.AccessAPI("sku.stock.update.batch", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -465,7 +465,7 @@ func (a *API) SkuStockUpdateOne(shopID string, stockInfo *ShopSkuInfo) (err erro
|
|||||||
skuIDType := stockInfo.GuessIDType()
|
skuIDType := stockInfo.GuessIDType()
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
KeyShopID: shopID,
|
KeyShopID: shopID,
|
||||||
stockUpdateKeyIDMap[skuIDType]: stockInfo.PriceString(skuIDType),
|
stockUpdateKeyIDMap[skuIDType]: stockInfo.StockString(skuIDType),
|
||||||
}
|
}
|
||||||
_, err = a.AccessAPI("sku.stock.update.one", params)
|
_, err = a.AccessAPI("sku.stock.update.one", params)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ func TestSkuGetItemsByCategoryId(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSkuList(t *testing.T) {
|
func TestSkuList(t *testing.T) {
|
||||||
result, err := api.SkuList("102023", &SkuListParams{
|
result, err := api.SkuList(testShopID, &SkuListParams{
|
||||||
// SkuID: 15579787500720732,
|
SkuID: 156411107107487,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -196,29 +196,66 @@ func TestSkuPriceUpdateBatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSkuStockUpdateBatch(t *testing.T) {
|
func TestSkuStockUpdateBatch(t *testing.T) {
|
||||||
|
const (
|
||||||
|
notExistSkuID = 12345678
|
||||||
|
existSkuID = 156406688807623
|
||||||
|
|
||||||
|
leftNum = 123
|
||||||
|
)
|
||||||
|
|
||||||
opResult, err := api.SkuStockUpdateBatch(testShopID, ShopSkuInfoList{
|
opResult, err := api.SkuStockUpdateBatch(testShopID, ShopSkuInfoList{
|
||||||
&ShopSkuInfo{
|
&ShopSkuInfo{
|
||||||
SkuID: 156291398007698,
|
SkuID: notExistSkuID,
|
||||||
Stock: 2,
|
Stock: leftNum,
|
||||||
},
|
},
|
||||||
&ShopSkuInfo{
|
&ShopSkuInfo{
|
||||||
SkuID: 13121231,
|
SkuID: existSkuID,
|
||||||
Stock: 2,
|
Stock: leftNum,
|
||||||
},
|
|
||||||
&ShopSkuInfo{
|
|
||||||
SkuID: 12321,
|
|
||||||
Stock: 2,
|
|
||||||
},
|
},
|
||||||
}, SkuIDTypeSkuID)
|
}, SkuIDTypeSkuID)
|
||||||
t.Log(utils.Format4Output(opResult, false))
|
t.Log(utils.Format4Output(opResult, false))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("应该要报错才对")
|
t.Fatal("应该要报错才对")
|
||||||
}
|
}
|
||||||
if len(opResult.FailedList) != 3 {
|
if len(opResult.FailedList) != 1 {
|
||||||
t.Fatal("错误列表不正确")
|
t.Fatal("错误列表不正确")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skuInfo, err := api.SkuList(testShopID, &SkuListParams{
|
||||||
|
SkuID: existSkuID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if skuInfo.List[0].LeftNum != leftNum {
|
||||||
|
t.Fatal("设置库存失败")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSkuStockUpdateOne(t *testing.T) {
|
||||||
|
const (
|
||||||
|
notExistSkuID = 12345678
|
||||||
|
existSkuID = 156406688807623
|
||||||
|
|
||||||
|
leftNum = 234
|
||||||
|
)
|
||||||
|
err := api.SkuStockUpdateOne(testShopID, &ShopSkuInfo{
|
||||||
|
SkuID: existSkuID,
|
||||||
|
Stock: leftNum,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
skuInfo, err := api.SkuList(testShopID, &SkuListParams{
|
||||||
|
SkuID: existSkuID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if skuInfo.List[0].LeftNum != leftNum {
|
||||||
|
t.Fatal("设置库存失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
func TestGetEbaiCatIDFromName(t *testing.T) {
|
func TestGetEbaiCatIDFromName(t *testing.T) {
|
||||||
ebaiCatID := api.GetEbaiCatIDFromName("300280", "应季水果新鲜美味")
|
ebaiCatID := api.GetEbaiCatIDFromName("300280", "应季水果新鲜美味")
|
||||||
t.Log(ebaiCatID)
|
t.Log(ebaiCatID)
|
||||||
|
|||||||
Reference in New Issue
Block a user