Files
baseapi/platformapi/jdshopapi/store_page_test.go
苏尹岚 45898a424e aa
2021-04-09 17:35:47 +08:00

1717 lines
30 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package jdshopapi
import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"encoding/binary"
"fmt"
"math"
"sort"
"testing"
"git.rosy.net.cn/baseapi/utils"
)
func TestCreateShopCategory(t *testing.T) {
var CreateShopCategoryParams = []*CreateShopCategoryParam{
&CreateShopCategoryParam{
HomeShow: "0",
ID: "1",
Open: "",
OrderNo: "0",
ParentID: "",
Title: "测试1",
Type: "3",
},
}
result, _ := api.CreateShopCategory(CreateShopCategoryParams)
fmt.Println(result)
}
func TestUpdateStoreStatus(t *testing.T) {
err := api.UpdateStoreStatus(24332466, 1)
if err != nil {
t.Fatal(err)
}
}
func TestNewInfoList(t *testing.T) {
result, err := api.NewInfoList(1)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func Test11(t *testing.T) {
change := func(s ...string) {
s[0] = "Go"
s = append(s, "playground")
fmt.Println(s)
}
welcome := []string{"hello", "world"}
change(welcome...)
fmt.Println(welcome)
}
func TestAllOrders(t *testing.T) {
result, err := api.AllOrders(&AllOrdersParam{
Current: 1,
PageSize: 10,
OrderCreateDateRange: []string{"2021-04-05 00:00:00", "2021-04-06 23:59:59"},
// OrderID: "118793082128",
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestOrderDetail(t *testing.T) {
result, err := api.OrderDetail("125138699851")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestPhoneSensltiveInfo(t *testing.T) {
result, err := api.PhoneSensltiveInfo("124396047880", "10b1707dc87755373d488a7a4f422f7d")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestUpdateWaybill(t *testing.T) {
err := api.UpdateWaybill("123076499052", "1274", "88328977356545 ")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestTryGetCookie(t *testing.T) {
result, err := api.TryGetCookie()
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestAAADS(t *testing.T) {
result := md5.Sum([]byte("2108529226000532"))
chanIndex := int(int64(binary.LittleEndian.Uint32(result[8:])) % int64(1000))
fmt.Println(chanIndex)
}
func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
blockMode := cipher.NewCBCDecrypter(block, iv)
blockMode.CryptBlocks(decryptBytes, decryptBytes)
return PKCS5UnPadding(decryptBytes), nil
}
func PKCS5UnPadding(decrypted []byte) []byte {
length := len(decrypted)
unPadding := int(decrypted[length-1])
return decrypted[:(length - unPadding)]
}
func TestShopDetail(t *testing.T) {
result, err := api.ShopDetail(1000070140)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestSubmitBasic(t *testing.T) {
result, err := api.SubmitBasic(&UpdateBasicParam{
StoreName: "京西菜市石犀市场生鲜店",
CategoryID2: 62,
Coordinate: "30.692941,103.858781",
BussinessBeginTime: "08:30",
BussinessEndTime: "20:00",
ImgURL: "jfs/t1/141918/10/14803/148865/5fb4e8cbE95a606cb/08a8dc277eb97a16.png",
StorePhone: "13706546496",
AddName: "四川成都市温江区@!温江区锦泉街116号优取舍",
// AddCode1: 22,
// AddCode2: 1930,
AddCode3: 49315,
CategoryID1: 34,
QualificationRequests: []*QualificationRequests{
&QualificationRequests{
QualificationID: 41,
QualificationName: "营业执照",
QualificationNo: "11111",
QualificationURL: "jfs/t1/148622/37/14846/10266/5fb4e3e2Ef2f61870/a7cfba9c1513d95e.png",
StartTime: "2020-11-04 00:00:00",
EndingTime: "2020-11-06 23:59:59",
Time: []string{"2020-11-04 00:00:00", "2020-11-06 23:59:59"},
},
},
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestUpdateBasic(t *testing.T) {
shop, _ := api.ShopList(1)
for _, v := range shop.List {
detail, _ := api.ShopDetail(v.StoreID)
api.UpdateBasic(&UpdateBasicParam{
StoreID: detail.StoreID,
StoreName: detail.StoreName,
CategoryID2: 62,
Coordinate: detail.Coordinate,
BussinessBeginTime: detail.BussinessBeginTime,
BussinessEndTime: detail.BussinessEndTime,
ImgURL: detail.ImgURL,
StorePhone: detail.StorePhone,
AddName: utils.LimitUTF8StringLen(detail.AddName, 100),
AddCode1: detail.AddCode1,
AddCode2: detail.AddCode2,
AddCode3: detail.AddCode3,
CategoryID1: 34,
QualificationRequests: []*QualificationRequests{
&QualificationRequests{
QualificationID: 41,
QualificationName: "营业执照",
QualificationNo: "91510106MA62QYUK9X",
QualificationURL: "jfs/t1/140863/13/17145/275844/5fc9ac7aE9a5f8d68/f9d459176d463cb5.jpg",
StartTime: "2017-03-01 00:00:00",
EndingTime: "2027-03-01 00:00:00",
Time: []string{"2017-03-01 00:00:00", "2027-03-01 00:00:00"},
},
},
})
}
// t.Log(utils.Format4Output(result, false))
}
func TestUpdateExpand(t *testing.T) {
s := []int{
1000068984,
1000068975,
1000068985,
1000068976,
1000068977,
1000068978,
1000068986,
1000068979,
1000068987,
1000069001,
1000069002,
1000068992,
1000068993,
1000068994,
1000069005,
1000069006,
1000068995,
1000069008,
1000069009,
1000068996,
1000069010,
1000069011,
1000068997,
1000068998,
1000068999,
1000069020,
1000069021,
1000069012,
1000069013,
1000069014,
1000069022,
1000069015,
1000069023,
1000069016,
1000069017,
1000069018,
1000069024,
1000069025,
1000069019,
1000069030,
1000069031,
1000069032,
1000069033,
1000069034,
1000069035,
1000069026,
1000069027,
1000069028,
1000069029,
1000069036,
1000069037,
1000069038,
1000069040,
1000069041,
1000069042,
1000069039,
1000069043,
1000069044,
1000069050,
1000069045,
1000069051,
1000069046,
1000069047,
1000069052,
1000069048,
1000069049,
1000069053,
1000069060,
1000069061,
1000069054,
1000069062,
1000069063,
1000069055,
1000069056,
1000069057,
1000069064,
1000069058,
1000069065,
1000069066,
1000069059,
1000069067,
1000069070,
1000069071,
1000069072,
1000069073,
1000069068,
1000069074,
1000069075,
1000069069,
1000069076,
1000069077,
1000069080,
1000069081,
1000069078,
1000069082,
1000069079,
1000069090,
1000069083,
1000069084,
1000069085,
1000069086,
1000069091,
1000069087,
1000069088,
1000069092,
1000069089,
1000069093,
1000069094,
1000069095,
1000069103,
1000069104,
1000069096,
1000069105,
1000069106,
1000069097,
1000069107,
1000069098,
1000069099,
1000069108,
1000069109,
1000069110,
1000069111,
1000069120,
1000069112,
1000069121,
1000069122,
1000069123,
1000069124,
1000069125,
1000069126,
1000069127,
1000069113,
1000069114,
1000069115,
1000069128,
1000069129,
1000069116,
1000069130,
1000069131,
1000069132,
1000069133,
1000069117,
1000069134,
1000069141,
1000069137,
1000069138,
1000069139,
1000069142,
1000069143,
1000069150,
1000069144,
1000069145,
1000069151,
1000069146,
1000069152,
1000069153,
1000069147,
1000069148,
1000069154,
1000069155,
1000069149,
1000069156,
1000069160,
1000069161,
1000069162,
1000069163,
1000069164,
1000069157,
1000069166,
1000069167,
1000069158,
1000069159,
1000069170,
1000069168,
1000069169,
1000069180,
1000069181,
1000069182,
1000069171,
1000069172,
1000069183,
1000069173,
1000069174,
1000069175,
1000069184,
1000069176,
1000069177,
1000069178,
1000069185,
1000069203,
1000069192,
1000069204,
1000069193,
1000069205,
1000069206,
1000069207,
1000069194,
1000069195,
1000069208,
1000069196,
1000069209,
1000069210,
1000069211,
1000069197,
1000069212,
1000069198,
1000069213,
1000069199,
1000069214,
1000069215,
1000069220,
1000069221,
1000069222,
1000069223,
1000069216,
1000069217,
1000069224,
1000069225,
1000069226,
1000069218,
1000069227,
1000069219,
1000069230,
1000069228,
1000069229,
1000069231,
1000069240,
1000069241,
1000069242,
1000069243,
1000069232,
1000069244,
1000069233,
1000069234,
1000069235,
1000069236,
1000069237,
1000069238,
1000069245,
1000069239,
1000069246,
1000069250,
1000069251,
1000069247,
1000069252,
1000069253,
1000069254,
1000069255,
1000069256,
1000069248,
1000069257,
1000069258,
1000069249,
1000069260,
1000069259,
1000069261,
1000069270,
1000069271,
1000069262,
1000069263,
1000069272,
1000069273,
1000069264,
1000069265,
1000069274,
1000069266,
1000069275,
1000069267,
1000069268,
1000069269,
1000069276,
1000069277,
1000069280,
1000069281,
1000069278,
1000069282,
1000069279,
1000069290,
1000069283,
1000069291,
1000069292,
1000069284,
1000069285,
1000069293,
1000069294,
1000069295,
1000069286,
1000069287,
1000069288,
1000069296,
1000069289,
1000069300,
1000069301,
1000069297,
1000069302,
1000069298,
1000069303,
1000069299,
1000069304,
1000069305,
1000069310,
1000069311,
1000069306,
1000069312,
1000069313,
1000069314,
1000069307,
1000069315,
1000069316,
1000069317,
1000069318,
1000069319,
1000069320,
1000069321,
1000069322,
1000069308,
1000069323,
1000069324,
1000069309,
1000069325,
1000069326,
1000069330,
1000069331,
1000069328,
1000069329,
1000069332,
1000069333,
1000069340,
1000069334,
1000069335,
1000069341,
1000069342,
1000069336,
1000069337,
1000069343,
1000069338,
1000069344,
1000069345,
1000069346,
1000069351,
1000069352,
1000069353,
1000069347,
1000069354,
1000069348,
1000069355,
1000069356,
1000069349,
1000069357,
1000069358,
1000069360,
1000069359,
1000069361,
1000069371,
1000069373,
1000069374,
1000069375,
1000069362,
1000069363,
1000069364,
1000069365,
1000069376,
1000069366,
1000069367,
1000069377,
1000069378,
1000069368,
1000069369,
1000069380,
1000069379,
1000069390,
1000069381,
1000069391,
1000069382,
1000069392,
1000069383,
1000069393,
1000069384,
1000069394,
1000069385,
1000069395,
1000069386,
1000069396,
1000069387,
1000069388,
1000069397,
1000069389,
1000069398,
1000069399,
1000069410,
1000069411,
1000069412,
1000069401,
1000069413,
1000069402,
1000069403,
1000069414,
1000069404,
1000069405,
1000069406,
1000069407,
1000069415,
1000069416,
1000069417,
1000069408,
1000069409,
1000069418,
1000069420,
1000069419,
1000069421,
1000069430,
1000069422,
1000069423,
1000069424,
1000069431,
1000069425,
1000069432,
1000069426,
1000069433,
1000069427,
1000069434,
1000069435,
1000069428,
1000069429,
1000069436,
1000069437,
1000069440,
1000069438,
1000069439,
1000069441,
1000069450,
1000069451,
1000069452,
1000069442,
1000069443,
1000069453,
1000069454,
1000069444,
1000069445,
1000069455,
1000069446,
1000069456,
1000069447,
1000069457,
1000069448,
1000069458,
1000069449,
1000069459,
1000069460,
1000069461,
1000069462,
1000069463,
1000069464,
1000069470,
1000069471,
1000069465,
1000069472,
1000069473,
1000069474,
1000069466,
1000069467,
1000069475,
1000069476,
1000069468,
1000069477,
1000069469,
1000069478,
1000069480,
1000069479,
1000069490,
1000069491,
1000069481,
1000069482,
1000069492,
1000069493,
1000069494,
1000069495,
1000069483,
1000069496,
1000069484,
1000069497,
1000069498,
1000069485,
1000069499,
1000069486,
1000069487,
1000069488,
1000069489,
1000069500,
1000069501,
1000069510,
1000069511,
1000069515,
1000069516,
1000069517,
1000069518,
1000069519,
1000069520,
1000069506,
1000069521,
1000069507,
1000069508,
1000069522,
1000069509,
1000069530,
1000069531,
1000069532,
1000069523,
1000069533,
1000069534,
1000069524,
1000069525,
1000069535,
1000069526,
1000069527,
1000069536,
1000069537,
1000069541,
1000069555,
1000069570,
1000069580,
1000069588,
1000069592,
1000069579,
1000069594,
1000069596,
1000069620,
1000069621,
1000069622,
1000069623,
1000069614,
1000069624,
1000069625,
1000069626,
1000069627,
1000069628,
1000069646,
1000069656,
1000069647,
1000069648,
1000069657,
1000069658,
1000069659,
1000069660,
1000069661,
1000069662,
1000069663,
1000069664,
1000069649,
1000069665,
1000069666,
1000069670,
1000069671,
1000069672,
1000069667,
1000069674,
1000069675,
1000069676,
1000069677,
1000069668,
1000069669,
1000069678,
1000069680,
1000069679,
1000069681,
1000069690,
1000069682,
1000069683,
1000069691,
1000069692,
1000069693,
1000069684,
1000069685,
1000069686,
1000069687,
1000069694,
1000069695,
1000069696,
1000069697,
1000069698,
1000069688,
1000069689,
1000069699,
1000069700,
1000069710,
1000069701,
1000069711,
1000069702,
1000069712,
1000069713,
1000069703,
1000069704,
1000069714,
1000069715,
1000069705,
1000069706,
1000069716,
1000069707,
1000069717,
1000069708,
1000069718,
1000069719,
1000069721,
1000069722,
1000069723,
1000069724,
1000069725,
1000069726,
1000069727,
1000069728,
1000069729,
1000069730,
1000069731,
1000069740,
1000069741,
1000069742,
1000069732,
1000069743,
1000069733,
1000069734,
1000069744,
1000069745,
1000069746,
1000069735,
1000069736,
1000069737,
1000069747,
1000069748,
1000069738,
1000069750,
1000069751,
1000069752,
1000069739,
1000069753,
1000069754,
1000069760,
1000069755,
1000069756,
1000069761,
1000069757,
1000069758,
1000069759,
1000069762,
1000069770,
1000069771,
1000069772,
1000069773,
1000069763,
1000069764,
1000069774,
1000069765,
1000069766,
1000069767,
1000069775,
1000069776,
1000069768,
1000069769,
1000069777,
1000069778,
1000069779,
1000069780,
1000069781,
1000069782,
1000069790,
1000069791,
1000069792,
1000069783,
1000069793,
1000069784,
1000069785,
1000069795,
1000069786,
1000069787,
1000069788,
1000069796,
1000069797,
1000069798,
1000069799,
1000069800,
1000069789,
1000069810,
1000069811,
1000069801,
1000069812,
1000069802,
1000069813,
1000069814,
1000069803,
1000069804,
1000069815,
1000069816,
1000069805,
1000069817,
1000069806,
1000069818,
1000069819,
1000069820,
1000069807,
1000069821,
1000069822,
1000069823,
1000069808,
1000069809,
1000069830,
1000069824,
1000069831,
1000069825,
1000069826,
1000069832,
1000069833,
1000069834,
1000069835,
1000069827,
1000069836,
1000069828,
1000069837,
1000069829,
1000069838,
1000069840,
1000069841,
1000069839,
1000069842,
1000069843,
1000069844,
1000069845,
1000069850,
1000069846,
1000069847,
1000069848,
1000069851,
1000069852,
1000069853,
1000069849,
1000069854,
1000069860,
1000069862,
1000069863,
1000069856,
1000069857,
1000069858,
1000069864,
1000069859,
1000069865,
1000069866,
1000069870,
1000069871,
1000069872,
1000069873,
1000069867,
1000069868,
1000069874,
1000069869,
1000069880,
1000069881,
1000069882,
1000069883,
1000069876,
1000069877,
1000069878,
1000069879,
1000069884,
1000069890,
1000069891,
1000069885,
1000069892,
1000069893,
1000069894,
1000069886,
1000069895,
1000069896,
1000069887,
1000069888,
1000069889,
1000069900,
1000069897,
1000069901,
1000069898,
1000069899,
1000069902,
1000069903,
1000069904,
1000069910,
1000069905,
1000069906,
1000069911,
1000069912,
1000069907,
1000069913,
1000069914,
1000069915,
1000069908,
1000069909,
1000069920,
1000069921,
1000069922,
1000069916,
1000069917,
1000069918,
1000069919,
1000069923,
1000069924,
1000069925,
1000069930,
1000069931,
1000069932,
1000069926,
1000069933,
1000069934,
1000069927,
1000069935,
1000069936,
1000069937,
1000069938,
1000069939,
1000069928,
1000069940,
1000069941,
1000069942,
1000069943,
1000069944,
1000069945,
1000069929,
1000069946,
1000069950,
1000069951,
1000069952,
1000069953,
1000069954,
1000069947,
1000069955,
1000069948,
1000069949,
1000069957,
1000069960,
1000069961,
1000069962,
1000069958,
1000069963,
1000069964,
1000069965,
1000069966,
1000069967,
1000069959,
1000069970,
1000069968,
1000069971,
1000069969,
1000069980,
1000069981,
1000069972,
1000069982,
1000069973,
1000069983,
1000069974,
1000069984,
1000069975,
1000069976,
1000069977,
1000069985,
1000069978,
1000069986,
1000069987,
1000069988,
1000069979,
1000069989,
1000069990,
1000069991,
1000070000,
1000070001,
1000070002,
1000069997,
1000070005,
1000070006,
1000070007,
1000069998,
1000070008,
1000070009,
1000069999,
1000070010,
1000070020,
1000070011,
1000070021,
1000070012,
1000070022,
1000070023,
1000070024,
1000070025,
1000070013,
1000070026,
1000070027,
1000070014,
1000070028,
1000070029,
1000070030,
1000070031,
1000070015,
1000070016,
1000070032,
1000070017,
1000070018,
1000070033,
1000070019,
1000070034,
1000070035,
1000070040,
1000070036,
1000070037,
1000070038,
1000070039,
1000070041,
1000070042,
1000070043,
1000070050,
1000070051,
1000070052,
1000070053,
1000070054,
1000070044,
1000070055,
1000070045,
1000070046,
1000070056,
1000070057,
1000070058,
1000070047,
1000070059,
1000070048,
1000070060,
1000070049,
1000070070,
1000070061,
1000070075,
1000070092,
1000070102,
1000070098,
1000070099,
1000070110,
1000070103,
1000070111,
1000070105,
1000070112,
1000070113,
1000070106,
1000070114,
1000070115,
1000070107,
1000070116,
1000070108,
1000070117,
1000070109,
1000070120,
1000070118,
1000070121,
1000070119,
1000070130,
1000070122,
1000070131,
1000070132,
1000070123,
1000070133,
1000070134,
1000070135,
1000070136,
1000070124,
1000070137,
1000070138,
1000070139,
1000070140,
1000070141,
1000070142,
1000070125,
1000070143,
1000070144,
1000070126,
1000070127,
1000063128,
1000070128,
1000116473,
}
for _, v := range s {
err := api.UpdateExpand(v)
if err != nil {
t.Fatal(err)
}
}
// t.Log(utils.Format4Output(result, false))
}
func TestCreateGisFence(t *testing.T) {
err := api.CreateGisFence(1000069001, "3")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestUpdateDeliveryPromise(t *testing.T) {
err := api.UpdateDeliveryPromise("09:00", "20:00", 1000070127)
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestUploadImageNew(t *testing.T) {
fmt.Println(int(utils.Str2Time("2021-03-09 23:59:59").Sub(utils.Str2Time("2021-03-07 00:00:00")).Hours()) / 24)
}
//给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。
//表达式仅包含非负整数,+ - */ 四种运算符和空格  。 整数除法仅保留整数部分。
func calculate(s string) int {
return 1
}
//输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。
func spiralOrder(matrix [][]int) []int {
var result []int
if len(matrix) == 0 {
return result
} else {
if len(matrix[0]) == 0 {
return result
}
}
l, h := len(matrix[0]), len(matrix)
left, right, top, bottom := 0, l-1, 0, h-1
lmax, tmax := 0, 0
if l%2 == 0 {
lmax = l / 2
} else {
lmax = l/2 + 1
}
if h%2 == 0 {
tmax = l / 2
} else {
tmax = l/2 + 1
}
for left <= lmax && top+1 <= tmax {
for left1 := left; left1 <= right; left1++ {
if len(result) >= l*h {
break
}
result = append(result, matrix[top][left1])
}
if h > 1 {
for top1 := top + 1; top1 <= bottom; top1++ {
if len(result) >= l*h {
break
}
result = append(result, matrix[top1][right])
}
if right > 0 {
for right1 := right - 1; right1 >= left; right1-- {
if len(result) >= l*h {
break
}
result = append(result, matrix[bottom][right1])
}
}
if bottom > 0 {
for bottom1 := bottom - 1; bottom1 >= top+1; bottom1-- {
if len(result) >= l*h {
break
}
result = append(result, matrix[bottom1][left])
}
}
}
left++
top++
right--
bottom--
}
return result
}
func addToArrayForm(A []int, K int) (a []int) {
B := []int{}
lengthK := 0
for i := 10; ; i = i * 10 {
if K/i == 0 {
lengthK++
break
}
lengthK++
}
for i := lengthK; i > 0; i-- {
if i == lengthK {
B = append(B, K/int(math.Pow10(i-1)))
} else if i == 1 {
gw := K
for j := lengthK; j > 1; j-- {
gw = gw % int(math.Pow10(j-1))
}
B = append(B, gw)
} else {
qtw := K
for j := lengthK; j > 1; j-- {
if j == i {
qtw = qtw / int(math.Pow10(j-1))
break
} else {
qtw = qtw % int(math.Pow10(j-1))
}
}
B = append(B, qtw)
}
}
flag := false
in := 0
for k := len(A) - 1; k >= 0; {
if flag {
break
}
for k1 := len(B) - 1; k1 >= 0; {
if A[k]+B[k1]+in < 10 {
if in == 0 {
a = append(a, A[k]+B[k1])
} else {
a = append(a, A[k]+B[k1]+in)
}
in = 0
} else {
if in == 0 {
a = append(a, (A[k]+B[k1])%10)
} else {
a = append(a, (A[k]+B[k1]+in)%10)
}
in = 0
in++
}
k--
k1--
if k == -1 && k1 == -1 && in != 0 {
a = append(a, 1)
}
if k < 0 {
in2 := 0
for i := k1; i >= 0; i-- {
if B[i]+in+in2 < 10 {
if in2 == 0 {
a = append(a, B[i]+in)
} else {
a = append(a, B[i]+in2+in)
}
in = 0
in2 = 0
} else {
if in2 == 0 {
a = append(a, (B[i]+in)%10)
} else {
a = append(a, (B[i]+in+in2)%10)
}
in = 0
in2 = 0
in2++
}
if i == 0 && in2 != 0 {
a = append(a, 1)
}
}
flag = true
break
}
if k1 < 0 {
in2 := 0
for i := k; i >= 0; i-- {
if A[i]+in+in2 < 10 {
if in2 == 0 {
a = append(a, A[i]+in)
} else {
a = append(a, A[i]+in2+in)
}
in = 0
in2 = 0
} else {
if in2 == 0 {
a = append(a, (A[i]+in)%10)
} else {
a = append(a, (A[i]+in+in2)%10)
}
in = 0
in2 = 0
in2++
}
if i == 0 && in2 != 0 {
a = append(a, 1)
}
}
flag = true
break
}
}
}
for i := 0; i < len(a)/2; i++ {
temp := a[i]
a[i] = a[len(a)-i-1]
a[len(a)-i-1] = temp
}
return a
}
func maximumProduct(nums []int) int {
sort.Ints(nums)
n := len(nums)
fmt.Println(nums)
return max(nums[0]*nums[1]*nums[n-1], nums[n-3]*nums[n-2]*nums[n-1])
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func accountsMerge(accounts [][]string) (ans [][]string) {
emailToIndex := map[string]int{}
emailToName := map[string]string{}
for _, account := range accounts {
name := account[0]
for _, email := range account[1:] {
if _, has := emailToIndex[email]; !has {
emailToIndex[email] = len(emailToIndex)
emailToName[email] = name
}
}
}
fmt.Println(emailToIndex)
fmt.Println()
fmt.Println(emailToName)
parent := make([]int, len(emailToIndex))
for i := range parent {
parent[i] = i
}
var find func(int) int
find = func(x int) int {
if parent[x] != x {
parent[x] = find(parent[x])
}
return parent[x]
}
union := func(from, to int) {
parent[find(from)] = find(to)
}
for _, account := range accounts {
firstIndex := emailToIndex[account[1]]
for _, email := range account[2:] {
union(emailToIndex[email], firstIndex)
}
}
fmt.Println(parent)
fmt.Println()
fmt.Println(accounts)
indexToEmails := map[int][]string{}
for email, index := range emailToIndex {
index = find(index)
indexToEmails[index] = append(indexToEmails[index], email)
}
fmt.Println(indexToEmails)
for _, emails := range indexToEmails {
sort.Strings(emails)
account := append([]string{emailToName[emails[0]]}, emails...)
ans = append(ans, account)
}
return
}
func findRedundantConnection(edges [][]int) []int {
parent := make([]int, len(edges)+1)
for i := range parent {
parent[i] = i
}
fmt.Println("edges ", edges)
fmt.Println("parent ", parent)
var find func(int) int
find = func(x int) int {
if parent[x] != x {
parent[x] = find(parent[x])
}
return parent[x]
}
union := func(from, to int) bool {
fmt.Println(from, to)
x, y := find(from), find(to)
fmt.Println(x, y)
if x == y {
return false
}
parent[x] = y
fmt.Println(parent)
fmt.Println("-------------------------------")
return true
}
for _, e := range edges {
if !union(e[0], e[1]) {
return e
}
}
return nil
}
func removeStones(stones [][]int) int {
fa := map[int]int{}
var find func(int) int
find = func(x int) int {
if _, has := fa[x]; !has {
fa[x] = x
}
if fa[x] != x {
fa[x] = find(fa[x])
}
fmt.Println(fa[x])
return fa[x]
}
union := func(x, y int) {
fmt.Println(x, y)
fx, fy := find(x), find(y)
if fx == fy {
return
}
fa[fy] = fx
fmt.Println(fa)
}
for _, p := range stones {
union(p[0], p[1]+10000)
}
ans := len(stones)
for x, fx := range fa {
if x == fx {
ans--
}
}
return ans
}
//动态规划
func maxUncrossedLines(A []int, B []int) (s int) {
var dynamic = make([][]int, len(A)+1, len(A)+1)
for index := range dynamic {
dynamic[index] = make([]int, len(B)+1, len(B)+1) //多创建一列,因为 index = 0 的时候,没有前置匹配
}
for _, v := range dynamic {
fmt.Println(v)
}
fmt.Println("---------------------")
for index, a := range A {
for i, b := range B {
if a == b {
dynamic[index+1][i+1] = dynamic[index][i] + 1
for _, v := range dynamic {
fmt.Println(v)
}
fmt.Println("---------------------")
} else {
dynamic[index+1][i+1] = dynamic[index][i+1]
if dynamic[index+1][i+1] < dynamic[index+1][i] {
dynamic[index+1][i+1] = dynamic[index+1][i] //判断大小,取大值
}
for _, v := range dynamic {
fmt.Println(v)
}
fmt.Println("---------------------")
}
}
}
return dynamic[len(A)][len(B)]
}
func TestShopList(t *testing.T) {
result, err := api.ShopList(25)
if err != nil {
t.Fatal(err)
}
fmt.Println("aaaaaaa", len(result.List))
t.Log(utils.Format4Output(result, false))
}
func TestWareSave(t *testing.T) {
// desc := `<p>因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解</p><p><img style="width:auto;height:auto;max-width:100%;" src="//img10.360buyimg.com/imgzone/jfs/t1/126814/22/1326/472568/5ebb888dEa2cfb5f6/c0c81db660994246.jpg"><br></p><p><br></p>`
params := &WareSaveParam{
WareID: 0,
Height: 100,
CategoryID: 13574,
LastCategoryID: 13574,
VenderID: 10569615,
BrandID: 44259,
Length: 200,
Wide: 100,
WareStatus: 8,
Title: "散养土鸡蛋新鲜鸡蛋草鸡蛋柴鸡蛋顺丰包邮测试",
Weight: "1",
ShopCategorys: []int{15602325},
Notes: `
<p><img src="//img10.360buyimg.com/imgzone/jfs/t1/152741/14/7416/273609/5fbf645aEa1f7d6b7/dc1d9d997fe346b7.jpg" style="width: auto; height: auto; max-width: 100%;"><br></p><p><br></p>
`,
Skus: []*WareSaveSkus{
&WareSaveSkus{
// SkuID: 10024685331653,
JdPrice: "25",
StockNum: 9999,
Props: []*WareSaveSkusProp{
&WareSaveSkusProp{
AttrID: 1001027603,
AttrValues: 2517633718,
AttrValueAlias: "20个",
},
},
OuterID: "6045735",
},
// &WareSaveSkus{
// JdPrice: "31",
// StockNum: 5,
// Props: []*WareSaveSkusProp{
// &WareSaveSkusProp{
// AttrID: 1000022043,
// AttrValues: 2515430634,
// AttrValueAlias: "500g",
// },
// },
// },
},
PromiseID: 0,
MultiCateProps: []interface{}{},
PropsSet: []interface{}{},
SaleAttrs: []interface{}{},
TransparentImageAudit: []interface{}{},
OptionType: 1,
AvailableFeatures: []interface{}{},
CharacteristicService: []interface{}{},
ExtendFeatures: []interface{}{},
TempID: "10569615110055200", //必须要这个东西,不知道是啥
}
params.ImageMap.Num0000000000 = append(params.ImageMap.Num0000000000, &CreateSkuParamImages{
ColorID: "0000000000",
ImgIndex: 1,
ImgURL: "jfs/t1/149724/17/15786/39416/5fbf645aE948e4d7a/b13bcaee129676b2.jpg",
// ImgZoneID: "0000000000",
})
// , &CreateSkuParamImages{
// ColorID: "0000000000",
// ImgIndex: 2,
// ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg",
// // ImgZoneID: "0000000000",
// })
result, err := api.WareSave(params)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestWareDoUpdate(t *testing.T) {
err := api.WareDoUpdate("up", "10020536451427")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreWareDoUpdate(t *testing.T) {
err := api.StoreWareDoUpdate(1, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreUpdatePrice(t *testing.T) {
err := api.StoreUpdatePrice("11.4", 10027605679156, "1000069001")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreUpdateStock(t *testing.T) {
err := api.StoreUpdateStock(80, 10024685331653, "1000063128")
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreSkuBindStore(t *testing.T) {
err := api.StoreSkuBindStore(false, []string{"10024685331653"}, []string{"1000063128"})
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestSetOrderStateToWait(t *testing.T) {
err := api.SetOrderStateToWait(1)
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
}
func TestStoreProductSearch(t *testing.T) {
result, _, err := api.StoreProductSearch(1, 20, []string{"1000069025"})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}