292 lines
15 KiB
Go
292 lines
15 KiB
Go
package ebaiapi
|
||
|
||
import (
|
||
"fmt"
|
||
"git.rosy.net.cn/jx-callback/globals"
|
||
"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 {
|
||
|
||
}
|
||
}
|
||
|
||
var StoreStatus2 = []int64{2233065959, 32267184057, 32267387627, 2267141486, 32267144456, 32267545390, 32267315057, 2233065966, 32267804789, 2233065955, 2233065977, 100000063514, 2233066063, 32267779556, 32267779555, 32267545375, 32267144479, 2233066217, 32267089395, 2233066010, 32267258879, 32267387608, 32267387626, 32267387509, 100000063963, 2233066358, 2233066075, 508415109, 32267088187, 32267630646, 32267315083, 32267184083, 2233066462, 32267697574, 32267387527, 32267034116, 32267715502, 2233066016, 32267387622, 2233066483, 2267121510, 32267630608, 32267630614, 32267545389, 32267315052, 32267358114, 32267144442, 32267545385, 2233065961, 32267387615, 32267387614, 32267387612, 2233066189, 32267387617, 2233065983, 2233066178, 32267144447, 32267258868, 32267388565, 32267034104, 32267034097, 2235330381, 32267387606, 32267387605, 32267034105, 2267081269, 2234560558, 32267184047, 32267779547, 32267184080, 2267030906, 32267358130, 32267387580, 2267081267, 2167002619, 2234549766, 2235330408, 32267089396, 2267092839, 2267121507, 32267387598, 32267387597, 2233066023, 32267034093, 2267092842, 32267258844, 2267141485, 32267715495, 32267388573, 32267034111, 2267121514, 32267315069, 2267121512, 32267258880, 32267034128, 32267387577, 32267387576, 32267034129, 2234778219, 32267089393, 32267630607, 32267089413, 32267358142, 200000081103, 32267630629, 32267144449, 32267089400, 32267089399, 32267089418, 32267144452, 32267089423, 32267387566, 2267141491, 32267105194, 32267105199, 2233065933, 2267092837, 32267105217, 32267105215, 32267674067, 32267387557, 32267144488, 32267708037, 32267387554, 32267387552, 32267144455, 32267144468, 32267144480, 32267144469, 32267144470, 32267184056, 32267184060, 32267387550, 32267804810, 32267184051, 32267358107, 32267184053, 32267387546, 32267184062, 32267184029, 32267184034, 32267258859, 32267144462, 32267184036, 32267184048, 32267184059, 32267387540, 32267184088, 32267184041, 32267184049, 32267184064, 32267184066, 32267184069, 32267184070, 32267184076, 32267184079, 32267804790, 32267258853, 32267258855, 32267258833, 32267258834, 32267258858, 32267387531, 32267258876, 32267034135, 32267258862, 32267258841, 32267258886, 32267258888, 32267258865, 32267184063, 2233066112, 32267258846, 32267315053, 32267258872, 32267258878, 32267258873, 32267184086, 32267315044, 2267141513, 32267315047, 32267387525, 32267387524, 32267315054, 32267315061, 32267315064, 32267315065, 32267315071, 32267315070, 2233066015, 32267315074, 32267315078, 32267630637, 32267630601, 32267358120, 32267184082, 32267315084, 32267105208, 32267387511, 32267358106, 32267358137, 32267184071, 32267387534, 32267387498, 32267358101, 32267358108, 32267779348, 32267387490, 32267697572, 32267387488, 32267401278, 32267715496, 32267545372, 32267387611, 32267388574, 32267388570, 32267545402, 32267545406, 32267545376, 32267545378, 1101809925, 32267144485, 32267545380, 2233066096, 32267545392, 32267545394, 32267674047, 32267630606, 32267545384, 32267630615, 32267630621, 32267630625, 32267387579, 32267387567, 32267674064, 32267358094, 32267753665, 32267387603, 32267655025, 32267697568, 32267655028, 32267655030, 32267630644, 32267655063, 32267742234, 32267674052, 32267184042, 32267655036, 32267630605, 32267655048, 100000048519, 32267674063, 32267655057, 32267715490, 32267630633, 32267674065, 32267674070, 32267697561, 32267674041, 32267674042, 32267804823, 32267779551, 32267674060, 32267630622, 32267674073, 32267674074, 32267674085, 32267697562, 32267697563, 32267697567, 32267715492, 32267697573, 32267715494, 32267715497, 32267715505, 32267742241, 32267742244, 32267742248, 32267315062, 32267742251, 32267742255, 32267742259, 32267742261, 32267753653, 200000081084, 32267779552, 32267779545, 32267753661, 32267779542, 32267779543, 32267779351, 32267779352, 32267779546, 32267144483, 32267779357, 32267779379, 32267804809, 32267779365, 32267779364, 32267779368, 32267779558, 2233066211, 32267804811, 32267387532, 32267358115, 32267804787, 32267358133, 32267804791, 32267804793, 32267630638, 32267804795, 32267655051, 32267545387, 32267804800, 32267630626, 32267804820, 32267804821, 32267804822, 32267812964, 100000048965, 100000045925, 32267812968, 32267715503, 32267812978, 32267804819, 32267655049, 100000063513, 32267697558, 32267804803, 32267742236, 200000095506, 32267742242, 32267674055, 32267715507, 200000090482, 32267674058, 200000080243, 100000048520, 100000052585, 200000081102, 200000072811, 506259859, 200000147130, 100000110402, 100000107526, 100000107370, 506403747, 1101848259, 100000104867, 100000104868, 1101873414, 200000143541, 506325097, 100000190484, 100000190475, 1136712384, 505943419, 100000328381, 506256497, 2122964557, 504797631, 1119844487, 2132151839, 2132873395, 505866454, 506281964, 506643037, 1168718701, 32267545413, 1102408916, 506287807, 506322630, 1112866916, 1110785718, 1109714045, 32267184032, 507377485, 507621023, 1122236598, 1128318613, 1144536493, 1124508293, 1124489923, 508042411, 1127582574, 1128314567, 508400141, 508281125, 1137321209, 508226060, 508415089, 1138084276, 2233066216, 508376256, 1138992552, 1138963763, 1138993841, 2235877567, 508246563, 1138968440, 1139471614, 508417755, 1139781155, 32267358089, 1140171041, 508163472, 1139765248, 1140168573, 508825112, 509005065, 509007554, 1143733509, 1144799169, 509019573, 1145199589, 1145229605, 509151553, 1147319541, 509196413, 1146634644, 509156468, 1144170755, 1147259519, 509371608, 1144562343, 1144141773, 509351958, 509227647, 509317001, 1151235596, 1144307543, 509388035, 509348026, 509163588, 1148999655, 1151231064, 1149127053, 509730365, 509625059, 1137966713, 32267655046, 1151316478, 1151130808, 1151305202, 1151130676, 1155361393, 2233065941, 510004243, 509878603, 510086032, 510322562, 1155331892, 1155432211, 1155537892, 1155478340, 1161746045, 510579703, 1161721135, 1157916361, 511891637, 1157653364, 1176226197, 1149385505, 1164043546, 2233066053, 512276503, 32267674076, 1178316283, 32267779345, 513523362, 514710033}
|
||
var status = map[int]string{1: "休息中", 2: "可预订", 3: "营业中", 4: "停营业"}
|
||
|
||
func TestShopBusStatusGet(t *testing.T) {
|
||
fmt.Println(len(StoreStatus2))
|
||
for _, v := range StoreStatus2 {
|
||
result, err := api.ShopBusStatusGet("", v, PlatformFlagElm)
|
||
if err != nil {
|
||
globals.SugarLogger.Debugf("storeID[%d],%v", v, err)
|
||
} else {
|
||
if result == 4 {
|
||
globals.SugarLogger.Debugf("storeID[%d],%s", v, status[result])
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestShopOpen(t *testing.T) {
|
||
for _, v := range StoreStatus2 {
|
||
err := api.ShopOpen("", v)
|
||
if err != nil {
|
||
globals.SugarLogger.Debugf("%d,%v", v, err)
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
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 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,
|
||
512276503,
|
||
}
|
||
|
||
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))
|
||
}
|