From f2bf95f011e0954b4c98894887079702b43adb87 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Sat, 22 Oct 2022 15:58:07 +0800 Subject: [PATCH] log delete --- platformapi/dadaapi/callback.go | 2 - platformapi/dadaapi/dadaapi_test.go | 337 +++++------ platformapi/dadaapi/order_test.go | 157 ++--- platformapi/dadaapi/shop_test.go | 91 +-- platformapi/ebaiapi/store_page_test.go | 467 +++++++-------- platformapi/ebaiapi/ugc_test.go | 59 +- platformapi/jdapi/sku_test.go | 795 +++++++++++++------------ platformapi/jdapi/store_page_test.go | 645 ++++++++++---------- platformapi/jdapi/store_test.go | 315 +++++----- platformapi/mtwmapi/mtwmapi_test.go | 6 +- platformapi/mtwmapi/order_test.go | 4 +- platformapi/mtwmapi/retail_test.go | 32 +- utils/utils_crypt.go | 3 - 13 files changed, 1457 insertions(+), 1456 deletions(-) diff --git a/platformapi/dadaapi/callback.go b/platformapi/dadaapi/callback.go index f821c964..ae8e4a72 100644 --- a/platformapi/dadaapi/callback.go +++ b/platformapi/dadaapi/callback.go @@ -6,7 +6,6 @@ import ( "sort" "strings" - "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/utils" ) @@ -68,7 +67,6 @@ func (a *API) unmarshalData(data []byte, msg interface{}) (callbackResponse *Cal func (a *API) CheckCallbackValidation(mapData map[string]interface{}) (callbackResponse *CallbackResponse) { sign := a.signCallbackParams(mapData) if remoteSign, _ := mapData[signKey].(string); sign != remoteSign { - baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, remoteSign) return FailedResponse } return nil diff --git a/platformapi/dadaapi/dadaapi_test.go b/platformapi/dadaapi/dadaapi_test.go index 949648f4..0776fcb1 100644 --- a/platformapi/dadaapi/dadaapi_test.go +++ b/platformapi/dadaapi/dadaapi_test.go @@ -1,170 +1,171 @@ package dadaapi -import ( - "net/http" - "testing" - - "git.rosy.net.cn/baseapi" - - "git.rosy.net.cn/baseapi/utils" - "go.uber.org/zap" -) - -var ( - dadaapi *API - sugarLogger *zap.SugaredLogger - testOrder *OperateOrderParams -) - -const ( - testShopNo = "11047059" -) - -func init() { - logger, _ := zap.NewDevelopment() - sugarLogger = logger.Sugar() - baseapi.Init(sugarLogger) - - // sandbox - // dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false) - - // prod - dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true) - - // prod - testOrder = &OperateOrderParams{ - ShopNo: testShopNo, - OriginID: "234242342", - CityCode: "028", - CargoPrice: 12.34, - IsPrepay: 1, - ReceiverName: "我是谁", - ReceiverAddress: "九里堤", - ReceiverLat: 30.74631, - ReceiverLng: 103.99112, - ReceiverPhone: "12812345678", - } - -} - -func TestTest(t *testing.T) { - sugarLogger.Debug(utils.GetCurTimeStr()) -} - -func TestSignCallback(t *testing.T) { - sampleData := `{"signature":"5a277f2519b6011028ff541fb09b8553","client_id":"275000419162381","order_id":"234242342","order_status":1,"cancel_reason":"","cancel_from":0,"dm_id":0,"update_time":1529564947}` - mapData := make(map[string]interface{}) - utils.UnmarshalUseNumber([]byte(sampleData), &mapData) - sign := dadaapi.signCallbackParams(mapData) - if sign != mapData["signature"] { - t.Fatal("sign is not correct") - } -} - -func TestAccessAPI(t *testing.T) { - body := make(map[string]interface{}) - body["order_id"] = "fakeorderid" - result, err := dadaapi.AccessAPI("api/order/status/query", body) - - failed := true - if err != nil { - if err2, ok := err.(*utils.ErrorWithCode); ok { - if err2.IntCode() != ResponseCodeSignErr { - failed = false - } - } - } else { - failed = false - } - - if failed { - t.Fatalf("Error when accessing api result:%v, error:%v", result, err) - } -} - -func TestGetCites(t *testing.T) { - result, err := dadaapi.GetCities() - if err != nil { - t.Fatal(err.Error()) - } - failed := true - for _, city := range result { - if city.CityCode == "028" { - failed = false - } - } - - if failed { - t.Fatal("failed") - } -} - -func TestGetReasons(t *testing.T) { - result, err := dadaapi.GetCancelReasons() - if err != nil { - t.Fatal(err.Error()) - } - // baseapi.SugarLogger.Debug(result) - failed := true - for _, reason := range result { - if reason.ID == 1 { - failed = false - } - } - - if failed { - t.Fatal("failed") - } -} - -func TestAddOrder(t *testing.T) { - result, err := dadaapi.AddOrder(testOrder) - if err != nil { - t.Fatal(err.Error()) - } - baseapi.SugarLogger.Debug(result) -} - -func TestReaddOrder(t *testing.T) { - result, err := dadaapi.ReaddOrder(testOrder) - if err != nil { - t.Fatal(err.Error()) - } - baseapi.SugarLogger.Debug(result) -} - -func TestCancelOrder(t *testing.T) { - result, err := dadaapi.CancelOrder("234242342", ReasonIDClientDontWantItAnymore, "") - if err != nil { - t.Fatal(err.Error()) - } - baseapi.SugarLogger.Debug(result) -} - -func TestCallbackMsgPlayback(t *testing.T) { - baseURL := "http://callback.test.jxc4.com:8080/" - playbackData := [][]string{ - []string{ - "{\"signature\":\"2b10053038eef28af360fa2603d59fd1\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":1,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":0,\"update_time\":1530171995}", - baseURL + "dadadelivery/msg", - }, - []string{ - "{\"signature\":\"14cb9d55179d47de73e09d3b5e800fea\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":2,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530172054}", - baseURL + "dadadelivery/msg", - }, - []string{ - "{\"signature\":\"1058519a18dd8ee8ba6a1638e53bed66\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":3,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530173065}", - baseURL + "dadadelivery/msg", - }, - []string{ - "{\"signature\":\"9c7a5d72d4e9bdea7b452f38e5c5a0dc\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":4,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530173559}", - baseURL + "dadadelivery/msg", - }, - } - for _, v := range playbackData { - _, err := utils.SendFakeRequest(http.MethodPost, v[1], v[0], "application/json; charset=utf-8") - if err != nil { - t.Fatal(err) - } - } -} +// +//import ( +// "net/http" +// "testing" +// +// "git.rosy.net.cn/baseapi" +// +// "git.rosy.net.cn/baseapi/utils" +// "go.uber.org/zap" +//) +// +//var ( +// dadaapi *API +// sugarLogger *zap.SugaredLogger +// testOrder *OperateOrderParams +//) +// +//const ( +// testShopNo = "11047059" +//) +// +//func init() { +// logger, _ := zap.NewDevelopment() +// sugarLogger = logger.Sugar() +// baseapi.Init(sugarLogger) +// +// // sandbox +// // dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false) +// +// // prod +// dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true) +// +// // prod +// testOrder = &OperateOrderParams{ +// ShopNo: testShopNo, +// OriginID: "234242342", +// CityCode: "028", +// CargoPrice: 12.34, +// IsPrepay: 1, +// ReceiverName: "我是谁", +// ReceiverAddress: "九里堤", +// ReceiverLat: 30.74631, +// ReceiverLng: 103.99112, +// ReceiverPhone: "12812345678", +// } +// +//} +// +//func TestTest(t *testing.T) { +// sugarLogger.Debug(utils.GetCurTimeStr()) +//} +// +//func TestSignCallback(t *testing.T) { +// sampleData := `{"signature":"5a277f2519b6011028ff541fb09b8553","client_id":"275000419162381","order_id":"234242342","order_status":1,"cancel_reason":"","cancel_from":0,"dm_id":0,"update_time":1529564947}` +// mapData := make(map[string]interface{}) +// utils.UnmarshalUseNumber([]byte(sampleData), &mapData) +// sign := dadaapi.signCallbackParams(mapData) +// if sign != mapData["signature"] { +// t.Fatal("sign is not correct") +// } +//} +// +//func TestAccessAPI(t *testing.T) { +// body := make(map[string]interface{}) +// body["order_id"] = "fakeorderid" +// result, err := dadaapi.AccessAPI("api/order/status/query", body) +// +// failed := true +// if err != nil { +// if err2, ok := err.(*utils.ErrorWithCode); ok { +// if err2.IntCode() != ResponseCodeSignErr { +// failed = false +// } +// } +// } else { +// failed = false +// } +// +// if failed { +// t.Fatalf("Error when accessing api result:%v, error:%v", result, err) +// } +//} +// +//func TestGetCites(t *testing.T) { +// result, err := dadaapi.GetCities() +// if err != nil { +// t.Fatal(err.Error()) +// } +// failed := true +// for _, city := range result { +// if city.CityCode == "028" { +// failed = false +// } +// } +// +// if failed { +// t.Fatal("failed") +// } +//} +// +//func TestGetReasons(t *testing.T) { +// result, err := dadaapi.GetCancelReasons() +// if err != nil { +// t.Fatal(err.Error()) +// } +// // baseapi.SugarLogger.Debug(result) +// failed := true +// for _, reason := range result { +// if reason.ID == 1 { +// failed = false +// } +// } +// +// if failed { +// t.Fatal("failed") +// } +//} +// +//func TestAddOrder(t *testing.T) { +// result, err := dadaapi.AddOrder(testOrder) +// if err != nil { +// t.Fatal(err.Error()) +// } +// t.Fatal(result) +//} +// +//func TestReaddOrder(t *testing.T) { +// result, err := dadaapi.ReaddOrder(testOrder) +// if err != nil { +// t.Fatal(err.Error()) +// } +// baseapi.SugarLogger.Debug(result) +//} +// +//func TestCancelOrder(t *testing.T) { +// result, err := dadaapi.CancelOrder("234242342", ReasonIDClientDontWantItAnymore, "") +// if err != nil { +// t.Fatal(err.Error()) +// } +// baseapi.SugarLogger.Debug(result) +//} +// +//func TestCallbackMsgPlayback(t *testing.T) { +// baseURL := "http://callback.test.jxc4.com:8080/" +// playbackData := [][]string{ +// []string{ +// "{\"signature\":\"2b10053038eef28af360fa2603d59fd1\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":1,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":0,\"update_time\":1530171995}", +// baseURL + "dadadelivery/msg", +// }, +// []string{ +// "{\"signature\":\"14cb9d55179d47de73e09d3b5e800fea\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":2,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530172054}", +// baseURL + "dadadelivery/msg", +// }, +// []string{ +// "{\"signature\":\"1058519a18dd8ee8ba6a1638e53bed66\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":3,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530173065}", +// baseURL + "dadadelivery/msg", +// }, +// []string{ +// "{\"signature\":\"9c7a5d72d4e9bdea7b452f38e5c5a0dc\",\"client_id\":\"275159553154971\",\"order_id\":\"815433510000122\",\"order_status\":4,\"cancel_reason\":\"\",\"cancel_from\":0,\"dm_id\":4690995,\"dm_name\":\"王杰\",\"dm_mobile\":\"15982842356\",\"update_time\":1530173559}", +// baseURL + "dadadelivery/msg", +// }, +// } +// for _, v := range playbackData { +// _, err := utils.SendFakeRequest(http.MethodPost, v[1], v[0], "application/json; charset=utf-8") +// if err != nil { +// t.Fatal(err) +// } +// } +//} diff --git a/platformapi/dadaapi/order_test.go b/platformapi/dadaapi/order_test.go index cedb079e..6b48788d 100644 --- a/platformapi/dadaapi/order_test.go +++ b/platformapi/dadaapi/order_test.go @@ -1,80 +1,81 @@ package dadaapi -import ( - "fmt" - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -func TestAddOrderAfterQuery(t *testing.T) { - // orderID := utils.GetUUID() - result, err := dadaapi.QueryDeliverFee(&OperateOrderParams{ - ShopNo: "102908", - OriginID: "130652775117000002", - CityCode: "021", - CargoPrice: 0.01, - IsPrepay: 0, - ReceiverName: "某人", - ReceiverAddress: "西南交通大学科技大厦", - ReceiverLng: 121.258651, - ReceiverLat: 31.034611, - ReceiverPhone: "18180948107", - CargoType: 19, - CargoWeight: 3, - }) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) - - // err = dadaapi.AddOrderAfterQuery(result.DeliveryNo) - // if err != nil { - // t.Fatal(err) - // } - - // cancelResponse, err := dadaapi.CancelOrder(orderID, ReasonIDOther, "test") - // if err != nil { - // t.Fatal(err) - // } - // baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) -} - -func TestCancel(t *testing.T) { - cancelResponse, err := dadaapi.CancelOrder("126099099192000002", ReasonIDOther, "协商一致") - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) -} - -func TestGetComplaintReasons(t *testing.T) { - complaintReason, err := dadaapi.GetComplaintReasons() - if err != nil { - t.Fatal(err) - } - fmt.Println(complaintReason) -} - -func TestComplaintRider(t *testing.T) { - err := dadaapi.ComplaintRider("123", 1) - if err != nil { - t.Fatal(err) - } -} - -func TestQueryOrderInfo(t *testing.T) { - result, err := dadaapi.QueryOrderInfo("80704840263399812") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestAddTip(t *testing.T) { - err := dadaapi.AddTip("80704840263399812", 1.0, "530100", "") - if err != nil { - t.Fatal(err) - } -} +// +//import ( +// "fmt" +// "testing" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//func TestAddOrderAfterQuery(t *testing.T) { +// // orderID := utils.GetUUID() +// result, err := dadaapi.QueryDeliverFee(&OperateOrderParams{ +// ShopNo: "102908", +// OriginID: "130652775117000002", +// CityCode: "021", +// CargoPrice: 0.01, +// IsPrepay: 0, +// ReceiverName: "某人", +// ReceiverAddress: "西南交通大学科技大厦", +// ReceiverLng: 121.258651, +// ReceiverLat: 31.034611, +// ReceiverPhone: "18180948107", +// CargoType: 19, +// CargoWeight: 3, +// }) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) +// +// // err = dadaapi.AddOrderAfterQuery(result.DeliveryNo) +// // if err != nil { +// // t.Fatal(err) +// // } +// +// // cancelResponse, err := dadaapi.CancelOrder(orderID, ReasonIDOther, "test") +// // if err != nil { +// // t.Fatal(err) +// // } +// // baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) +//} +// +//func TestCancel(t *testing.T) { +// cancelResponse, err := dadaapi.CancelOrder("126099099192000002", ReasonIDOther, "协商一致") +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) +//} +// +//func TestGetComplaintReasons(t *testing.T) { +// complaintReason, err := dadaapi.GetComplaintReasons() +// if err != nil { +// t.Fatal(err) +// } +// fmt.Println(complaintReason) +//} +// +//func TestComplaintRider(t *testing.T) { +// err := dadaapi.ComplaintRider("123", 1) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestQueryOrderInfo(t *testing.T) { +// result, err := dadaapi.QueryOrderInfo("80704840263399812") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestAddTip(t *testing.T) { +// err := dadaapi.AddTip("80704840263399812", 1.0, "530100", "") +// if err != nil { +// t.Fatal(err) +// } +//} diff --git a/platformapi/dadaapi/shop_test.go b/platformapi/dadaapi/shop_test.go index 87acdab6..f7ff1a15 100644 --- a/platformapi/dadaapi/shop_test.go +++ b/platformapi/dadaapi/shop_test.go @@ -1,47 +1,48 @@ package dadaapi -import ( - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -func TestShopDetail(t *testing.T) { - result, err := dadaapi.ShopDetail("18180948107") - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) -} - -func TestShopAdd(t *testing.T) { - shopInfo := &ShopInfo{ - OriginShopID: "181809481071", - StationName: "京西大本营2", - Business: BusinessTypeFruitVegetable, - CityName: "成都市", - AreaName: "金牛区", - StationAddress: "西南交通大学科技大厦二楼", - Lng: 104.056844, - Lat: 30.695151, - ContactName: "徐先生", - Phone: "18180948107", - } - result, err := dadaapi.ShopAdd(shopInfo) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(result) -} - -func TestShopUpdate(t *testing.T) { - shopInfo := &ShopInfo{ - OriginShopID: "666872", - Status: 1, - } - err := dadaapi.ShopUpdate(shopInfo) - if err != nil { - t.Fatal(err) - } -} +// +//import ( +// "testing" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//func TestShopDetail(t *testing.T) { +// result, err := dadaapi.ShopDetail("18180948107") +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) +//} +// +//func TestShopAdd(t *testing.T) { +// shopInfo := &ShopInfo{ +// OriginShopID: "181809481071", +// StationName: "京西大本营2", +// Business: BusinessTypeFruitVegetable, +// CityName: "成都市", +// AreaName: "金牛区", +// StationAddress: "西南交通大学科技大厦二楼", +// Lng: 104.056844, +// Lat: 30.695151, +// ContactName: "徐先生", +// Phone: "18180948107", +// } +// result, err := dadaapi.ShopAdd(shopInfo) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(result) +//} +// +//func TestShopUpdate(t *testing.T) { +// shopInfo := &ShopInfo{ +// OriginShopID: "666872", +// Status: 1, +// } +// err := dadaapi.ShopUpdate(shopInfo) +// if err != nil { +// t.Fatal(err) +// } +//} diff --git a/platformapi/ebaiapi/store_page_test.go b/platformapi/ebaiapi/store_page_test.go index 80f9c0d6..02886028 100644 --- a/platformapi/ebaiapi/store_page_test.go +++ b/platformapi/ebaiapi/store_page_test.go @@ -1,235 +1,236 @@ package ebaiapi -import ( - "fmt" - "net/http" - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -func TestGetRealMobileNumber4Order(t *testing.T) { - orderId := "5025796789378554068" - desiredMobile := "18483673654" - mobile, err := api.GetRealMobile4Order(orderId) - if err != nil { - t.Fatal(err) - } - if mobile != desiredMobile { - t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile) - } - baseapi.SugarLogger.Debug(mobile) -} - -func TestGetStoreOrderInfo(t *testing.T) { - orderId := "5025796789378554068" - // desiredMobile := "18483673654" - orderInfo, err := api.GetStoreOrderInfo(orderId) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false)) -} - -func TestGetStoreOrderInfoList(t *testing.T) { - orderInfoList, err := api.GetStoreOrderInfoList("2019-02-14 13:00:00", "2019-02-14 15:30:00", "", -1) - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false)) - baseapi.SugarLogger.Debug(len(orderInfoList)) - } -} - -func TestGetEleCommentList(t *testing.T) { - commentList, err := api.GetEleCommentList(utils.Str2Time("2019-09-29 00:00:00"), utils.Str2Time("2019-09-30 23:30:00"), "", "", ReplyStatusAll, CommentLevelAll, CommentContentAll) - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) - baseapi.SugarLogger.Debug(len(commentList)) - } -} - -func TestPageGetSkuList(t *testing.T) { - skuList, err := api.PageGetSkuList(32267350915) - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false)) - } -} - -func TestPageGetCustomSkuList(t *testing.T) { - skuList, err := api.PageGetCustomSkuList(2267121521, 1552729500062) - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false)) - } -} - -func TestPageGetCustomCatList(t *testing.T) { - catList, err := api.PageGetCustomCatList(2233065941) - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(catList, false)) - } -} - -func TestSwitchShop(t *testing.T) { - cookie, err := api.SwitchShop(2233065941) - if err != nil { - t.Fatal(err) - } - t.Log(cookie) -} - -func TestGetShopUserInfo(t *testing.T) { - result, err := api.GetShopUserInfo(32267034127) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetShopHealthByDetail(t *testing.T) { - result, err := api.GetShopHealthByDetail(32267034127) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreList(t *testing.T) { - result, err := api.GetStoreList("104.057218", "30.6949", 0, 0) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreList2(t *testing.T) { - result, err := api.GetStoreList2(104.010554, 30.637072) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreInfo(t *testing.T) { - result, err := api.GetStoreInfo("170879219") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreInfo2(t *testing.T) { - result, err := api.GetStoreInfo2("2233065925") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetShopListIDs(t *testing.T) { - result, total, _ := api.GetShopListByPage(1, 10, 500, 1) - fmt.Println(total) - for _, v := range result { - fmt.Println(v.Name, v.Wid) - } -} - -func TestGetStoresShowWindowSkus(t *testing.T) { - result, _ := api.GetStoresShowWindowSkus(32267089415) - t.Log(utils.Format4Output(result, false)) -} - -func TestGetExianDaSkuDepot(t *testing.T) { - result, err := api.GetExianDaSkuDepot("190600741") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetExianDaSku(t *testing.T) { - result, _ := api.GetExianDaSku(100000000000184645) - t.Log(utils.Format4Output(result, false)) -} - -func TestPageGetSku(t *testing.T) { - result, _ := api.PageGetSku(32267350915, 15813853840796298) - t.Log(utils.Format4Output(result, false)) -} - -func TestGetEbaiDepotSku(t *testing.T) { - result, _ := api.GetEbaiDepotSku(EbaiWholeCountryStore, "190700570") - t.Log(utils.Format4Output(result, false)) -} - -func TestGetEbaiSku(t *testing.T) { - result, _ := api.GetEbaiSku("1578500400097", EbaiWholeCountryStore) - t.Log(utils.Format4Output(result, false)) -} - -func TestGetEbaiShopShareInfo(t *testing.T) { - req, err := http.NewRequest("GET", "https://kong.eleme.cn/h5/C3KHLTXHSEKQ3TGV?_ltraffic_share=clipboard", nil) - req.Header.Set("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") - req.Header.Set("accept-encoding", "gzip, deflate, br") - req.Header.Set("accept-language", "zh-CN,zh;q=0.9") - req.Header.Set("sec-fetch-user", "?1") - req.Header.Set("sec-fetch-dest", "document") - req.Header.Set("sec-fetch-mode", "navigate") - req.Header.Set("sec-fetch-site", "none") - req.Header.Set("upgrade-insecure-requests", "1") - req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36") - client := &http.Client{} - res, err := client.Do(req) - fmt.Println(res.Header) - // err := api.GetEbaiShopShareInfo() - if err != nil { - t.Fatal(err) - } - // t.Log(utils.Format4Output(result, false)) -} - -func TestGetMainActivityList(t *testing.T) { - result, err := api.GetMainActivityList(2233065879) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetMainActivityDetail(t *testing.T) { - result, err := api.GetMainActivityDetail(8134513001) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetSubActivityDetail(t *testing.T) { - result, err := api.GetSubActivityDetail(6136111001) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestModifyShop(t *testing.T) { - err := api.ModifyShop() - if err != nil { - t.Fatal(err) - } - //t.Log(utils.Format4Output(result, false)) -} +// +//import ( +// "fmt" +// "net/http" +// "testing" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//func TestGetRealMobileNumber4Order(t *testing.T) { +// orderId := "5025796789378554068" +// desiredMobile := "18483673654" +// mobile, err := api.GetRealMobile4Order(orderId) +// if err != nil { +// t.Fatal(err) +// } +// if mobile != desiredMobile { +// t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile) +// } +// baseapi.SugarLogger.Debug(mobile) +//} +// +//func TestGetStoreOrderInfo(t *testing.T) { +// orderId := "5025796789378554068" +// // desiredMobile := "18483673654" +// orderInfo, err := api.GetStoreOrderInfo(orderId) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false)) +//} +// +//func TestGetStoreOrderInfoList(t *testing.T) { +// orderInfoList, err := api.GetStoreOrderInfoList("2019-02-14 13:00:00", "2019-02-14 15:30:00", "", -1) +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false)) +// baseapi.SugarLogger.Debug(len(orderInfoList)) +// } +//} +// +//func TestGetEleCommentList(t *testing.T) { +// commentList, err := api.GetEleCommentList(utils.Str2Time("2019-09-29 00:00:00"), utils.Str2Time("2019-09-30 23:30:00"), "", "", ReplyStatusAll, CommentLevelAll, CommentContentAll) +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) +// baseapi.SugarLogger.Debug(len(commentList)) +// } +//} +// +//func TestPageGetSkuList(t *testing.T) { +// skuList, err := api.PageGetSkuList(32267350915) +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false)) +// } +//} +// +//func TestPageGetCustomSkuList(t *testing.T) { +// skuList, err := api.PageGetCustomSkuList(2267121521, 1552729500062) +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false)) +// } +//} +// +//func TestPageGetCustomCatList(t *testing.T) { +// catList, err := api.PageGetCustomCatList(2233065941) +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(catList, false)) +// } +//} +// +//func TestSwitchShop(t *testing.T) { +// cookie, err := api.SwitchShop(2233065941) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(cookie) +//} +// +//func TestGetShopUserInfo(t *testing.T) { +// result, err := api.GetShopUserInfo(32267034127) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetShopHealthByDetail(t *testing.T) { +// result, err := api.GetShopHealthByDetail(32267034127) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreList(t *testing.T) { +// result, err := api.GetStoreList("104.057218", "30.6949", 0, 0) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreList2(t *testing.T) { +// result, err := api.GetStoreList2(104.010554, 30.637072) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreInfo(t *testing.T) { +// result, err := api.GetStoreInfo("170879219") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreInfo2(t *testing.T) { +// result, err := api.GetStoreInfo2("2233065925") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetShopListIDs(t *testing.T) { +// result, total, _ := api.GetShopListByPage(1, 10, 500, 1) +// fmt.Println(total) +// for _, v := range result { +// fmt.Println(v.Name, v.Wid) +// } +//} +// +//func TestGetStoresShowWindowSkus(t *testing.T) { +// result, _ := api.GetStoresShowWindowSkus(32267089415) +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetExianDaSkuDepot(t *testing.T) { +// result, err := api.GetExianDaSkuDepot("190600741") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetExianDaSku(t *testing.T) { +// result, _ := api.GetExianDaSku(100000000000184645) +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestPageGetSku(t *testing.T) { +// result, _ := api.PageGetSku(32267350915, 15813853840796298) +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetEbaiDepotSku(t *testing.T) { +// result, _ := api.GetEbaiDepotSku(EbaiWholeCountryStore, "190700570") +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetEbaiSku(t *testing.T) { +// result, _ := api.GetEbaiSku("1578500400097", EbaiWholeCountryStore) +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetEbaiShopShareInfo(t *testing.T) { +// req, err := http.NewRequest("GET", "https://kong.eleme.cn/h5/C3KHLTXHSEKQ3TGV?_ltraffic_share=clipboard", nil) +// req.Header.Set("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") +// req.Header.Set("accept-encoding", "gzip, deflate, br") +// req.Header.Set("accept-language", "zh-CN,zh;q=0.9") +// req.Header.Set("sec-fetch-user", "?1") +// req.Header.Set("sec-fetch-dest", "document") +// req.Header.Set("sec-fetch-mode", "navigate") +// req.Header.Set("sec-fetch-site", "none") +// req.Header.Set("upgrade-insecure-requests", "1") +// req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36") +// client := &http.Client{} +// res, err := client.Do(req) +// fmt.Println(res.Header) +// // err := api.GetEbaiShopShareInfo() +// if err != nil { +// t.Fatal(err) +// } +// // t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetMainActivityList(t *testing.T) { +// result, err := api.GetMainActivityList(2233065879) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetMainActivityDetail(t *testing.T) { +// result, err := api.GetMainActivityDetail(8134513001) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetSubActivityDetail(t *testing.T) { +// result, err := api.GetSubActivityDetail(6136111001) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestModifyShop(t *testing.T) { +// err := api.ModifyShop() +// if err != nil { +// t.Fatal(err) +// } +// //t.Log(utils.Format4Output(result, false)) +//} diff --git a/platformapi/ebaiapi/ugc_test.go b/platformapi/ebaiapi/ugc_test.go index 6efe59ab..ceb8956e 100644 --- a/platformapi/ebaiapi/ugc_test.go +++ b/platformapi/ebaiapi/ugc_test.go @@ -1,31 +1,32 @@ package ebaiapi -import ( - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -func TestOrderRatesGet(t *testing.T) { - commentList, err := api.OrderRatesGet("102002", 0, utils.Str2Time("2019-09-25"), utils.Str2Time("2019-10-10"), ReplyStatusAll) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) -} - -func TestOrderCommetGet(t *testing.T) { - commentList, err := api.OrderCommetGet("103035", 0, utils.Str2Time("2021-07-01"), utils.Str2Time("2021-07-30"), ReplyStatusAll) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) -} - -func TestOrderRatesReply(t *testing.T) { - err := api.OrderRatesReply("100119", 0, "commentID", "hello") - if err != nil { - t.Fatal(err) - } -} +// +//import ( +// "testing" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//func TestOrderRatesGet(t *testing.T) { +// commentList, err := api.OrderRatesGet("102002", 0, utils.Str2Time("2019-09-25"), utils.Str2Time("2019-10-10"), ReplyStatusAll) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) +//} +// +//func TestOrderCommetGet(t *testing.T) { +// commentList, err := api.OrderCommetGet("103035", 0, utils.Str2Time("2021-07-01"), utils.Str2Time("2021-07-30"), ReplyStatusAll) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) +//} +// +//func TestOrderRatesReply(t *testing.T) { +// err := api.OrderRatesReply("100119", 0, "commentID", "hello") +// if err != nil { +// t.Fatal(err) +// } +//} diff --git a/platformapi/jdapi/sku_test.go b/platformapi/jdapi/sku_test.go index ba198733..78e94dbf 100644 --- a/platformapi/jdapi/sku_test.go +++ b/platformapi/jdapi/sku_test.go @@ -1,399 +1,400 @@ package jdapi -import ( - "fmt" - "testing" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -func TestQueryPageBrandInfo(t *testing.T) { - result, _, err := api.QueryPageBrandInfo(0, 0, 0, "京西") - if err != nil { - t.Fatal(err) - } - if len(result) == 0 { - t.Fatal("QueryPageBrandInfo brand list is empty!") - } - baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) -} - -func TestQueryCategoriesByOrgCode(t *testing.T) { - result, err := api.QueryCategoriesByOrgCode() - if err != nil { - t.Fatal(err) - } - if len(result) == 0 { - t.Fatal("QueryCategoriesByOrgCode category list is empty!") - } -} - -func TestQueryChildCategoriesForOP(t *testing.T) { - result, err := api.QueryChildCategoriesForOP(0) - if err != nil { - t.Fatal(err) - } - if len(result) == 0 { - t.Fatal("QueryChildCategoriesForOP jd category list is empty!") - } -} - -func TestBatchUpdateOutSkuId(t *testing.T) { - result, err := api.BatchUpdateOutSkuId([]*SkuIDPair{ - &SkuIDPair{ - SkuId: 2037664182, - OutSkuId: "", - }, - }) - baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) - if err != nil { - t.Fatal(err) - } -} - -func TestQuerySkuInfos(t *testing.T) { - pageSize := MaxSkuIDsCount4QueryListBySkuIds - pageNo := 1 - var skuList []*SkuMain - for { - result, totalCount, err := api.QuerySkuInfos(&QuerySkuParam{ - PageSize: pageSize, - PageNo: pageNo, - IsFilterDel: IsFilterDelTrue, - }) - if err != nil { - t.Fatal(err) - } - skuList = append(skuList, result...) - if len(skuList) >= totalCount { - break - } - pageNo++ - } - var abnormalSkuList []*SkuMain - for _, v := range skuList { - if len(v.ShopCategories) == 0 { - abnormalSkuList = append(abnormalSkuList, v) - } - } - t.Log(utils.Format4Output(abnormalSkuList, false)) - t.Log(len(abnormalSkuList)) -} - -func TestQueryListBySkuIds(t *testing.T) { - ids := []int64{ - 2018806493, - 2018805873, - } - result, err := api.QueryListBySkuIds(&QueryListBySkuIdsParam{ - SkuIDs: ids, - }) - t.Log(utils.Format4Output(result, false)) - if err != nil { - t.Fatal(err) - } - if len(result) != len(ids) { - baseapi.SugarLogger.Debug(result) - t.Fatalf("QueryListBySkuIds result size is not same as requested:%d", len(ids)) - } -} - -func TestQueryKeyWordDicInfo(t *testing.T) { - result, totalCount, err := api.QueryKeyWordDicInfo(0, 0, "") - if err != nil { - t.Fatal(err) - } - if len(result) == 0 || totalCount == 0 { - t.Fatalf("QueryKeyWordDicInfo size is wrong") - } - // baseapi.SugarLogger.Debug(result[0], totalCount) -} - -func TestSyncProduct(t *testing.T) { - _, err := api.SyncProduct("11734846", "2023346662") - if err != nil { - t.Fatal(err) - } - //baseapi.SugarLogger.Debug(result) - //result, err = api.SyncProduct("wrongstoreid", "2022250244") - //if err == nil { - // t.Fatal("SyncProduct should return error") - //} - //result, err = api.SyncProduct(mustExistStoreID, "wrongskuid") - //if err == nil { - // t.Fatal("SyncProduct should return error") - //} -} - -func TestGetProductStatust(t *testing.T) { - result, err := api.GetProductStatus(mustExistStoreID, "2022250244") - if err != nil || result == nil { - t.Fatal(err) - } - // baseapi.SugarLogger.Debug(result) - result, err = api.GetProductStatus("wrongstoreid", "2022250244") - if err == nil { - t.Fatal("GetProductStatus should return error") - } - result, err = api.GetProductStatus(mustExistStoreID, "wrongskuid") - if err == nil { - t.Fatal("GetProductStatus should return error") - } -} - -func TestAddShopCategory(t *testing.T) { - result, err := api.AddShopCategory(0, "hello", 1, 0, "test") - if err != nil { - t.Fatal(err) - } - t.Log(result) -} - -func TestDelShopCategory(t *testing.T) { - map1 := map[string][][]string{ - "363436": [][]string{ - []string{ - "b922658a-8f07-4932-a616-6a4b5347cf0a", "b5e6b41babba4743ab9c0896b9c6003f", "6511abe10f28405081e4f5a351457c22", - }, - []string{ - "5492150", - "5492148", - "5492146", - }, - }, - "363558": [][]string{ - []string{ - "c91173f4-567b-4bc9-a1e3-a1608407ec9d", "349b0b2156de4fd1adec4f34a5ca7247", "bee0d13695e64d13bb93ac9d50b95f94", - }, - []string{ - "5490060", - "5490053", - "5490056", - }, - }, - "363701": [][]string{ - []string{ - "3e21445d-ac39-428e-866c-69dca7b95ddc", "2148e08b14444b73bb04ee8dae4217ac", "7f541ab195934c109b8eee7a56b6f58d", - }, - []string{ - "5498539", - "5498535", - "5498536", - }, - }, - "363739": [][]string{ - []string{ - "fdb687b1-8e0a-4072-b251-04ef6d7a1a92", "218c544106e84cb08cbeed186c0d5bac", "fdd384a632354f189abce33f5a32ea14", - }, - []string{ - "5498692", - "5498688", - "5498689", - }, - }, - "363786": [][]string{ - []string{ - "098c8550-cfe7-4820-91fa-1bbf63ed9b20", "a396d930904047738dc70b6d2eb54e2d", "262f4656f16a48ed94003a1f261cd7d3", - }, - []string{ - "5499968", - "5499966", - "5499964", - }, - }, - "363788": [][]string{ - []string{ - "9b78cbb9-b956-4820-9b2f-330daaed2828", "5ecd3d4b65b44c9f9f820af232110f20", "63b0d12d32734334bf8c95d43e396035", - }, - []string{ - "5500121", - "5500123", - "5500120", - }, - }, - "363892": [][]string{ - []string{ - "163a032f-72df-44c9-a405-b7675e68d2a6", "f40e9fc714e741359c8fc4f2a1ea9e59", "e486c09cfded4fe3a15ee1cff546155f", - }, - []string{ - "5502844", - "5502840", - "5502842", - }, - }, - "363894": [][]string{ - []string{ - "840b4a7c-5b9a-40fc-95e8-e53b56573565", "fbeeef71305c46f192979ca6a00d380c", "feeec4ccf24744d892c4e892f5978847", - }, - []string{ - "5503000", - "5502996", - "5502997", - }, - }, - "363896": [][]string{ - []string{ - "064ee734-e819-455b-b4c4-cc5ee21c6b2f", "ab938148ff0444eba773a7851029d082", "8f659292e639499ca41d39476fc9c2df", - }, - []string{ - "5503152", - "5503150", - "5503151", - }, - }, - } - for _, v := range map1 { - apijd := New(v[0][0], v[0][1], v[0][2]) - for _, vv := range v[1] { - apijd.DelShopCategory(utils.Str2Int64(vv)) - } - } - // err := api.DelShopCategory(5496926) - // if err != nil { - // t.Fatal(err) - // } -} - -func TestGetSkuSaleAttrName(t *testing.T) { - result, err := api.GetSkuSaleAttrName() - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetSpuSaleAttr(t *testing.T) { - result, err := api.GetSpuSaleAttr("3628") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestAddSku(t *testing.T) { - str := ` - {"brandId":35247, - "categoryId":20847, - "fixedStatus":1, - "ifViewDesc":0, - "images":["http://image.jxc4.com/e42be71501d0fbb841743bfb7a9ebbcf.jpg"], - "isSale":false, - "outSkuId":"123", - "shopCategories":[4247719], - "skuName":"黑3龙江冰宝珍珠米10kg/袋", - "skuPrice":7245,"traceId":"4414AEAD1CCA11EAB689525400E86DC0,xujianhua","weight":1} - ` - var param *OpSkuParam - err := utils.UnmarshalUseNumber([]byte(str), ¶m) - if err != nil { - t.Fatal(err) - } - param.Upc = "66660003446710" - result, err := api.AddSku2(param) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestBatchAddSku(t *testing.T) { - paramList := []*CreateByUpcParam{ - &CreateByUpcParam{ - UniqueUpc: "6948939649102", - OutSku: "50001", - JdPrice: "2.13", - ShopCategoryID: 4247719, - IsSale: true, - }, - } - result, err := api.BatchAddSku(paramList) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetSpuStatus(t *testing.T) { - result, err := api.GetSpuStatus("8515") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetSkuStatus(t *testing.T) { - result, err := api.GetSkuStatus("6092943") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestUpdateSpuSaleAttr(t *testing.T) { - err := api.UpdateSpuSaleAttr("3628", "1001", "", "10", "hello") - if err != nil { - t.Fatal(err) - } -} - -func TestUpdateSpu(t *testing.T) { - err := api.UpdateSpu("8620", nil) - if err != nil { - t.Fatal(err) - } -} - -func TestUpdateSku(t *testing.T) { - _, err := api.UpdateSku("27379", map[string]interface{}{ - "upc": "ttld20190712", - }) - if err != nil { - t.Fatal(err) - } -} - -func TestUpdateShopCategory(t *testing.T) { - err := api.UpdateShopCategory(4760208, "中秋必抢🍳") - if err != nil { - t.Fatal(err) - } -} - -func TestQueren(t *testing.T) { - for i := 1; i < 85; i++ { - result, _, _ := api.QuerySkuInfos(&QuerySkuParam{ - PageNo: i, - }) - fmt.Println(i) - for _, v := range result { - api.UpdateSku2(&OpSkuParam{ - TraceID: utils.GetUUID(), - OutSkuID: v.OutSkuID, - }) - } - } - - // result, _, err := api.QuerySkuInfos(&QuerySkuParam{ - // PageNo: 1, - // }) - // if err != nil { - // t.Fatal(err) - // } - // t.Log(utils.Format4Output(result, false)) -} - -func TestBatchAddSkuByUPC(t *testing.T) { - result, err := api.BatchAddSkuByUPC([]*CreateByUpcParam2{ - &CreateByUpcParam2{ - OutSkuId: "6048265", - Upc: "6911672042530", - JdPrice: "29800", - ShopCategoryID: 5485102, - }, - }) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} +// +//import ( +// "fmt" +// "testing" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//func TestQueryPageBrandInfo(t *testing.T) { +// result, _, err := api.QueryPageBrandInfo(0, 0, 0, "京西") +// if err != nil { +// t.Fatal(err) +// } +// if len(result) == 0 { +// t.Fatal("QueryPageBrandInfo brand list is empty!") +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) +//} +// +//func TestQueryCategoriesByOrgCode(t *testing.T) { +// result, err := api.QueryCategoriesByOrgCode() +// if err != nil { +// t.Fatal(err) +// } +// if len(result) == 0 { +// t.Fatal("QueryCategoriesByOrgCode category list is empty!") +// } +//} +// +//func TestQueryChildCategoriesForOP(t *testing.T) { +// result, err := api.QueryChildCategoriesForOP(0) +// if err != nil { +// t.Fatal(err) +// } +// if len(result) == 0 { +// t.Fatal("QueryChildCategoriesForOP jd category list is empty!") +// } +//} +// +//func TestBatchUpdateOutSkuId(t *testing.T) { +// result, err := api.BatchUpdateOutSkuId([]*SkuIDPair{ +// &SkuIDPair{ +// SkuId: 2037664182, +// OutSkuId: "", +// }, +// }) +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestQuerySkuInfos(t *testing.T) { +// pageSize := MaxSkuIDsCount4QueryListBySkuIds +// pageNo := 1 +// var skuList []*SkuMain +// for { +// result, totalCount, err := api.QuerySkuInfos(&QuerySkuParam{ +// PageSize: pageSize, +// PageNo: pageNo, +// IsFilterDel: IsFilterDelTrue, +// }) +// if err != nil { +// t.Fatal(err) +// } +// skuList = append(skuList, result...) +// if len(skuList) >= totalCount { +// break +// } +// pageNo++ +// } +// var abnormalSkuList []*SkuMain +// for _, v := range skuList { +// if len(v.ShopCategories) == 0 { +// abnormalSkuList = append(abnormalSkuList, v) +// } +// } +// t.Log(utils.Format4Output(abnormalSkuList, false)) +// t.Log(len(abnormalSkuList)) +//} +// +//func TestQueryListBySkuIds(t *testing.T) { +// ids := []int64{ +// 2018806493, +// 2018805873, +// } +// result, err := api.QueryListBySkuIds(&QueryListBySkuIdsParam{ +// SkuIDs: ids, +// }) +// t.Log(utils.Format4Output(result, false)) +// if err != nil { +// t.Fatal(err) +// } +// if len(result) != len(ids) { +// baseapi.SugarLogger.Debug(result) +// t.Fatalf("QueryListBySkuIds result size is not same as requested:%d", len(ids)) +// } +//} +// +//func TestQueryKeyWordDicInfo(t *testing.T) { +// result, totalCount, err := api.QueryKeyWordDicInfo(0, 0, "") +// if err != nil { +// t.Fatal(err) +// } +// if len(result) == 0 || totalCount == 0 { +// t.Fatalf("QueryKeyWordDicInfo size is wrong") +// } +// // baseapi.SugarLogger.Debug(result[0], totalCount) +//} +// +//func TestSyncProduct(t *testing.T) { +// _, err := api.SyncProduct("11734846", "2023346662") +// if err != nil { +// t.Fatal(err) +// } +// //baseapi.SugarLogger.Debug(result) +// //result, err = api.SyncProduct("wrongstoreid", "2022250244") +// //if err == nil { +// // t.Fatal("SyncProduct should return error") +// //} +// //result, err = api.SyncProduct(mustExistStoreID, "wrongskuid") +// //if err == nil { +// // t.Fatal("SyncProduct should return error") +// //} +//} +// +//func TestGetProductStatust(t *testing.T) { +// result, err := api.GetProductStatus(mustExistStoreID, "2022250244") +// if err != nil || result == nil { +// t.Fatal(err) +// } +// // baseapi.SugarLogger.Debug(result) +// result, err = api.GetProductStatus("wrongstoreid", "2022250244") +// if err == nil { +// t.Fatal("GetProductStatus should return error") +// } +// result, err = api.GetProductStatus(mustExistStoreID, "wrongskuid") +// if err == nil { +// t.Fatal("GetProductStatus should return error") +// } +//} +// +//func TestAddShopCategory(t *testing.T) { +// result, err := api.AddShopCategory(0, "hello", 1, 0, "test") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(result) +//} +// +//func TestDelShopCategory(t *testing.T) { +// map1 := map[string][][]string{ +// "363436": [][]string{ +// []string{ +// "b922658a-8f07-4932-a616-6a4b5347cf0a", "b5e6b41babba4743ab9c0896b9c6003f", "6511abe10f28405081e4f5a351457c22", +// }, +// []string{ +// "5492150", +// "5492148", +// "5492146", +// }, +// }, +// "363558": [][]string{ +// []string{ +// "c91173f4-567b-4bc9-a1e3-a1608407ec9d", "349b0b2156de4fd1adec4f34a5ca7247", "bee0d13695e64d13bb93ac9d50b95f94", +// }, +// []string{ +// "5490060", +// "5490053", +// "5490056", +// }, +// }, +// "363701": [][]string{ +// []string{ +// "3e21445d-ac39-428e-866c-69dca7b95ddc", "2148e08b14444b73bb04ee8dae4217ac", "7f541ab195934c109b8eee7a56b6f58d", +// }, +// []string{ +// "5498539", +// "5498535", +// "5498536", +// }, +// }, +// "363739": [][]string{ +// []string{ +// "fdb687b1-8e0a-4072-b251-04ef6d7a1a92", "218c544106e84cb08cbeed186c0d5bac", "fdd384a632354f189abce33f5a32ea14", +// }, +// []string{ +// "5498692", +// "5498688", +// "5498689", +// }, +// }, +// "363786": [][]string{ +// []string{ +// "098c8550-cfe7-4820-91fa-1bbf63ed9b20", "a396d930904047738dc70b6d2eb54e2d", "262f4656f16a48ed94003a1f261cd7d3", +// }, +// []string{ +// "5499968", +// "5499966", +// "5499964", +// }, +// }, +// "363788": [][]string{ +// []string{ +// "9b78cbb9-b956-4820-9b2f-330daaed2828", "5ecd3d4b65b44c9f9f820af232110f20", "63b0d12d32734334bf8c95d43e396035", +// }, +// []string{ +// "5500121", +// "5500123", +// "5500120", +// }, +// }, +// "363892": [][]string{ +// []string{ +// "163a032f-72df-44c9-a405-b7675e68d2a6", "f40e9fc714e741359c8fc4f2a1ea9e59", "e486c09cfded4fe3a15ee1cff546155f", +// }, +// []string{ +// "5502844", +// "5502840", +// "5502842", +// }, +// }, +// "363894": [][]string{ +// []string{ +// "840b4a7c-5b9a-40fc-95e8-e53b56573565", "fbeeef71305c46f192979ca6a00d380c", "feeec4ccf24744d892c4e892f5978847", +// }, +// []string{ +// "5503000", +// "5502996", +// "5502997", +// }, +// }, +// "363896": [][]string{ +// []string{ +// "064ee734-e819-455b-b4c4-cc5ee21c6b2f", "ab938148ff0444eba773a7851029d082", "8f659292e639499ca41d39476fc9c2df", +// }, +// []string{ +// "5503152", +// "5503150", +// "5503151", +// }, +// }, +// } +// for _, v := range map1 { +// apijd := New(v[0][0], v[0][1], v[0][2]) +// for _, vv := range v[1] { +// apijd.DelShopCategory(utils.Str2Int64(vv)) +// } +// } +// // err := api.DelShopCategory(5496926) +// // if err != nil { +// // t.Fatal(err) +// // } +//} +// +//func TestGetSkuSaleAttrName(t *testing.T) { +// result, err := api.GetSkuSaleAttrName() +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetSpuSaleAttr(t *testing.T) { +// result, err := api.GetSpuSaleAttr("3628") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestAddSku(t *testing.T) { +// str := ` +// {"brandId":35247, +// "categoryId":20847, +// "fixedStatus":1, +// "ifViewDesc":0, +// "images":["http://image.jxc4.com/e42be71501d0fbb841743bfb7a9ebbcf.jpg"], +// "isSale":false, +// "outSkuId":"123", +// "shopCategories":[4247719], +// "skuName":"黑3龙江冰宝珍珠米10kg/袋", +// "skuPrice":7245,"traceId":"4414AEAD1CCA11EAB689525400E86DC0,xujianhua","weight":1} +// ` +// var param *OpSkuParam +// err := utils.UnmarshalUseNumber([]byte(str), ¶m) +// if err != nil { +// t.Fatal(err) +// } +// param.Upc = "66660003446710" +// result, err := api.AddSku2(param) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestBatchAddSku(t *testing.T) { +// paramList := []*CreateByUpcParam{ +// &CreateByUpcParam{ +// UniqueUpc: "6948939649102", +// OutSku: "50001", +// JdPrice: "2.13", +// ShopCategoryID: 4247719, +// IsSale: true, +// }, +// } +// result, err := api.BatchAddSku(paramList) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetSpuStatus(t *testing.T) { +// result, err := api.GetSpuStatus("8515") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetSkuStatus(t *testing.T) { +// result, err := api.GetSkuStatus("6092943") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestUpdateSpuSaleAttr(t *testing.T) { +// err := api.UpdateSpuSaleAttr("3628", "1001", "", "10", "hello") +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestUpdateSpu(t *testing.T) { +// err := api.UpdateSpu("8620", nil) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestUpdateSku(t *testing.T) { +// _, err := api.UpdateSku("27379", map[string]interface{}{ +// "upc": "ttld20190712", +// }) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestUpdateShopCategory(t *testing.T) { +// err := api.UpdateShopCategory(4760208, "中秋必抢🍳") +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestQueren(t *testing.T) { +// for i := 1; i < 85; i++ { +// result, _, _ := api.QuerySkuInfos(&QuerySkuParam{ +// PageNo: i, +// }) +// fmt.Println(i) +// for _, v := range result { +// api.UpdateSku2(&OpSkuParam{ +// TraceID: utils.GetUUID(), +// OutSkuID: v.OutSkuID, +// }) +// } +// } +// +// // result, _, err := api.QuerySkuInfos(&QuerySkuParam{ +// // PageNo: 1, +// // }) +// // if err != nil { +// // t.Fatal(err) +// // } +// // t.Log(utils.Format4Output(result, false)) +//} +// +//func TestBatchAddSkuByUPC(t *testing.T) { +// result, err := api.BatchAddSkuByUPC([]*CreateByUpcParam2{ +// &CreateByUpcParam2{ +// OutSkuId: "6048265", +// Upc: "6911672042530", +// JdPrice: "29800", +// ShopCategoryID: 5485102, +// }, +// }) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} diff --git a/platformapi/jdapi/store_page_test.go b/platformapi/jdapi/store_page_test.go index 42cfbb31..a582838e 100644 --- a/platformapi/jdapi/store_page_test.go +++ b/platformapi/jdapi/store_page_test.go @@ -1,324 +1,325 @@ package jdapi -import ( - "fmt" - "regexp" - "strings" - "testing" - "time" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -var ( - skuNamePat = regexp.MustCompile(`([\((\[【][^\((\[【\))\]】]*[\))\]】])?(.*?)([((].*[))])?\s*约?([1-9][\d\.]*)(g|G|kg|mg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([((].*[))])?\s*(?:\/|/|)\s*([^\s()()]{0,2})(\s.*)?$\s*([((].*[))])?$`) -) - -func TestGetRealMobileNumber4Order(t *testing.T) { - orderId := "921823424000122" - desiredMobile := "13722455105" - mobile, err := api.GetRealMobile4Order(orderId, "11893205") - fmt.Println("1111111111111111", mobile, err.Error()) - if err != nil { - t.Fatal(err) - } - if mobile != desiredMobile { - t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile) - } - baseapi.SugarLogger.Debug(mobile) -} - -func TestGetStoreOrderInfo(t *testing.T) { - orderId := "2113752262000061" - orderInfo, err := api.GetStoreOrderInfo(orderId, "11930291") - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false)) -} - -func TestGetStoreOrderInfoList(t *testing.T) { - orderInfoList, err := api.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59") - if err != nil { - t.Fatal(err) - } - if true { - baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false)) - } -} - -func TestGetSkuPageInfo(t *testing.T) { - skuInfo, err := api.GetSkuPageInfo(2023524346) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(skuInfo, false)) -} - -func TestGetSkuPageImageInfo(t *testing.T) { - imgList, err := api.GetSkuPageImageInfo(2025112058) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false)) -} - -func TestGetCorporationInfo(t *testing.T) { - imgList, err := api.GetCorporationInfo("", "92330104MA28XPXH5G") - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false)) -} - -func TestGetStoreList(t *testing.T) { - result, err := api.GetStoreList("104.054195", "30.581782") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreInfo(t *testing.T) { - result, err := api.GetStoreInfo("11750116") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStoreInfo2(t *testing.T) { - result, err := api.GetStoreInfo2("11883852") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestMonthSaleNum2Int(t *testing.T) { - num1 := MonthSaleNum2Int("1千+") - if num1 != 1000 { - t.Fatalf("num1:%d", num1) - } - num2 := MonthSaleNum2Int("2万+") - if num2 != 20000 { - t.Fatalf("num2:%d", num2) - } - num3 := MonthSaleNum2Int("234") - if num3 != 234 { - t.Fatalf("num3:%d", num3) - } -} - -func TestStoreUploadImgByURL(t *testing.T) { - outImgURL, err := api.StoreUploadImgByURL("http://image.jxc4.com/940c151db7e396f2ceaec0304597836f.jpg") - t.Log(outImgURL) - if err != nil { - t.Fatal(err) - } -} - -func TestSaveQualify(t *testing.T) { - jsonStr := ` - [ - {"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/169610/5/8031/168819/60386ed6E3e1d3543/34b3856c9e4e1282.jpg","qualifyType":"25","qualifyExpireForever":0,"qualifyExpireStart":"2020-11-04+00:00:00","qualifyName":"左凤娟","licenceType":"-1","qualifyNumber":"92331002MA2HJU1Q0J","qualifyAddress":"浙江省台州市椒江区白云街道花园新村60号楼二单元101室车库(自主申报)","licenceName":"台州市椒江彤彤蔬菜经营部","econKind":"个体工商户","scope":"一般项目:小食杂店(三小行业);食用农产品零售(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)。"},{"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/154609/37/19742/6390/60386ed6E9caa7248/a25278c9d3b01428.jpg","qualifyType":"22","qualifyExpireForever":1,"qualifyExpireStart":"2012-02-22+00:00:00","qualifyExpireEnd":"2022-02-22+00:00:00","qualifyOwner":"左凤娟","qualifyNumber":"411481198912063324"} - ] - ` - var qualityList []*QualifyItem - err := utils.UnmarshalUseNumber([]byte(jsonStr), &qualityList) - if err != nil { - t.Fatal(err) - } - err = api.SaveQualify("12085905", 0, qualityList) - if err != nil { - t.Fatal(err) - } -} - -func TestGetJdUserBindStoreIDs(t *testing.T) { - vv, err := api.GetJdUserBindStoreIDs(339890) - if err != nil { - t.Fatal(err) - } - fmt.Println(vv) -} - -func TestPrivilegeSearchUser(t *testing.T) { - list, _ := api.PrivilegeSearchUserAll() - for _, v := range list { - fmt.Println(v.LoginName) - } -} - -func TestPrivilegeUpdateJdUserStatus(t *testing.T) { - result, err := api.PrivilegeUpdateJdUserStatus(339020, 1) - if err != nil { - t.Fatal(err) - } - fmt.Println(result) -} - -func TestUpdateJdUserRoles(t *testing.T) { - result, err := api.UpdateJdUserRoles(345919, []string{"28926"}) - if err != nil { - t.Fatal(err) - } - fmt.Println(result) -} - -func TestIsJdManagerUser(t *testing.T) { - aa, _ := api.IsJdManagerUser(334683) - fmt.Println(aa) -} - -func TestGetJdStoreLevel(t *testing.T) { - api.GetJdStoreLevel("320406", "11732427", 1) -} - -func TestGetJdUpcCodeByName(t *testing.T) { - result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetJdSkuDirectPrice(t *testing.T) { - result, err := api.GetJdSkuDirectPrice(31031) - fmt.Println("test1", result, err) -} - -func TestSearchDeleteWare(t *testing.T) { - var ( - page = 1 - pageSize = 20 - searchResults []*SearchDeleteWareResult - ) - for ; page < 367; page++ { - searchDeleteWareResults, err := api.SearchDeleteWare("2020-04-22", "2020-04-23", page, pageSize) - if err == nil && len(searchDeleteWareResults) > 0 { - searchResults = append(searchResults, searchDeleteWareResults...) - } - } - fmt.Println(utils.Format4Output(searchResults, false)) -} - -func TestGetJdStoreID(t *testing.T) { - result, err := api.GetJdStoreID(801246) - fmt.Println("test1", result, err) -} - -func TestUpdateClosetStatus(t *testing.T) { - err := api.UpdateClosetStatus(801246, 1) - fmt.Println("test1", err) -} - -func TestGetJdShopOrders(t *testing.T) { - result, err := api.GetJdShopOrders("20210501", "20210531", "320406", "jd_jxcs1223") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetJdTopSkus(t *testing.T) { - // err := api.GetJdStoreInfo("12050477") - // if err != nil { - // t.Fatal(err) - // } - // t.Log(utils.Format4Output(result, false)) - s1 := "ymbgaraibkfmvocpizdydugvalagaivdbfsfbepeyccqfepzvtpyxtbadkhmwmoswrcxnargtlswqemafandgkmydtimuzvjwxvlfwlhvkrgcsithaqlcvrihrwqkpjdhgfgreqoxzfvhjzojhghfwbvpfzectwwhexthbsndovxejsntmjihchaotbgcysfdaojkjldprwyrnischrgmtvjcorypvopfmegizfkvudubnejzfqffvgdoxohuinkyygbdzmshvyqyhsozwvlhevfepdvafgkqpkmcsikfyxczcovrmwqxxbnhfzcjjcpgzjjfateajnnvlbwhyppdleahgaypxidkpwmfqwqyofwdqgxhjaxvyrzupfwesmxbjszolgwqvfiozofncbohduqgiswuiyddmwlwubetyaummenkdfptjczxemryuotrrymrfdxtrebpbjtpnuhsbnovhectpjhfhahbqrfbyxggobsweefcwxpqsspyssrmdhuelkkvyjxswjwofngpwfxvknkjviiavorwyfzlnktmfwxkvwkrwdcxjfzikdyswsuxegmhtnxjraqrdchaauazfhtklxsksbhwgjphgbasfnlwqwukprgvihntsyymdrfovaszjywuqygpvjtvlsvvqbvzsmgweiayhlubnbsitvfxawhfmfiatxvqrcwjshvovxknnxnyyfexqycrlyksderlqarqhkxyaqwlwoqcribumrqjtelhwdvaiysgjlvksrfvjlcaiwrirtkkxbwgicyhvakxgdjwnwmubkiazdjkfmotglclqndqjxethoutvjchjbkoasnnfbgrnycucfpeovruguzumgmgddqwjgdvaujhyqsqtoexmnfuluaqbxoofvotvfoiexbnprrxptchmlctzgqtkivsilwgwgvpidpvasurraqfkcmxhdapjrlrnkbklwkrvoaziznlpor" - s2 := "qhxepbshlrhoecdaodgpousbzfcqjxulatciapuftffahhlmxbufgjuxstfjvljybfxnenlacmjqoymvamphpxnolwijwcecgwbcjhgdybfffwoygikvoecdggplfohemfypxfsvdrseyhmvkoovxhdvoavsqqbrsqrkqhbtmgwaurgisloqjixfwfvwtszcxwktkwesaxsmhsvlitegrlzkvfqoiiwxbzskzoewbkxtphapavbyvhzvgrrfriddnsrftfowhdanvhjvurhljmpxvpddxmzfgwwpkjrfgqptrmumoemhfpojnxzwlrxkcafvbhlwrapubhveattfifsmiounhqusvhywnxhwrgamgnesxmzliyzisqrwvkiyderyotxhwspqrrkeczjysfujvovsfcfouykcqyjoobfdgnlswfzjmyucaxuaslzwfnetekymrwbvponiaojdqnbmboldvvitamntwnyaeppjaohwkrisrlrgwcjqqgxeqerjrbapfzurcwxhcwzugcgnirkkrxdthtbmdqgvqxilllrsbwjhwqszrjtzyetwubdrlyakzxcveufvhqugyawvkivwonvmrgnchkzdysngqdibhkyboyftxcvvjoggecjsajbuqkjjxfvynrjsnvtfvgpgveycxidhhfauvjovmnbqgoxsafknluyimkczykwdgvqwlvvgdmufxdypwnajkncoynqticfetcdafvtqszuwfmrdggifokwmkgzuxnhncmnsstffqpqbplypapctctfhqpihavligbrutxmmygiyaklqtakdidvnvrjfteazeqmbgklrgrorudayokxptswwkcircwuhcavhdparjfkjypkyxhbgwxbkvpvrtzjaetahmxevmkhdfyidhrdeejapfbafwmdqjqszwnwzgclitdhlnkaiyldwkwwzvhyorgbysyjbxsspnjdewjxbhpsvj" - fmt.Println(string(findTheDifference(s1, s2))) -} - -func findTheDifference(s string, t string) byte { - var ( - map1 = make(map[byte]int) - map2 = make(map[byte]int) - ) - if s == "" { - return []byte(t)[0] - } - for k, _ := range s { - map1[s[k]]++ - } - for k, _ := range t { - map2[t[k]]++ - } - for k, v := range map1 { - if map2[k] != v { - return k - } - } - for k, v := range t { - if k == len(t)-1 { - return t[k] - } else { - if strings.Index(string(v), string(s[k])) == -1 { - return t[k] - } - } - } - return []byte(t)[0] -} - -func TestGetJdStoreInfo(t *testing.T) { - str := "汤臣倍健 辅酶Q10天然维生素E软胶囊 400mg*60粒/瓶" - searchResult := skuNamePat.FindStringSubmatch(str) - fmt.Println(searchResult) -} - -func TestUpdateInterStatus(t *testing.T) { - err := api.UpdateInterStatus("f93ddfb7034b468da4d1ef10abe4b3ab", "message.djsw.newOrder", 0) - if err != nil { - t.Fatal(err) - } - // fmt.Println(result) -} - -func TestSaveMsgUrl(t *testing.T) { - err := api.SaveMsgUrl("f93ddfb7034b468da4d1ef10abe4b3ab", "http://callback.test.jxc4.com", "http://callback.jxc4.com", 0) - if err != nil { - t.Fatal(err) - } - // fmt.Println(result) -} - -func TestExcuteInvoking(t *testing.T) { - err := api.ExcuteInvoking("e95911589479472e8b6f4d099ad343b5", 0) - if err != nil { - t.Fatal(err) - } - // fmt.Println(result) -} - -func TestPeiZhiJdZhangHao(t *testing.T) { - for k, v := range interfaceMap { - if err := api.UpdateInterStatus(k, v[0].(string), v[1].(int)); err == nil { - if err2 := api.SaveMsgUrl(k, "http://callback.test.jxc4.com", "http://callback.jxc4.com", v[1].(int)); err2 == nil { - if err3 := api.ExcuteInvoking(k, v[1].(int)); err3 == nil { - } - } - } - } - if err := api.SaveCheckedInters(); err == nil { - time.Sleep(time.Second * 2) - api.ToOnline() - } -} - -func TestQueryMemberTransListByCondition(t *testing.T) { - result, err := api.QueryMemberTransListByCondition("", "", 4, 200) - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -type GuoMei struct { - appKey string - timestamp string - sign string -} +// +//import ( +// "fmt" +// "regexp" +// "strings" +// "testing" +// "time" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//var ( +// skuNamePat = regexp.MustCompile(`([\((\[【][^\((\[【\))\]】]*[\))\]】])?(.*?)([((].*[))])?\s*约?([1-9][\d\.]*)(g|G|kg|mg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([((].*[))])?\s*(?:\/|/|)\s*([^\s()()]{0,2})(\s.*)?$\s*([((].*[))])?$`) +//) +// +//func TestGetRealMobileNumber4Order(t *testing.T) { +// orderId := "921823424000122" +// desiredMobile := "13722455105" +// mobile, err := api.GetRealMobile4Order(orderId, "11893205") +// fmt.Println("1111111111111111", mobile, err.Error()) +// if err != nil { +// t.Fatal(err) +// } +// if mobile != desiredMobile { +// t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile) +// } +// baseapi.SugarLogger.Debug(mobile) +//} +// +//func TestGetStoreOrderInfo(t *testing.T) { +// orderId := "2113752262000061" +// orderInfo, err := api.GetStoreOrderInfo(orderId, "11930291") +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false)) +//} +// +//func TestGetStoreOrderInfoList(t *testing.T) { +// orderInfoList, err := api.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59") +// if err != nil { +// t.Fatal(err) +// } +// if true { +// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false)) +// } +//} +// +//func TestGetSkuPageInfo(t *testing.T) { +// skuInfo, err := api.GetSkuPageInfo(2023524346) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(skuInfo, false)) +//} +// +//func TestGetSkuPageImageInfo(t *testing.T) { +// imgList, err := api.GetSkuPageImageInfo(2025112058) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false)) +//} +// +//func TestGetCorporationInfo(t *testing.T) { +// imgList, err := api.GetCorporationInfo("", "92330104MA28XPXH5G") +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false)) +//} +// +//func TestGetStoreList(t *testing.T) { +// result, err := api.GetStoreList("104.054195", "30.581782") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreInfo(t *testing.T) { +// result, err := api.GetStoreInfo("11750116") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStoreInfo2(t *testing.T) { +// result, err := api.GetStoreInfo2("11883852") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestMonthSaleNum2Int(t *testing.T) { +// num1 := MonthSaleNum2Int("1千+") +// if num1 != 1000 { +// t.Fatalf("num1:%d", num1) +// } +// num2 := MonthSaleNum2Int("2万+") +// if num2 != 20000 { +// t.Fatalf("num2:%d", num2) +// } +// num3 := MonthSaleNum2Int("234") +// if num3 != 234 { +// t.Fatalf("num3:%d", num3) +// } +//} +// +//func TestStoreUploadImgByURL(t *testing.T) { +// outImgURL, err := api.StoreUploadImgByURL("http://image.jxc4.com/940c151db7e396f2ceaec0304597836f.jpg") +// t.Log(outImgURL) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestSaveQualify(t *testing.T) { +// jsonStr := ` +// [ +// {"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/169610/5/8031/168819/60386ed6E3e1d3543/34b3856c9e4e1282.jpg","qualifyType":"25","qualifyExpireForever":0,"qualifyExpireStart":"2020-11-04+00:00:00","qualifyName":"左凤娟","licenceType":"-1","qualifyNumber":"92331002MA2HJU1Q0J","qualifyAddress":"浙江省台州市椒江区白云街道花园新村60号楼二单元101室车库(自主申报)","licenceName":"台州市椒江彤彤蔬菜经营部","econKind":"个体工商户","scope":"一般项目:小食杂店(三小行业);食用农产品零售(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)。"},{"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/154609/37/19742/6390/60386ed6E9caa7248/a25278c9d3b01428.jpg","qualifyType":"22","qualifyExpireForever":1,"qualifyExpireStart":"2012-02-22+00:00:00","qualifyExpireEnd":"2022-02-22+00:00:00","qualifyOwner":"左凤娟","qualifyNumber":"411481198912063324"} +// ] +// ` +// var qualityList []*QualifyItem +// err := utils.UnmarshalUseNumber([]byte(jsonStr), &qualityList) +// if err != nil { +// t.Fatal(err) +// } +// err = api.SaveQualify("12085905", 0, qualityList) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestGetJdUserBindStoreIDs(t *testing.T) { +// vv, err := api.GetJdUserBindStoreIDs(339890) +// if err != nil { +// t.Fatal(err) +// } +// fmt.Println(vv) +//} +// +//func TestPrivilegeSearchUser(t *testing.T) { +// list, _ := api.PrivilegeSearchUserAll() +// for _, v := range list { +// fmt.Println(v.LoginName) +// } +//} +// +//func TestPrivilegeUpdateJdUserStatus(t *testing.T) { +// result, err := api.PrivilegeUpdateJdUserStatus(339020, 1) +// if err != nil { +// t.Fatal(err) +// } +// fmt.Println(result) +//} +// +//func TestUpdateJdUserRoles(t *testing.T) { +// result, err := api.UpdateJdUserRoles(345919, []string{"28926"}) +// if err != nil { +// t.Fatal(err) +// } +// fmt.Println(result) +//} +// +//func TestIsJdManagerUser(t *testing.T) { +// aa, _ := api.IsJdManagerUser(334683) +// fmt.Println(aa) +//} +// +//func TestGetJdStoreLevel(t *testing.T) { +// api.GetJdStoreLevel("320406", "11732427", 1) +//} +// +//func TestGetJdUpcCodeByName(t *testing.T) { +// result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetJdSkuDirectPrice(t *testing.T) { +// result, err := api.GetJdSkuDirectPrice(31031) +// fmt.Println("test1", result, err) +//} +// +//func TestSearchDeleteWare(t *testing.T) { +// var ( +// page = 1 +// pageSize = 20 +// searchResults []*SearchDeleteWareResult +// ) +// for ; page < 367; page++ { +// searchDeleteWareResults, err := api.SearchDeleteWare("2020-04-22", "2020-04-23", page, pageSize) +// if err == nil && len(searchDeleteWareResults) > 0 { +// searchResults = append(searchResults, searchDeleteWareResults...) +// } +// } +// fmt.Println(utils.Format4Output(searchResults, false)) +//} +// +//func TestGetJdStoreID(t *testing.T) { +// result, err := api.GetJdStoreID(801246) +// fmt.Println("test1", result, err) +//} +// +//func TestUpdateClosetStatus(t *testing.T) { +// err := api.UpdateClosetStatus(801246, 1) +// fmt.Println("test1", err) +//} +// +//func TestGetJdShopOrders(t *testing.T) { +// result, err := api.GetJdShopOrders("20210501", "20210531", "320406", "jd_jxcs1223") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetJdTopSkus(t *testing.T) { +// // err := api.GetJdStoreInfo("12050477") +// // if err != nil { +// // t.Fatal(err) +// // } +// // t.Log(utils.Format4Output(result, false)) +// s1 := "ymbgaraibkfmvocpizdydugvalagaivdbfsfbepeyccqfepzvtpyxtbadkhmwmoswrcxnargtlswqemafandgkmydtimuzvjwxvlfwlhvkrgcsithaqlcvrihrwqkpjdhgfgreqoxzfvhjzojhghfwbvpfzectwwhexthbsndovxejsntmjihchaotbgcysfdaojkjldprwyrnischrgmtvjcorypvopfmegizfkvudubnejzfqffvgdoxohuinkyygbdzmshvyqyhsozwvlhevfepdvafgkqpkmcsikfyxczcovrmwqxxbnhfzcjjcpgzjjfateajnnvlbwhyppdleahgaypxidkpwmfqwqyofwdqgxhjaxvyrzupfwesmxbjszolgwqvfiozofncbohduqgiswuiyddmwlwubetyaummenkdfptjczxemryuotrrymrfdxtrebpbjtpnuhsbnovhectpjhfhahbqrfbyxggobsweefcwxpqsspyssrmdhuelkkvyjxswjwofngpwfxvknkjviiavorwyfzlnktmfwxkvwkrwdcxjfzikdyswsuxegmhtnxjraqrdchaauazfhtklxsksbhwgjphgbasfnlwqwukprgvihntsyymdrfovaszjywuqygpvjtvlsvvqbvzsmgweiayhlubnbsitvfxawhfmfiatxvqrcwjshvovxknnxnyyfexqycrlyksderlqarqhkxyaqwlwoqcribumrqjtelhwdvaiysgjlvksrfvjlcaiwrirtkkxbwgicyhvakxgdjwnwmubkiazdjkfmotglclqndqjxethoutvjchjbkoasnnfbgrnycucfpeovruguzumgmgddqwjgdvaujhyqsqtoexmnfuluaqbxoofvotvfoiexbnprrxptchmlctzgqtkivsilwgwgvpidpvasurraqfkcmxhdapjrlrnkbklwkrvoaziznlpor" +// s2 := "qhxepbshlrhoecdaodgpousbzfcqjxulatciapuftffahhlmxbufgjuxstfjvljybfxnenlacmjqoymvamphpxnolwijwcecgwbcjhgdybfffwoygikvoecdggplfohemfypxfsvdrseyhmvkoovxhdvoavsqqbrsqrkqhbtmgwaurgisloqjixfwfvwtszcxwktkwesaxsmhsvlitegrlzkvfqoiiwxbzskzoewbkxtphapavbyvhzvgrrfriddnsrftfowhdanvhjvurhljmpxvpddxmzfgwwpkjrfgqptrmumoemhfpojnxzwlrxkcafvbhlwrapubhveattfifsmiounhqusvhywnxhwrgamgnesxmzliyzisqrwvkiyderyotxhwspqrrkeczjysfujvovsfcfouykcqyjoobfdgnlswfzjmyucaxuaslzwfnetekymrwbvponiaojdqnbmboldvvitamntwnyaeppjaohwkrisrlrgwcjqqgxeqerjrbapfzurcwxhcwzugcgnirkkrxdthtbmdqgvqxilllrsbwjhwqszrjtzyetwubdrlyakzxcveufvhqugyawvkivwonvmrgnchkzdysngqdibhkyboyftxcvvjoggecjsajbuqkjjxfvynrjsnvtfvgpgveycxidhhfauvjovmnbqgoxsafknluyimkczykwdgvqwlvvgdmufxdypwnajkncoynqticfetcdafvtqszuwfmrdggifokwmkgzuxnhncmnsstffqpqbplypapctctfhqpihavligbrutxmmygiyaklqtakdidvnvrjfteazeqmbgklrgrorudayokxptswwkcircwuhcavhdparjfkjypkyxhbgwxbkvpvrtzjaetahmxevmkhdfyidhrdeejapfbafwmdqjqszwnwzgclitdhlnkaiyldwkwwzvhyorgbysyjbxsspnjdewjxbhpsvj" +// fmt.Println(string(findTheDifference(s1, s2))) +//} +// +//func findTheDifference(s string, t string) byte { +// var ( +// map1 = make(map[byte]int) +// map2 = make(map[byte]int) +// ) +// if s == "" { +// return []byte(t)[0] +// } +// for k, _ := range s { +// map1[s[k]]++ +// } +// for k, _ := range t { +// map2[t[k]]++ +// } +// for k, v := range map1 { +// if map2[k] != v { +// return k +// } +// } +// for k, v := range t { +// if k == len(t)-1 { +// return t[k] +// } else { +// if strings.Index(string(v), string(s[k])) == -1 { +// return t[k] +// } +// } +// } +// return []byte(t)[0] +//} +// +//func TestGetJdStoreInfo(t *testing.T) { +// str := "汤臣倍健 辅酶Q10天然维生素E软胶囊 400mg*60粒/瓶" +// searchResult := skuNamePat.FindStringSubmatch(str) +// fmt.Println(searchResult) +//} +// +//func TestUpdateInterStatus(t *testing.T) { +// err := api.UpdateInterStatus("f93ddfb7034b468da4d1ef10abe4b3ab", "message.djsw.newOrder", 0) +// if err != nil { +// t.Fatal(err) +// } +// // fmt.Println(result) +//} +// +//func TestSaveMsgUrl(t *testing.T) { +// err := api.SaveMsgUrl("f93ddfb7034b468da4d1ef10abe4b3ab", "http://callback.test.jxc4.com", "http://callback.jxc4.com", 0) +// if err != nil { +// t.Fatal(err) +// } +// // fmt.Println(result) +//} +// +//func TestExcuteInvoking(t *testing.T) { +// err := api.ExcuteInvoking("e95911589479472e8b6f4d099ad343b5", 0) +// if err != nil { +// t.Fatal(err) +// } +// // fmt.Println(result) +//} +// +//func TestPeiZhiJdZhangHao(t *testing.T) { +// for k, v := range interfaceMap { +// if err := api.UpdateInterStatus(k, v[0].(string), v[1].(int)); err == nil { +// if err2 := api.SaveMsgUrl(k, "http://callback.test.jxc4.com", "http://callback.jxc4.com", v[1].(int)); err2 == nil { +// if err3 := api.ExcuteInvoking(k, v[1].(int)); err3 == nil { +// } +// } +// } +// } +// if err := api.SaveCheckedInters(); err == nil { +// time.Sleep(time.Second * 2) +// api.ToOnline() +// } +//} +// +//func TestQueryMemberTransListByCondition(t *testing.T) { +// result, err := api.QueryMemberTransListByCondition("", "", 4, 200) +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//type GuoMei struct { +// appKey string +// timestamp string +// sign string +//} diff --git a/platformapi/jdapi/store_test.go b/platformapi/jdapi/store_test.go index 619fdd64..ce284dc1 100644 --- a/platformapi/jdapi/store_test.go +++ b/platformapi/jdapi/store_test.go @@ -1,159 +1,160 @@ package jdapi -import ( - "testing" - "time" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/utils" -) - -const ( - mustExistStoreID = "11053496" - mustExistStoreJXID = "2" - - // mustExistStoreID = "11734851" - // mustExistStoreJXID = "100118" -) - -func TestGetAllCities(t *testing.T) { - result, err := api.GetAllCities() - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestGetStationsByVenderId(t *testing.T) { - result, err := api.GetStationsByVenderId() - if err != nil { - t.Fatal(err) - } - findStore := false - for _, v := range result { - if v == mustExistStoreID { - findStore = true - break - } - } - if !findStore { - baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID) - } -} - -func TestGetStoreInfoByStationNo(t *testing.T) { - result, err := api.GetStoreInfoByStationNo2("11946249") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) - -} - -func TestUpdateStoreInfo4Open(t *testing.T) { - result, err := api.GetStoreInfoByStationNo2(mustExistStoreID) - if err != nil { - t.Fatal(err) - } - oldAddress := result.StationAddress - params := &OpStoreParams{ - StationNo: mustExistStoreID, - Operator: "test", - StationAddress: oldAddress + "T", - } - err = api.UpdateStoreInfo4Open2(params, false) - if err != nil { - t.Fatal(err) - } - - result, err = api.GetStoreInfoByStationNo2(mustExistStoreID) - newAddress := result.StationAddress - if newAddress != params.StationAddress { - t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress) - } - - params.StationAddress = oldAddress - api.UpdateStoreInfo4Open2(params, false) - if err != nil { - t.Fatal(err) - } -} - -func TestGetCommentByOrderId(t *testing.T) { - testOrderID := int64(922520919000622) - result, err := api.GetCommentByOrderId2(testOrderID) - if err != nil { - t.Fatal(err.Error()) - } - t.Log(utils.Format4Output(result, false)) -} - -func TestUpdateStoreConfig4Open(t *testing.T) { - testStationNo := "11785740" - desiredValue := true - // 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。 - result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue) - if err != nil || !result { - if err != nil { - t.Fatal(err.Error()) - } - t.Fatal(result) - } - time.Sleep(2 * time.Second) - result2, err := api.GetStoreInfoByStationNo2(testStationNo) - if err != nil { - t.Fatal(err.Error()) - } - isAutoOrder := result2.IsAutoOrder - if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue { - t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder) - } -} - -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 - } -} - -func TestUpdateStoreFreightConfigNew(t *testing.T) { - err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{ - UserPin: "test", - MerchantStationNo: "2", - OpenDistanceFreight: true, - IsFullFree: true, - - StartCharge: 1890, - }) - if err != nil { - t.Fatal(err) - } -} - -func TestGetDeliveryRangeByStationNo(t *testing.T) { - const testStoreID = "11946249" - result, err := api.GetDeliveryRangeByStationNo2(testStoreID) - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) -} - -func TestQueryMerchantMemberInfo(t *testing.T) { - result, err := api.GetCommonMemberRegisteredInfo("562012843072000442") - if err != nil { - t.Fatal(err) - } - baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) -} +// +//import ( +// "testing" +// "time" +// +// "git.rosy.net.cn/baseapi" +// "git.rosy.net.cn/baseapi/utils" +//) +// +//const ( +// mustExistStoreID = "11053496" +// mustExistStoreJXID = "2" +// +// // mustExistStoreID = "11734851" +// // mustExistStoreJXID = "100118" +//) +// +//func TestGetAllCities(t *testing.T) { +// result, err := api.GetAllCities() +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestGetStationsByVenderId(t *testing.T) { +// result, err := api.GetStationsByVenderId() +// if err != nil { +// t.Fatal(err) +// } +// findStore := false +// for _, v := range result { +// if v == mustExistStoreID { +// findStore = true +// break +// } +// } +// if !findStore { +// baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID) +// } +//} +// +//func TestGetStoreInfoByStationNo(t *testing.T) { +// result, err := api.GetStoreInfoByStationNo2("11946249") +// if err != nil { +// t.Fatal(err) +// } +// t.Log(utils.Format4Output(result, false)) +// +//} +// +//func TestUpdateStoreInfo4Open(t *testing.T) { +// result, err := api.GetStoreInfoByStationNo2(mustExistStoreID) +// if err != nil { +// t.Fatal(err) +// } +// oldAddress := result.StationAddress +// params := &OpStoreParams{ +// StationNo: mustExistStoreID, +// Operator: "test", +// StationAddress: oldAddress + "T", +// } +// err = api.UpdateStoreInfo4Open2(params, false) +// if err != nil { +// t.Fatal(err) +// } +// +// result, err = api.GetStoreInfoByStationNo2(mustExistStoreID) +// newAddress := result.StationAddress +// if newAddress != params.StationAddress { +// t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress) +// } +// +// params.StationAddress = oldAddress +// api.UpdateStoreInfo4Open2(params, false) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestGetCommentByOrderId(t *testing.T) { +// testOrderID := int64(922520919000622) +// result, err := api.GetCommentByOrderId2(testOrderID) +// if err != nil { +// t.Fatal(err.Error()) +// } +// t.Log(utils.Format4Output(result, false)) +//} +// +//func TestUpdateStoreConfig4Open(t *testing.T) { +// testStationNo := "11785740" +// desiredValue := true +// // 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。 +// result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue) +// if err != nil || !result { +// if err != nil { +// t.Fatal(err.Error()) +// } +// t.Fatal(result) +// } +// time.Sleep(2 * time.Second) +// result2, err := api.GetStoreInfoByStationNo2(testStationNo) +// if err != nil { +// t.Fatal(err.Error()) +// } +// isAutoOrder := result2.IsAutoOrder +// if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue { +// t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder) +// } +//} +// +//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 +// } +//} +// +//func TestUpdateStoreFreightConfigNew(t *testing.T) { +// err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{ +// UserPin: "test", +// MerchantStationNo: "2", +// OpenDistanceFreight: true, +// IsFullFree: true, +// +// StartCharge: 1890, +// }) +// if err != nil { +// t.Fatal(err) +// } +//} +// +//func TestGetDeliveryRangeByStationNo(t *testing.T) { +// const testStoreID = "11946249" +// result, err := api.GetDeliveryRangeByStationNo2(testStoreID) +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) +//} +// +//func TestQueryMerchantMemberInfo(t *testing.T) { +// result, err := api.GetCommonMemberRegisteredInfo("562012843072000442") +// if err != nil { +// t.Fatal(err) +// } +// baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) +//} diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 440f537a..2d2a9eba 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -19,13 +19,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 - api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") + //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_kWP3yV8ei6reTseKnsxDJA") //token_nH_IlcWQKAkZBqklwItNRw + //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nH_IlcWQKAkZBqklwItNRw") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index 50b0e403..bbbe5ca8 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -18,7 +18,7 @@ func TestOrderViewStatus(t *testing.T) { } func TestOrderGetOrderDetail(t *testing.T) { - result, err := api.OrderGetOrderDetail(126652081163588666, false) + result, err := api.OrderGetOrderDetail(1300248543772157444, false) if err != nil { t.Fatal(err) } @@ -29,7 +29,7 @@ func TestOrderGetOrderDetail(t *testing.T) { } func TestOrderGetOrderDetail2(t *testing.T) { - result, err := api.OrderGetOrderDetail2(104784113865527330, false) + result, err := api.OrderGetOrderDetail2(1300248543772157444, false) if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 0d96d9e8..ac5a7ed0 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -24,23 +24,21 @@ func TestRetailCatUpdate(t *testing.T) { } } func TestRetailCatDelete(t *testing.T) { - var err error - err = api.RetailCatDelete(testPoiCode, "" /*utils.GetUpperUUID()*/, "猪肉类") - if err == nil { - t.Fatal("should return error that can not find such cat") - } - // uniqueCatName := "一二三四五六七八九十" - // // uniqueCatName := "1234567890" //fmt.Sprintf("CAT%d", time.Now().Unix()) - // err = api.RetailCatUpdate(testPoiCode, uniqueCatName, &Param4UpdateCat{ - // Sequence: 15, - // }) - // if err != nil { - // t.Fatal(err) - // } - // err = api.RetailCatDelete(testPoiCode, "", uniqueCatName) - // if err != nil { - // t.Fatal(err) - // } + //var err error + //errList := errlist.New() + //info := []string{"11309161", "7379027", "14422863", "12405467", "12398353", "12422620", "12422751", "11437415", "2391979", "11037873", "11646173", "12286931", "11086818", "9000444", "13413407", "10874383", "11674367", "11824223", "11939392", "11810047", "12071134", "11799045", "12848707", "11596643", "14038247", "9676866", "15382980", "8967897", "11566485", "11774697", "11730687", "11798089", "11488932", "11651698", "11637939", "11831005", "11883106", "11011885", "11342761", "12131910", "12833849", "11209533", "12211457", "15874713", "11440630", "12665305", "11437682", "11440628", "9578183", "11796739", "11213162", "12665208", "13887316"} + //str := []string{"token_gFkmTBCfctlpehYTENBNpw", "token_tnrjZftD5q4lU42KI3RPsQ", "token_ih9ZUCueA_dnrHBC6eBDew", "token_uJenwb2m6hWDe36e7hhAuw", "token_o2bWH171jXW8dIikHjFFog", "token_kfsqhhQ3kPXAwxUueglF_g", "token_h86ZqAP89I-Pe6vMACVLZQ", "token_uzWsBdnSIbv1KBQPoNRKRQ", "token_ucnSaUtKiUbonBnax5dDMQ", "token_o2-KGSi8lbh1ON4seUlEiQ", "token_v0gPiP4rH1vrS51GXgZJBg", "token_k0GWFzpjDtodAW5yFhVBgA", "token_oV2lXBnc1d8kc_JgWvtFxQ", "token_gl5GkKf9XKOO5ZNK-0JPRg", "token_suOF8ngaSTOcFcjNxvdHVA", "token_nf9QokI2udnECY2s1zBIeA", "token_nZjY3PlhFWlkHxdUDr9EsA", "token_kwq5HiBJI4vnavnmDyZBuA", "token_jhE-_ku5e7g6Ys4jWt5J0g", "token_lqAjjKmpEws1pKcspd1ETw", "token_mj31nyxnSIKFfxjViWpN4w", "token_kxjANA3lKNqfJrXApsZEEg", "token_kMttVFAYWLAcPAmZi3FNjg", "token_gd5aruWWQX2Iz8CXEg1Gaw", "token_j1HkNiZHh76aEGLqJT9Pfw", "token_muEkyBPPm6quxE2P2dlNQA", "token_uoHU5jcIZNx_QV0rZI1Now", "token_jj9M4B67tEr0DKgRiidDBQ", "token_gXpPtzRin_m9SEzohBJOFA", "token_rBIwyLoU2O6qfq2_VCdBQg", "token_qY6wArUbm8ypW1IoUc5Frw", "token_m5XZKS8TiL1ILCqy1flFjg", "token_n5xs7bSk96MekhNxWuJGPw", "token_oqbTOzEAZYvr4QgRIypA9w", "token_jmBHMy8LQi-TPa1fOsJJKQ", "token_nNzvPUZFeQ009kWinAhDiw", "token_q4EqYUsEXy726qXH1fdJeA", "token_o0aHQxC55_XjOLvWuYFFCQ", "token_k9vJhV8aAX2fN-39KZRGEA", "token_vdGAQ50zMvm_Ofqz1yJJwg", "token_r-XGhX8HFahkkDMelHxFbQ", "token_nHupX9FsP6nj6HWQm0RN2w", "token_hpNdSt3m1Hs-CKAiWZlMKw", "token_mQ16KE4knE2sdPP2r8ROSw", "token_uUrPsYavDU1ExUwEbuFG8Q", "token_oSSLl9h6zIt9hKz16e1N_g", "token_ifyMH0B_2YipwaBoBmdAdQ", "token_uryS4endUdFgySqEWo9Dwg", "token_kAFq-IIr_5KYQwo5wlhPcg", "token_shBMfRfZtOS1xaNn5MdI0Q", "token_sS0KoWshUu-WlGchoxBNcA"} + //for _, v := range info { + // for _, i := range str { + // err = New("5873", "41c479790a76f86326f89e8048964739", "", i).RetailCatDelete(v, "", "国产水果") + // if err != nil { + // errList.AddErr(err) + // } + // } + //} + //t.Fatal(errList) + err := api.RetailCatDelete("8694203", "" /*utils.GetUpperUUID()*/, "国产水果") + t.Fatal(err) } func TestRetailList(t *testing.T) { diff --git a/utils/utils_crypt.go b/utils/utils_crypt.go index c2da0500..01053d73 100644 --- a/utils/utils_crypt.go +++ b/utils/utils_crypt.go @@ -4,8 +4,6 @@ import ( "bytes" "crypto/aes" "crypto/cipher" - - "git.rosy.net.cn/baseapi" ) func AESCBCEncpryt(data, aesKey, iv []byte) (encryptedData []byte, err error) { @@ -36,7 +34,6 @@ func PKCSUnPadding(originData []byte) []byte { length := len(originData) unpadding := int(originData[length-1]) originData = originData[:(length - unpadding)] - baseapi.SugarLogger.Debugf("PKCSUnPadding, length:%d, unpadding:%d", length, unpadding) return originData }