- 京东门店信息查询相关的三个API返回值改为具体的struct
This commit is contained in:
@@ -58,12 +58,12 @@ func TestBatchUpdateOutSkuId(t *testing.T) {
|
|||||||
|
|
||||||
func TestQuerySkuInfos(t *testing.T) {
|
func TestQuerySkuInfos(t *testing.T) {
|
||||||
pageSize := 20
|
pageSize := 20
|
||||||
result, totalCount, err := api.QuerySkuInfos("", 0, 0, pageSize, true)
|
result, totalCount, err := api.QuerySkuInfos("一个高级商品", 0, 0, pageSize, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(result) != pageSize || totalCount == 0 {
|
if len(result) != pageSize || totalCount == 0 {
|
||||||
baseapi.SugarLogger.Debug(result)
|
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
t.Fatalf("QuerySkuInfos result size is not same as requested:%d", pageSize)
|
t.Fatalf("QuerySkuInfos result size is not same as requested:%d", pageSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,38 @@ type SkuIdEntity struct {
|
|||||||
OutSkuId string `json:"outSkuId"`
|
OutSkuId string `json:"outSkuId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StorePriceInfo struct {
|
||||||
|
MarketPrice int64 `json:"marketPrice"`
|
||||||
|
Pin string `json:"pin"`
|
||||||
|
Price int64 `json:"price"`
|
||||||
|
PromoteVipPrice int64 `json:"promoteVipPrice"`
|
||||||
|
SkuID int64 `json:"skuId"`
|
||||||
|
StationNo string `json:"stationNo"`
|
||||||
|
VenderID string `json:"venderId"`
|
||||||
|
VipPrice int64 `json:"vipPrice"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type QueryStockResponse struct {
|
||||||
|
SkuID int64 `json:"skuId"`
|
||||||
|
StationNo string `json:"stationNo"`
|
||||||
|
UsableQty int `json:"usableQty"`
|
||||||
|
LockQty int `json:"lockQty"`
|
||||||
|
OrderQty int `json:"orderQty"`
|
||||||
|
Vendibility int `json:"vendibility"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateVendibilityResponse struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
CurrentQty int `json:"currentQty"`
|
||||||
|
LockQty int `json:"lockQty"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
OrderQty int `json:"orderQty"`
|
||||||
|
OutSkuID string `json:"outSkuId"`
|
||||||
|
SkuID int64 `json:"skuId"`
|
||||||
|
UsableQty int `json:"usableQty"`
|
||||||
|
Vendibility int `json:"vendibility"`
|
||||||
|
}
|
||||||
|
|
||||||
// 传入为数组的,最多一次为50个
|
// 传入为数组的,最多一次为50个
|
||||||
// 有好些功能有两个类似的函数,一个为到家ID,一个为商家ID,建议都只用商家ID的那个,因为:
|
// 有好些功能有两个类似的函数,一个为到家ID,一个为商家ID,建议都只用商家ID的那个,因为:
|
||||||
// 1,这类函数一般可以批量操作
|
// 1,这类函数一般可以批量操作
|
||||||
@@ -85,16 +117,16 @@ func (a *API) UpdateStationPrice(skuId int64, stationNo string, price int) (stri
|
|||||||
|
|
||||||
// 根据到家商品编码和到家门店编码批量查询商品门店价格信息接口
|
// 根据到家商品编码和到家门店编码批量查询商品门店价格信息接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=205&apiid=21ccd5a00d3a4582b4c9a8ef0ae238fc
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=205&apiid=21ccd5a00d3a4582b4c9a8ef0ae238fc
|
||||||
func (a *API) GetStationInfoList(stationNo string, skuIds []int64) ([]map[string]interface{}, error) {
|
func (a *API) GetStationInfoList(stationNo string, skuIds []int64) (priceInfo []*StorePriceInfo, err error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"skuIds": skuIds,
|
"skuIds": skuIds,
|
||||||
"stationNo": stationNo,
|
"stationNo": stationNo,
|
||||||
}
|
}
|
||||||
result, err := a.AccessAPINoPage("price/getStationInfoList", jdParams, nil, nil, nil)
|
result, err := a.AccessAPINoPage("price/getStationInfoList", jdParams, nil, nil, genNoPageResultParser("code", "detail", "result", "0"))
|
||||||
if err == nil && result != nil {
|
if err == nil && result != nil {
|
||||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
err = utils.Map2StructByJson(result, &priceInfo, false)
|
||||||
}
|
}
|
||||||
return nil, err
|
return priceInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据商家商品编码和商家门店编码批量修改现货库存接口
|
// 根据商家商品编码和商家门店编码批量修改现货库存接口
|
||||||
@@ -174,20 +206,20 @@ func (a *API) BatchUpdateVendibility(outStationNo, stationNo string, stockVendib
|
|||||||
// 根据到家商品编码和门店编码批量查询商品库存及可售状态信息接口
|
// 根据到家商品编码和门店编码批量查询商品库存及可售状态信息接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=200&apiid=bc6ad75e8fd34580856e06b5eb149aad
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=200&apiid=bc6ad75e8fd34580856e06b5eb149aad
|
||||||
// 尽量不用这个接口,用下面那个
|
// 尽量不用这个接口,用下面那个
|
||||||
func (a *API) QueryOpenUseable(listBaseStockCenterRequest []*BaseStockCenterRequest) ([]map[string]interface{}, error) {
|
func (a *API) QueryOpenUseable(listBaseStockCenterRequest []*BaseStockCenterRequest) (stockResponse []*QueryStockResponse, err error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"listBaseStockCenterRequest": listBaseStockCenterRequest,
|
"listBaseStockCenterRequest": listBaseStockCenterRequest,
|
||||||
}
|
}
|
||||||
result, err := a.AccessAPINoPage("stock/queryOpenUseable", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"))
|
result, err := a.AccessAPINoPage("stock/queryOpenUseable", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"))
|
||||||
if err == nil && result != nil {
|
if err == nil && result != nil {
|
||||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
err = utils.Map2StructByJson(result, &stockResponse, false)
|
||||||
}
|
}
|
||||||
return nil, err
|
return stockResponse, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据商家商品编码和门店编码批量查询商品库存及可售状态信息接口
|
// 根据商家商品编码和门店编码批量查询商品库存及可售状态信息接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=200&apiid=ba70316bb84f425f8c088d3c19b2570d
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=200&apiid=ba70316bb84f425f8c088d3c19b2570d
|
||||||
func (a *API) QueryStockCenter(outStationNo string, skuIds []*SkuIdEntity, userPin string) ([]map[string]interface{}, error) {
|
func (a *API) QueryStockCenter(outStationNo string, skuIds []*SkuIdEntity, userPin string) (vendibilityResponse []*UpdateVendibilityResponse, err error) {
|
||||||
jdParams := map[string]interface{}{
|
jdParams := map[string]interface{}{
|
||||||
"outStationNo": outStationNo,
|
"outStationNo": outStationNo,
|
||||||
"skuIds": skuIds,
|
"skuIds": skuIds,
|
||||||
@@ -195,7 +227,7 @@ func (a *API) QueryStockCenter(outStationNo string, skuIds []*SkuIdEntity, userP
|
|||||||
}
|
}
|
||||||
result, err := a.AccessAPINoPage("stock/queryStockCenter", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"))
|
result, err := a.AccessAPINoPage("stock/queryStockCenter", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"))
|
||||||
if err == nil && result != nil {
|
if err == nil && result != nil {
|
||||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
err = utils.Map2StructByJson(result, &vendibilityResponse, false)
|
||||||
}
|
}
|
||||||
return nil, err
|
return vendibilityResponse, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mustExistSkuID = 2017194325
|
mustExistSkuID = 2023747677
|
||||||
mustExistSkuJXID = "21206"
|
mustExistSkuJXID = "5246"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetStationInfoList(t *testing.T) {
|
func TestGetStationInfoList(t *testing.T) {
|
||||||
@@ -17,9 +17,7 @@ func TestGetStationInfoList(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, v := range result {
|
t.Log(utils.Format4Output(result, false))
|
||||||
baseapi.SugarLogger.Debug(v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryOpenUseable(t *testing.T) {
|
func TestQueryOpenUseable(t *testing.T) {
|
||||||
@@ -32,9 +30,7 @@ func TestQueryOpenUseable(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, v := range result {
|
t.Log(utils.Format4Output(result, false))
|
||||||
baseapi.SugarLogger.Debug(v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryStockCenter(t *testing.T) {
|
func TestQueryStockCenter(t *testing.T) {
|
||||||
@@ -46,9 +42,7 @@ func TestQueryStockCenter(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, v := range result {
|
t.Log(utils.Format4Output(result, false))
|
||||||
baseapi.SugarLogger.Debug(v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBatchUpdateVendibility(t *testing.T) {
|
func TestBatchUpdateVendibility(t *testing.T) {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mustExistStoreID = "11738324"
|
mustExistStoreID = "11053496"
|
||||||
mustExistStoreJXID = "100285"
|
mustExistStoreJXID = "2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAllCities(t *testing.T) {
|
func TestGetAllCities(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user