287 lines
9.9 KiB
Go
287 lines
9.9 KiB
Go
package ebaiapi
|
||
|
||
import (
|
||
"fmt"
|
||
"testing"
|
||
"time"
|
||
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
)
|
||
|
||
func TestShopList(t *testing.T) {
|
||
result, err := api.ShopList(SysStatusAll)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|
||
}
|
||
|
||
func TestShopCreate(t *testing.T) {
|
||
result, err := api.ShopCreate(map[string]interface{}{
|
||
"shop_id": "667550",
|
||
"name": "互利超市(金牛区店)",
|
||
"supplier_id": "1486975681715",
|
||
"province": 32,
|
||
"city": 75,
|
||
"county": 698,
|
||
"address": "成都市金牛区二环路北一段8号",
|
||
"phone": 18160030913, // 18980429231,
|
||
"service_phone": 18160030913, //18980429231,
|
||
"ivr_phone": 18160030913, //18048531223,
|
||
"longitude": 104.043677,
|
||
"latitude": 30.692361,
|
||
"shop_logo": "https://image-star.elemecdn.com/pb/dab294b0d3e9fa4b5fa63007ff02d06e98",
|
||
"coord_type": "amap",
|
||
"categorys": []map[string]int{
|
||
map[string]int{
|
||
"category1": 166,
|
||
"category2": 222,
|
||
},
|
||
},
|
||
"business_time": []map[string]string{
|
||
map[string]string{
|
||
"start": "7:00",
|
||
"end": "19:00",
|
||
},
|
||
},
|
||
"business_form_id": 1672214913,
|
||
})
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|
||
}
|
||
|
||
func TestShopGet(t *testing.T) {
|
||
result, err := api.ShopGet2("", 1138456086) //2233065879 ,22267134648
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|
||
|
||
// result, err = api.ShopGet(testShopID, 0)
|
||
// if err != nil {
|
||
// t.Fatal(err)
|
||
// } else {
|
||
// t.Log(utils.Format4Output(result, false))
|
||
// }
|
||
}
|
||
|
||
func TestShopAptitudeGet(t *testing.T) {
|
||
result, err := api.ShopAptitudeGet("", 335768207)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|
||
}
|
||
|
||
func TestShopUpdate(t *testing.T) {
|
||
params := map[string]interface{}{
|
||
"address": "四川省成都市双流区东升街道藏卫路中段21号D区23号",
|
||
"baidu_shop_id": "511574437",
|
||
"business_time": []map[string]string{{"end": "19:30", "start": "07:30"}},
|
||
"ivr_phone": "17366937206",
|
||
"package_box_price": 100,
|
||
"service_phone": "13310841099",
|
||
}
|
||
err := api.ShopUpdate(params)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
|
||
}
|
||
}
|
||
|
||
func TestShopBusStatusGet(t *testing.T) {
|
||
result, err := api.ShopBusStatusGet("", 1157916361, PlatformFlagElm)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(result)
|
||
}
|
||
}
|
||
|
||
func TestShopStatusGet(t *testing.T) {
|
||
result, err := api.ShopStatusGet("", 32267034105)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(result)
|
||
}
|
||
}
|
||
|
||
//todo 修改ebai平台与本地映射
|
||
func TestShopIDBatchUpdate(t *testing.T) {
|
||
var (
|
||
fBaiduShopIDs []string
|
||
fShopIDs []string
|
||
)
|
||
key := map[int64]string{
|
||
509107995: "668893",
|
||
}
|
||
for k, v := range key {
|
||
k1 := utils.Int64ToStr(k)
|
||
remoteRel, err := api.ShopGet2("", k)
|
||
fmt.Sprintf("err====%v", err)
|
||
if remoteRel.ShopID != v {
|
||
fBaiduShopIDs = append(fBaiduShopIDs, k1)
|
||
fShopIDs = append(fShopIDs, v)
|
||
}
|
||
}
|
||
fmt.Sprintf("fBaiduIDs=====%s", fBaiduShopIDs)
|
||
fmt.Sprintf("fBaiduIDs=====%s", fShopIDs)
|
||
err := api.ShopIDBatchUpdate(fBaiduShopIDs, fShopIDs)
|
||
//err := api.ShopIDBatchUpdate([]string{utils.Int2Str(2235877567)}, []string{"100920"})
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
// err = api.ShopIDBatchUpdate([]string{utils.Int2Str(testShopBaiduID)}, []string{testShopID})
|
||
// if err != nil {
|
||
// t.Fatal(err)
|
||
// }
|
||
}
|
||
|
||
func TestSupplierList(t *testing.T) {
|
||
result, err := api.SupplierList()
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
} else {
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|
||
}
|
||
|
||
func TestShopOpen(t *testing.T) {
|
||
vendorStoreID := []int64{
|
||
2233065959, 32267184057, 32267387509, 32267034116, 32267387617, 32267715509, 32267034104, 32267184080, 2167002619, 2235330408, 32267089396, 2267092839, 32267630607, 32267089399, 32267387566, 2267092837, 32267144488, 32267184056, 32267387550, 32267258859, 32267387540, 32267184066, 32267184079, 32267804790, 32267034135, 2233066112, 32267258877, 32267258873, 2267141513, 32267315047, 32267315061, 32267315065, 2233066015, 32267315074, 32267315078, 32267630637, 32267105208, 32267387511, 32267358106, 32267358137, 32267358101, 32267387490, 1101809925, 32267387579, 32267753665, 32267655028, 32267655030, 32267804823, 32267779551, 32267674060, 32267630622, 32267674074, 32267715497, 32267742255, 200000081084, 32267779545, 32267779543, 2233066211, 32267804795, 32267812964, 32267804819, 32267655049, 32267697558, 32267715507, 32267674058, 200000080243, 100000135093, 506325097, 506256497, 504253088, 2125201021, 2125203286, 504878195, 1119844487, 2132873395, 1110785718, 1122087332, 1122236598, 508281125, 1137321209, 508415089, 1138428037, 508376256, 508246563, 1139471614, 1139632027, 509007554, 509019573, 1145229605, 509371608, 1144562343, 1144141773, 509163588, 1149127053, 1149066669, 1151305202, 511696051, 2233065941, 1161721135, 1176226197, 1178316283, 32267779345,
|
||
}
|
||
for _, v := range vendorStoreID {
|
||
err := api.ShopOpen("", v)
|
||
fmt.Println(v)
|
||
if err != nil {
|
||
t.Logf("errr := %v", err)
|
||
}
|
||
time.Sleep(200 * time.Millisecond)
|
||
}
|
||
|
||
}
|
||
|
||
func TestShopClose(t *testing.T) {
|
||
aa := []int64{
|
||
2233065959, 32267184057, 32267387509, 32267034116, 32267387617, 32267715509, 32267034104, 32267184080, 2167002619, 2235330408, 32267089396, 2267092839, 32267630607, 32267089399, 32267387566, 2267092837, 32267144488, 32267184056, 32267387550, 32267258859, 32267387540, 32267184066, 32267184079, 32267804790, 32267034135, 2233066112, 32267258877, 32267258873, 2267141513, 32267315047, 32267315061, 32267315065, 2233066015, 32267315074, 32267315078, 32267630637, 32267105208, 32267387511, 32267358106, 32267358137, 32267358101, 32267387490, 1101809925, 32267387579, 32267753665, 32267655028, 32267655030, 32267804823, 32267779551, 32267674060, 32267630622, 32267674074, 32267715497, 32267742255, 200000081084, 32267779545, 32267779543, 2233066211, 32267804795, 32267812964, 32267804819, 32267655049, 32267697558, 32267715507, 32267674058, 200000080243, 100000135093, 506325097, 506256497, 504253088, 2125201021, 2125203286, 504878195, 1119844487, 2132873395, 1110785718, 1122087332, 1122236598, 508281125, 1137321209, 508415089, 1138428037, 508376256, 508246563, 1139471614, 1139632027, 509007554, 509019573, 1145229605, 509371608, 1144562343, 1144141773, 509163588, 1149127053, 1149066669, 1151305202, 511696051, 2233065941, 1161721135, 1176226197, 1178316283, 32267779345,
|
||
}
|
||
|
||
for i := 0; i < len(aa); i++ {
|
||
err := api.ShopClose("", aa[i])
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
t.Logf("id .......%d", aa[i])
|
||
time.Sleep(1 * time.Second)
|
||
}
|
||
|
||
}
|
||
|
||
func TestShopOffline(t *testing.T) {
|
||
err := api.ShopOffline("", testShopBaiduID)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
|
||
func TestShopAnnouncementSet(t *testing.T) {
|
||
err := api.ShopAnnouncementSet("", testShopBaiduID, "测试公告123")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
|
||
func TestShopAptitudeUpload(t *testing.T) {
|
||
err := api.ShopAptitudeUpload("", 335768207, map[string]interface{}{
|
||
"aptitude": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"type_1": 1,
|
||
"type_2": 101,
|
||
"license_number": "92510106L597085088",
|
||
"license_address": "金牛区二环路北一段8号1(A-2、A-3、A-4)楼",
|
||
"long_term_valid": 1,
|
||
"legal_representative_name": "张应友",
|
||
"license_name": "营业执照",
|
||
"photos": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/c436338a2af4d87e30b770cfc1bb8041.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/c436338a2af4d87e30b770cfc1bb8041.jpg",
|
||
},
|
||
},
|
||
},
|
||
map[string]interface{}{
|
||
"type_1": 2,
|
||
"type_2": 202,
|
||
"license_number": "JY15101060104947(1-1)",
|
||
"license_validdate": "2023-10-09",
|
||
"license_name": "食品经营许可证",
|
||
"license_address": "金牛区二环路北一段8号1(A-2、A-3、A-4)楼",
|
||
"legal_representative_name": "张应友",
|
||
"photos": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/93d2126adfd28350385b5067e2770edf.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/93d2126adfd28350385b5067e2770edf.jpg",
|
||
},
|
||
},
|
||
},
|
||
map[string]interface{}{
|
||
"type_1": 3,
|
||
"type_2": 301,
|
||
"license_number": "510921196608255211",
|
||
"long_term_valid": 1,
|
||
"license_name": "身份证",
|
||
"legal_representative_name": "张应友",
|
||
"photos": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/ebdaf32e771a6c050e397624c3fae369.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/ebdaf32e771a6c050e397624c3fae369.jpg",
|
||
},
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/75fad719d61326cedd73f17b1af6338b.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/75fad719d61326cedd73f17b1af6338b.jpg",
|
||
},
|
||
},
|
||
},
|
||
map[string]interface{}{
|
||
"type_1": 5,
|
||
"type_2": 501,
|
||
"photos": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/53bd1275a8a9cd5898912fa78857f284.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/53bd1275a8a9cd5898912fa78857f284.jpg",
|
||
},
|
||
},
|
||
},
|
||
map[string]interface{}{
|
||
"type_1": 5,
|
||
"type_2": 502,
|
||
"photos": []map[string]interface{}{
|
||
map[string]interface{}{
|
||
"photo_url": "http://image.jxc4.com/image/74c371be5bf39d795cf6c02507e7ca84.jpg",
|
||
"waterprinter_url": "http://image.jxc4.com/image/74c371be5bf39d795cf6c02507e7ca84.jpg",
|
||
},
|
||
},
|
||
},
|
||
},
|
||
})
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
|
||
func TestShopDeliveryinfoGet(t *testing.T) {
|
||
result, err := api.ShopDeliveryinfoGet("", 2233065959)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
t.Log(utils.Format4Output(result, false))
|
||
}
|