diff --git a/script/Makefile b/script/Makefile index d48fe4a78d522dd3e98431aca615e560b1c60522..f02ba2e43c031b10bf60587f218033f9ea65cd8d 100644 --- a/script/Makefile +++ b/script/Makefile @@ -30,3 +30,9 @@ promotion_data: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o promotion_data promotion_data.go group_room_visit500: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o group_room_visit500 group_room_visit500.go +svip_user_charge: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o svip_user_charge svip_user_charge.go +act_710_data: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o act_710_data act_710_data.go +clear_redis: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o clear_redis clear_redis.go diff --git a/script/act_710_data.go b/script/act_710_data.go new file mode 100644 index 0000000000000000000000000000000000000000..be2c840ab08083165252c1897cb4a49791dda132 --- /dev/null +++ b/script/act_710_data.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "git.hilo.cn/hilo-common/script/model" + "git.hilo.cn/hilo-common/script/mysql" + "github.com/tealeg/xlsx" + "strings" +) + +type Act710Data struct { + Code string + SendUserId uint64 + ActDiamond uint64 + Levels []int `gorm:"-"` + RealDiamond uint64 +} + +func ats39(a interface{}) string { + return fmt.Sprintf("%v", a) +} + +type ActUserAward struct { + Level int +} + +func main() { + var data []Act710Data + if err := mysql.ProdReadOnlyDB.Table("act_gift_record"). + Where("activity_id = 710"). + Select("send_user_id,SUM(diamond) act_diamond"). + Group("send_user_id").Find(&data).Error; err != nil { + panic(err) + } + for i, v := range data { + var user model.User + if err := mysql.ProdReadOnlyDB.Model(model.User{}).Where("id = ? ", v.SendUserId).First(&user).Error; err != nil { + panic(err) + } + var realDiamond uint64 + if err := mysql.ProdReadOnlyDB.Table("gift_operate"). + Where("send_user_id = ? AND res_gift_id in (4766,4767,4768,4769) AND created_time >= \"2024-01-01 05:00:00\" AND created_time <= \"2024-01-08 05:00:00\"", v.SendUserId). + Select("SUM(send_user_diamond) real_diamond").Scan(&realDiamond).Error; err != nil { + panic(err) + } + data[i].Code = user.Code + data[i].RealDiamond = realDiamond + var levels []ActUserAward + if err := mysql.ProdReadOnlyDB.Table("act_user_award").Where("activity_id = 710 AND user_id = ?", v.SendUserId).Select("level").Find(&levels).Error; err != nil { + panic(err) + } + var l []int + for _, v := range levels { + l = append(l, v.Level) + } + data[i].Levels = l + //break + } + excelFileName := fmt.Sprintf("./710数据.xlsx") + xlFile := xlsx.NewFile() + sheet, _ := xlFile.AddSheet("charge") + row := sheet.AddRow() + c1, c2, c3, c4 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c1.Value, c2.Value, c3.Value, c4.Value = "用户", "实际送礼", "活动统计送礼", "已经领取的任务" + for _, d := range data { + row := sheet.AddRow() + c1, c2, c3, c4 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + var l []string + for _, v := range d.Levels { + l = append(l, fmt.Sprintf("%v", v)) + } + levels := strings.Join(l, ",") + c1.Value, c2.Value, c3.Value, c4.Value = ats39(d.Code), ats39(d.RealDiamond), ats39(d.ActDiamond), ats39(levels) + } + _ = xlFile.Save(excelFileName) +} diff --git a/script/clear_redis.go b/script/clear_redis.go new file mode 100644 index 0000000000000000000000000000000000000000..a6dbebfbabd5b19b14d89cd52942a9fd4da9fcfc --- /dev/null +++ b/script/clear_redis.go @@ -0,0 +1,79 @@ +package main + +import ( + "context" + "fmt" + "github.com/go-redis/redis/v8" + "log" +) + +const redisAddr = "172.28.16.31:6379" // 替换为你的Redis地址 + +func main() { + // 创建Redis客户端 + client := redis.NewClient(&redis.Options{ + Addr: redisAddr, + DB: 0, // 替换为你的数据库编号 + //Password: "yPyZH1DYMJhrVQgr", + }) + + // 关闭连接 + defer func() { + if err := client.Close(); err != nil { + log.Fatalf("Failed to close Redis connection: %v", err) + } + }() + + // 获取所有以"user_qps_"为前缀的键 + keys, err := getKeysWithPrefix(client, "hilo_zsdb_round_") + if err != nil { + log.Fatalf("Failed to get keys with prefix: %v", err) + } + println(len(keys)) + + // 删除所有匹配的键 + //err = deleteKeys(client, keys) + //if err != nil { + // log.Fatalf("Failed to delete keys: %v", err) + //} + + fmt.Println("Cleanup completed.") +} + +// 获取所有以特定前缀开头的键 +func getKeysWithPrefix(client *redis.Client, prefix string) ([]string, error) { + ctx := context.Background() + var cursor uint64 + var keys []string + var err error + + for { + var result []string + result, cursor, err = client.Scan(ctx, cursor, prefix+"*", 1000).Result() + if err != nil { + return nil, err + } + + keys = append(keys, result...) + + if cursor == 0 { + break + } + } + + return keys, nil +} + +// 删除指定的键 +func deleteKeys(client *redis.Client, keys []string) error { + ctx := context.Background() + + for _, key := range keys { + err := client.Del(ctx, key).Err() + if err != nil { + return err + } + } + + return nil +} diff --git a/script/promotion_data.go b/script/promotion_data.go index bf1fcf5ee4c10bc1bb5565770f4f5d1b13854b50..8dd26830b1ae50d7529a07b9c5df81239145f67f 100644 --- a/script/promotion_data.go +++ b/script/promotion_data.go @@ -43,7 +43,7 @@ func main() { pageIndex := 1 pageSize := 1000 for { - url := fmt.Sprintf("https://apiv2.faceline.live/v1/mgr/promotion/invite/data?lang=zh-cn&pageIndex=%d&pageSize=%d&startTime=2023-10-01&endTime=2023-10-31&teamName=&agentCode=&inviteeCode=&platform=All", + url := fmt.Sprintf("https://apiv2.faceline.live/v1/mgr/promotion/invite/data?lang=zh-cn&pageIndex=%d&pageSize=%d&startTime=2023-09-01&endTime=2023-11-30&teamName=&agentCode=&inviteeCode=&platform=All", pageIndex, pageSize) method := "GET" @@ -55,7 +55,7 @@ func main() { return } req.Header.Add("nonce", "hilo") - req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcwMjU0NjkzMX0.-3OB6g_T9sX4XZIh3BaDlG7uSpYkRAcOh6PobBFyOKA") + req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcwNTIxODE0MH0.Xb7DU89AUYBahJfV4MDcr-pBbsLJcf1VM0WgnCNb-ig") res, err := client.Do(req) if err != nil { @@ -80,7 +80,7 @@ func main() { data = append(data, resp.Data.Items...) pageIndex++ } - excelFileName := fmt.Sprintf("./推广员数据10月.xlsx") + excelFileName := fmt.Sprintf("./推广员数据0901-1130.xlsx") xlFile := xlsx.NewFile() sheet, err := xlFile.AddSheet("promotion") if err != nil { diff --git a/script/svip_user_charge.go b/script/svip_user_charge.go index 61caaedb3bfc8e4cb829bb1997ec83b51160f912..c1018ca93f7ed08afab57df6a5dc139c1dfce285 100644 --- a/script/svip_user_charge.go +++ b/script/svip_user_charge.go @@ -14,15 +14,17 @@ type AutoGenerated34 struct { Data struct { Total int `json:"total"` Data []struct { - UserID int `json:"userId"` - Date string `json:"date"` - Country string `json:"country"` - UserCode string `json:"userCode"` - UserName string `json:"userName"` - ChargeMoney string `json:"chargeMoney"` - HaveFirst int `json:"haveFirst"` - RegisterAt string `json:"registerAt"` - SvipLevel int `json:"svipLevel"` + UserID int `json:"userId"` + Date string `json:"date"` + Country string `json:"country"` + UserCode string `json:"userCode"` + UserName string `json:"userName"` + ChargeMoney string `json:"chargeMoney"` + HaveFirst int `json:"haveFirst"` + RegisterAt string `json:"registerAt"` + SvipLevel int `json:"svipLevel"` + MaxDollar int `json:"maxDollar"` // 历史最高单笔 + MaxDollarDuration int `json:"maxDollarDuration"` // 时段最高单笔 } `json:"data"` } `json:"data"` } @@ -32,7 +34,9 @@ func ats34(a interface{}) string { } func main() { - url := "https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=2&beginDate=2023-10-01&endDate=2023-10-31&pageIndex=1&pageSize=10000&country=All&code=&area=1&timezone=1" + //url := "https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=2&beginDate=2023-10-01&endDate=2023-10-31&pageIndex=1&pageSize=10000&country=All&code=&area=1&timezone=1" + //url := "https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=1&beginDate=2022-06-01&endDate=2023-12-13&pageIndex=1&pageSize=4805&country=All&code=&area=1&timezone=0" + url := "https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=1&beginDate=2023-12-01&endDate=2023-12-31&pageIndex=2&pageSize=2500&country=All&code=&area=2&timezone=0" method := "GET" client := &http.Client{} @@ -43,7 +47,7 @@ func main() { return } req.Header.Add("nonce", "hilo") - req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcwMTIyNTI5Nn0.YIz5lhgvqIxgmK0lLXICUhiISHNP4_g-LHsg4foL-qc") + req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcwNTIxODE0MH0.Xb7DU89AUYBahJfV4MDcr-pBbsLJcf1VM0WgnCNb-ig") res, err := client.Do(req) if err != nil { @@ -56,22 +60,23 @@ func main() { if err != nil { panic(err) } + println(string(body)) var response = new(AutoGenerated34) err = json.Unmarshal(body, &response) if err != nil { panic(err) } - excelFileName := fmt.Sprintf("./粉钻充值10月-沙特时间.xlsx") + excelFileName := fmt.Sprintf("./非阿语区黄钻充值202312月2.xlsx") xlFile := xlsx.NewFile() sheet, _ := xlFile.AddSheet("charge") row := sheet.AddRow() - c1, c2, c3, c4, c5, c6, c7, c8 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() - c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value = "日期", "国家", "用户ID", "用户昵称", "充值金额", "注册时间", "是否举办首场活动", "svip等级" + c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value, c10.Value = "日期", "国家", "用户ID", "用户昵称", "充值金额", "注册时间", "是否举办首场活动", "svip等级", "时段最高单笔", "历史最高单笔" for _, d := range response.Data.Data { row := sheet.AddRow() - c1, c2, c3, c4, c5, c6, c7, c8 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() + c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 := row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell(), row.AddCell() c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value = ats34(d.Date), ats34(d.Country), ats34(d.UserCode), ats34(d.UserName), ats34(d.ChargeMoney), ats34(d.RegisterAt) - c7.Value, c8.Value = ats34(d.HaveFirst), ats34(d.SvipLevel) + c7.Value, c8.Value, c9.Value, c10.Value = ats34(d.HaveFirst), ats34(d.SvipLevel), ats34(d.MaxDollarDuration), ats34(d.MaxDollar) } _ = xlFile.Save(excelFileName) } diff --git a/script/test_20_in_mic.go b/script/test_20_in_mic.go index be4551e50c4df17e709cfcbcb6be6aa896f8da7b..ec5f6dd01f1ec15b21cb5505fd70676419a8e262 100644 --- a/script/test_20_in_mic.go +++ b/script/test_20_in_mic.go @@ -10,7 +10,8 @@ import ( "time" ) -var micCodes = []string{"1000653", "1000516", "1000675", "1000890", "1000755", "1000593", "1000629", "1000634", "1000765", "1000591", "1000633", "1000224", "1000611", "1000689", "1000467", "1000384", "1000367", "1000623"} +//var micCodes = []string{"1000653", "1000516", "1000675", "1000890", "1000755", "1000593", "1000629", "1000634", "1000765", "1000591", "1000633", "1000224", "1000611", "1000689", "1000467", "1000384", "1000367", "1000623"} +var micCodes = []string{"1110189", "1110188", "1110186", "1110183", "1110180", "1110175", "1110170", "1110160", "1110158", "1110154", "1110152", "1110150", "1110141", "1110139", "1110130", "199777", "1110124", "1110122", "1110120", "1110118"} func main() { var users []model.User @@ -21,7 +22,7 @@ func main() { url := "https://test.apiv1.faceline.live/v1/imGroup/mic/in" method := "POST" - payload := strings.NewReader("groupUuid=HTGS%23a56194639&i=") + payload := strings.NewReader("groupUuid=HTGS%23a50923362&i=") client := &http.Client{} req, err := http.NewRequest(method, url, payload)