jd fake api

This commit is contained in:
gazebo
2020-01-14 17:34:14 +08:00
parent 2245908e18
commit 23b58f605a
3 changed files with 207 additions and 2 deletions

View File

@@ -0,0 +1,92 @@
package jdapi
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
)
func (a *API) FakeOrderQuery(jdParams map[string]interface{}) (retVal []interface{}, totalCount int, err error) {
retVal, totalCount, err = a.AccessAPIHavePage("order/orderQuery", jdParams, nil, nil, nil)
return retVal, totalCount, err
}
func (a *API) FakeQuerySingleOrder(orderId, deliveryStationNo string) (map[string]interface{}, error) {
jdParams := make(map[string]interface{})
jdParams["orderId"] = orderId
jdParams["deliveryStationNo "] = deliveryStationNo
result, _, err := a.FakeOrderQuery(jdParams)
if err != nil {
return nil, err
}
if len(result) == 0 {
return nil, ErrCanNotFindOrder
}
return result[0].(map[string]interface{}), nil
}
func (a *API) FakeBatchUpdateCurrentQtys(trackInfo, outStationNo, stationNo string, skuStockList []*SkuStock, userPin string) (responseList []*StoreSkuBatchUpdateResponse, err error) {
if (outStationNo == "" && stationNo == "") || (outStationNo != "" && stationNo != "") {
return nil, errors.New("outStationNo and stationNo can not all be empty or have value")
}
jdParams := map[string]interface{}{
"skuStockList": skuStockList,
"userPin": utils.GetAPIOperator(userPin),
}
if outStationNo != "" {
jdParams["outStationNo"] = outStationNo
} else {
jdParams["stationNo"] = stationNo
}
result, err := a.AccessAPINoPage2("stock/batchUpdateCurrentQtys", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"), trackInfo)
if result != nil {
var err2 error
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(skuStockList), err, result, ""); err2 != nil && err == nil {
err = err2
}
}
return responseList, err
}
func (a *API) FakeBatchUpdateVendibility(trackInfo, outStationNo, stationNo string, stockVendibilityList []*StockVendibility, userPin string) (responseList []*StoreSkuBatchUpdateResponse, err error) {
if (outStationNo == "" && stationNo == "") || (outStationNo != "" && stationNo != "") {
return nil, errors.New("outStationNo and stationNo can not all be empty or have value")
}
jdParams := map[string]interface{}{
"stockVendibilityList": stockVendibilityList,
"userPin": utils.GetAPIOperator(userPin),
}
if outStationNo != "" {
jdParams["outStationNo"] = outStationNo
} else {
jdParams["stationNo"] = stationNo
}
// 此函数在全部失败时err仍然返回成功
result, err := a.AccessAPINoPage2("stock/batchUpdateVendibility", jdParams, nil, nil, genNoPageResultParser("retCode", "retMsg", "data", "0"), trackInfo)
if result != nil {
var err2 error
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(stockVendibilityList), err, result, ""); err2 != nil && err == nil {
err = err2
}
}
return responseList, err
}
func (a *API) FakeUpdateVendorStationPrice(trackInfo string, outStationNo, stationNo string, skuPriceInfoList []*SkuPriceInfo) (responseList []*StoreSkuBatchUpdateResponse, err error) {
jdParams := map[string]interface{}{
"skuPriceInfoList": skuPriceInfoList,
}
if outStationNo != "" {
jdParams["outStationNo"] = outStationNo
} else {
jdParams["stationNo"] = stationNo
}
result, err := a.AccessAPINoPage2("price/batchUpdateStationPrice", jdParams, nil, nil, genNoPageResultParser("code", "msg", "result", "0"), trackInfo)
if result != nil {
var err2 error
if responseList, err2 = a.handleBatchOpResult(outStationNo, stationNo, len(skuPriceInfoList), err, result, "json2"); err2 != nil && err == nil {
err = err2
}
}
return responseList, err
}