🚧更新脚本测试

This commit is contained in:
sunxiaolong
2024-05-23 23:28:24 +08:00
parent b4684b6350
commit 148d67cf63
3 changed files with 42 additions and 16 deletions

42
main.go
View File

@@ -27,6 +27,23 @@ func SortMap(m map[string]string) []string {
return arr
}
func GenRandomCardNo() string {
cardNo := "GCA"
//GCA3238734750243
for i := 0; i < 13; i++ {
cardNo += strconv.Itoa(rand.Intn(10))
}
return cardNo
}
func GenRandomCardPass() string {
cardPass := ""
for i := 0; i < 16; i++ {
cardPass += string(rune(rand.Intn(26) + 65))
}
return cardPass
}
func genSign(data models.Data) string {
appSecret := "ssssc9kit6bimggos5kk0c9g"
@@ -38,11 +55,10 @@ func genSign(data models.Data) string {
params["orderNo"] = data.OrderNo
params["orderPeriod"] = data.OrderPeriod
params["orderPrice"] = data.OrderPrice
params["payWayCode"] = data.PayWayCode
params["osType"] = data.OsType
params["notifyUrl"] = data.NotifyUrl
params["payKey"] = data.AppKey
params["timestamp"] = data.TimeStamp
params["payKey"] = data.PayKey
params["productCode"] = data.ProductCode
strArr := SortMap(params)
signStr := ""
@@ -76,18 +92,17 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup) {
client := http.Client{}
formData := models.Data{
ExValue: models.ExValue{
Data: "333333333333333",
Data: GenRandomCardPass(),
FaceType: "100",
CardNo: "1233333333",
CardNo: GenRandomCardNo(),
RecoveryType: "8",
},
OrderNo: id,
OrderPeriod: strconv.Itoa(rand.Intn(24)),
OrderPrice: "100",
PayWayCode: "CARD_DH",
OsType: "1",
ProductCode: "8546",
NotifyUrl: "https://baidu.com",
AppKey: "kkkkc9kit6bimggos5kk0c90",
PayKey: "kkkkc9kit6bimggos5kk0c90",
TimeStamp: strconv.FormatInt(time.Now().Unix(), 10),
Sign: "",
}
@@ -98,13 +113,20 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup) {
fmt.Println(string(result))
}
//func GenAccount() {
// client := http.Client{}
// client.Post("http://121.37.253.228:12401/")
//}
func main() {
group := sync.WaitGroup{}
stop := make(chan int, 50)
for i := 1; i < int(math.Pow10(5)); i++ {
startTime := time.Now()
stop := make(chan int, 100)
for i := 1; i < int(math.Pow10(3)); i++ {
group.Add(1)
stop <- 1
go randomRequest(i, stop, &group)
}
group.Wait()
fmt.Println("总耗时", time.Since(startTime).Seconds())
}

6
models/account.go Normal file
View File

@@ -0,0 +1,6 @@
package models
type AppleAccountRecord struct {
Account string `json:"account" description:"账户"`
Password string `json:"password" description:"密码"`
}

View File

@@ -10,10 +10,9 @@ type Data struct {
OrderNo string `json:"orderNo"`
OrderPeriod string `json:"orderPeriod"`
OrderPrice string `json:"orderPrice"`
PayWayCode string `json:"payWayCode"`
OsType string `json:"osType"`
ProductCode string `json:"productCode"`
NotifyUrl string `json:"notifyUrl"`
AppKey string `json:"payKey"`
PayKey string `json:"PayKey"`
TimeStamp string `json:"timestamp"`
Sign string `json:"sign"`
}
@@ -24,10 +23,9 @@ func (d *Data) Url() url.Values {
"orderNo": {d.OrderNo},
"orderPeriod": {d.OrderPeriod},
"orderPrice": {d.OrderPrice},
"payWayCode": {d.PayWayCode},
"osType": {d.OsType},
"notifyUrl": {d.NotifyUrl},
"payKey": {d.AppKey},
"productCode": {d.ProductCode},
"payKey": {d.PayKey},
"timestamp": {d.TimeStamp},
"sign": {d.Sign},
}