- 标准化京东到家门店相关API
This commit is contained in:
@@ -11,6 +11,9 @@ import (
|
||||
const (
|
||||
mustExistStoreID = "11053496"
|
||||
mustExistStoreJXID = "2"
|
||||
|
||||
// mustExistStoreID = "11734851"
|
||||
// mustExistStoreJXID = "100118"
|
||||
)
|
||||
|
||||
func TestGetAllCities(t *testing.T) {
|
||||
@@ -39,56 +42,51 @@ func TestGetStationsByVenderId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outSystemId := result["outSystemId"].(string)
|
||||
if outSystemId != "100285" {
|
||||
baseapi.SugarLogger.Fatalf("outSystemId is not correct, its:%s", outSystemId)
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
if result.OutSystemID != mustExistStoreJXID {
|
||||
baseapi.SugarLogger.Fatalf("outSystemId is not correct, its:%s", result.OutSystemID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldAddress := result["stationAddress"].(string)
|
||||
testAddress := oldAddress + "T"
|
||||
addParams := map[string]interface{}{
|
||||
"stationAddress": testAddress,
|
||||
oldAddress := result.StationAddress
|
||||
params := &OpStoreParams{
|
||||
StationNo: mustExistStoreID,
|
||||
Operator: "test",
|
||||
StationAddress: oldAddress + "T",
|
||||
}
|
||||
err = api.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
err = api.UpdateStoreInfo4Open2(params)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
result, err = api.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
newAddress := result["stationAddress"].(string)
|
||||
if newAddress != testAddress {
|
||||
result, err = api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
newAddress := result.StationAddress
|
||||
if newAddress != params.StationAddress {
|
||||
t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
}
|
||||
|
||||
addParams = map[string]interface{}{
|
||||
"stationAddress": oldAddress,
|
||||
}
|
||||
api.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
params.StationAddress = oldAddress
|
||||
api.UpdateStoreInfo4Open2(params)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetCommentByOrderId(t *testing.T) {
|
||||
testOrderID := int64(822347450000922)
|
||||
result, err := api.GetCommentByOrderId(testOrderID)
|
||||
testOrderID := int64(922520919000622)
|
||||
result, err := api.GetCommentByOrderId2(testOrderID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
gotOrderID := utils.MustInterface2Int64(result["orderId"])
|
||||
if gotOrderID != testOrderID {
|
||||
t.Fatalf("GetCommentByOrderId wrong, gotOrderID:%d", gotOrderID)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
@@ -115,27 +113,27 @@ func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
const testStoreID = "11738152"
|
||||
result, err := api.GetDeliveryRangeByStationNo(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result2, err := api.GetStoreInfoByStationNo(testStoreID)
|
||||
const testStoreID = "11734851"
|
||||
result, err := api.GetDeliveryRangeByStationNo2(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result2, false))
|
||||
deliveryRange := result["deliveryRange"].(string)
|
||||
params := map[string]interface{}{
|
||||
"lng": result2["lng"],
|
||||
"lat": result2["lat"],
|
||||
"coordinateType": 3,
|
||||
"deliveryRangeType": 2,
|
||||
"coordinatePoints": deliveryRange,
|
||||
}
|
||||
err = api.UpdateStoreInfo4Open(testStoreID, "test", params)
|
||||
}
|
||||
|
||||
func TestDisableAutoOrder4AllStores(t *testing.T) {
|
||||
storeIDs, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, storeID := range storeIDs {
|
||||
if storeInfo, err := api.GetStoreInfoByStationNo2(storeID); err == nil {
|
||||
if storeInfo.Yn == 0 && storeInfo.IsAutoOrder == 0 {
|
||||
t.Log(storeID)
|
||||
api.UpdateStoreConfig4Open(storeID, false)
|
||||
}
|
||||
t.Log(utils.Format4Output(storeInfo, false))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user