Commit 96e3c960 authored by hujiebin's avatar hujiebin

feat

parent 029c199c
This diff is collapsed.
...@@ -25,7 +25,7 @@ func main() { ...@@ -25,7 +25,7 @@ func main() {
}() }()
// 获取所有以"user_qps_"为前缀的键 // 获取所有以"user_qps_"为前缀的键
keys, err := getKeysWithPrefix(client, "group_in_user_duration_") keys, err := getKeysWithPrefix(client, "lobby:match:msg:")
if err != nil { if err != nil {
log.Fatalf("Failed to get keys with prefix: %v", err) log.Fatalf("Failed to get keys with prefix: %v", err)
} }
......
package main
import (
"encoding/json"
"fmt"
"github.com/tealeg/xlsx"
"io/ioutil"
"net/http"
)
type FruitDayDetailResp struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data struct {
Total int `json:"total,omitempty"`
Data []struct {
Date string `json:"Date,omitempty"`
Round int `json:"Round,omitempty"`
Pool int `json:"Pool,omitempty"`
UserNum int `json:"UserNum,omitempty"`
Stake int `json:"Stake,omitempty"`
Total int `json:"Total,omitempty"`
AwardNum int `json:"AwardNum,omitempty"`
Award int `json:"Award,omitempty"`
Recycle int `json:"Recycle,omitempty"`
LeftOver int `json:"LeftOver,omitempty"`
FruitId uint64 `json:"FruitId"`
} `json:"data,omitempty"`
} `json:"data,omitempty"`
}
func ats48(a interface{}) string {
return fmt.Sprintf("%v", a)
}
func main() {
url := "http://43.135.4.137:8088/v1/fruitMachine/day/detail?lang=zh-cn&pageIndex=1&pageSize=10000&date=2025-11-11"
method := "GET"
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("nonce", "hilo")
req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjEsIkV4dGVybmFsSWQiOiIiLCJleHAiOjE3MTk3NDMzNDd9.O9UCpSAR82xW_w9wKNXOP5jW3lfX5TPYkv8un8Gu1q8")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
var response = new(FruitDayDetailResp)
json.Unmarshal(body, &response)
excelFileName := fmt.Sprintf("./水果机每日明细.xlsx")
xlFile := xlsx.NewFile()
sheet, _ := xlFile.AddSheet("charge")
row := sheet.AddRow()
c1, c2, c3, c4, c5, c6, c7 := 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 = "轮次", "开奖位置", "投注", "奖励", "奖池盈余", "系统回收", "本轮盈余"
for _, d := range response.Data.Data {
row := sheet.AddRow()
c1, c2, c3, c4, c5, c6, c7 := 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 = ats48(d.Round), ats48(d.FruitId), ats48(d.Stake), ats48(d.Award), ats48(d.Pool), ats48(d.Recycle), ats48(d.LeftOver)
}
_ = xlFile.Save(excelFileName)
}
...@@ -36,7 +36,8 @@ func ats28(a interface{}) string { ...@@ -36,7 +36,8 @@ func ats28(a interface{}) string {
} }
func main() { func main() {
url := "https://apiv2.faceline.live/v1/fruitMachine/day/stats?lang=zh-cn&pageIndex=1&pageSize=100000&beginDate=2023-04-01&endDate=2023-06-31" //url := "https://apiv2.faceline.live/v1/fruitMachine/day/stats?lang=zh-cn&pageIndex=1&pageSize=100000&beginDate=2024-04-01&endDate=2024-06-30"
url := "https://apiv2.faceline.live/v1/race/day/stats?lang=zh-cn&pageIndex=1&pageSize=100000&beginDate=2024-04-01&endDate=2024-06-30"
method := "GET" method := "GET"
client := &http.Client{} client := &http.Client{}
...@@ -47,7 +48,7 @@ func main() { ...@@ -47,7 +48,7 @@ func main() {
return return
} }
req.Header.Add("nonce", "hilo") req.Header.Add("nonce", "hilo")
req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTY5MDYwOTY4NX0.dVsFGjc1wLPxqhAMloXICs-xQcVxM5FkweLvFta3ncA") req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcyMjczNzEzMH0.LZDmjeRkUiYIQA7hVnbb6_xFQtyGf9yev-y6NQqVhRY")
res, err := client.Do(req) res, err := client.Do(req)
if err != nil { if err != nil {
...@@ -63,7 +64,7 @@ func main() { ...@@ -63,7 +64,7 @@ func main() {
} }
var response = new(AutoGenerated) var response = new(AutoGenerated)
json.Unmarshal(body, &response) json.Unmarshal(body, &response)
excelFileName := fmt.Sprintf("./水果机每日统计.xlsx") excelFileName := fmt.Sprintf("./赛车每日统计-4-6月.xlsx")
xlFile := xlsx.NewFile() xlFile := xlsx.NewFile()
sheet, _ := xlFile.AddSheet("charge") sheet, _ := xlFile.AddSheet("charge")
row := sheet.AddRow() row := sheet.AddRow()
......
...@@ -19,7 +19,7 @@ func ats42(a interface{}) string { ...@@ -19,7 +19,7 @@ func ats42(a interface{}) string {
return fmt.Sprintf("%v", a) return fmt.Sprintf("%v", a)
} }
var start, end = "2024-05-20 05:00:00", "2024-05-27 05:00:00" // 左闭右开,沙特时间 var start, end = "2024-05-27 05:00:00", "2024-06-03 05:00:00" // 左闭右开,沙特时间
func main() { func main() {
...@@ -58,7 +58,7 @@ func main() { ...@@ -58,7 +58,7 @@ func main() {
charges[i].Bet = bets[uc.UserId] charges[i].Bet = bets[uc.UserId]
} }
excelFileName := fmt.Sprintf("./5月20日-5月26日水果机slot赛车数据.xlsx") excelFileName := fmt.Sprintf("./5月27日-6月02日水果机slot赛车数据.xlsx")
xlFile := xlsx.NewFile() xlFile := xlsx.NewFile()
sheet, err := xlFile.AddSheet("data") sheet, err := xlFile.AddSheet("data")
if err != nil { if err != nil {
......
...@@ -43,7 +43,7 @@ func main() { ...@@ -43,7 +43,7 @@ func main() {
pageIndex := 1 pageIndex := 1
pageSize := 1000 pageSize := 1000
for { for {
url := fmt.Sprintf("https://apiv2.faceline.live/v1/mgr/promotion/invite/data?lang=zh-cn&pageIndex=%d&pageSize=%d&startTime=2023-12-01&endTime=2024-03-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=2024-01-01&endTime=2024-06-30&teamName=&agentCode=&inviteeCode=&platform=All",
pageIndex, pageSize) pageIndex, pageSize)
method := "GET" method := "GET"
...@@ -55,7 +55,7 @@ func main() { ...@@ -55,7 +55,7 @@ func main() {
return return
} }
req.Header.Add("nonce", "hilo") req.Header.Add("nonce", "hilo")
req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcxNDcxNjcyOH0.Mt_gpOenB25vRXDFM4u-oReTNMBYgS7ZvzQumQHOuvU") req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcyMjczNzEzMH0.LZDmjeRkUiYIQA7hVnbb6_xFQtyGf9yev-y6NQqVhRY")
res, err := client.Do(req) res, err := client.Do(req)
if err != nil { if err != nil {
...@@ -80,7 +80,7 @@ func main() { ...@@ -80,7 +80,7 @@ func main() {
data = append(data, resp.Data.Items...) data = append(data, resp.Data.Items...)
pageIndex++ pageIndex++
} }
excelFileName := fmt.Sprintf("./推广员数据12月1日-3月31日.xlsx") excelFileName := fmt.Sprintf("./推广员数据1月1日-6月30日.xlsx")
xlFile := xlsx.NewFile() xlFile := xlsx.NewFile()
sheet, err := xlFile.AddSheet("promotion") sheet, err := xlFile.AddSheet("promotion")
if err != nil { if err != nil {
......
...@@ -3,9 +3,11 @@ package main ...@@ -3,9 +3,11 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx" "github.com/tealeg/xlsx"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"time"
) )
type AutoGenerated34 struct { type AutoGenerated34 struct {
...@@ -18,7 +20,7 @@ type AutoGenerated34 struct { ...@@ -18,7 +20,7 @@ type AutoGenerated34 struct {
} }
type AutoGenerated34Data struct { type AutoGenerated34Data struct {
UserID int `json:"userId"` UserID uint64 `json:"userId"`
Date string `json:"date"` Date string `json:"date"`
Country string `json:"country"` Country string `json:"country"`
UserCode string `json:"userCode"` UserCode string `json:"userCode"`
...@@ -29,6 +31,9 @@ type AutoGenerated34Data struct { ...@@ -29,6 +31,9 @@ type AutoGenerated34Data struct {
SvipLevel int `json:"svipLevel"` SvipLevel int `json:"svipLevel"`
MaxDollar int `json:"maxDollar"` // 历史最高单笔 MaxDollar int `json:"maxDollar"` // 历史最高单笔
MaxDollarDuration int `json:"maxDollarDuration"` // 时段最高单笔 MaxDollarDuration int `json:"maxDollarDuration"` // 时段最高单笔
Phone string `json:"phone"`
Charm int `json:"charm"`
LastRequestTime string `json:"lastRequestTime"`
} }
func ats34(a interface{}) string { func ats34(a interface{}) string {
...@@ -42,7 +47,7 @@ func main() { ...@@ -42,7 +47,7 @@ func main() {
pageIndex := 1 pageIndex := 1
pageSize := 1000 pageSize := 1000
for { for {
url := fmt.Sprintf("https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=1&beginDate=2024-03-01&endDate=2024-03-31&pageIndex=%d&pageSize=%d&country=All&code=&area=2&timezone=0", url := fmt.Sprintf("https://apiv2.faceline.live/v1/stats/charge/user?lang=zh-cn&diamondType=1&beginDate=2020-01-01&endDate=2024-07-05&pageIndex=%d&pageSize=%d&country=All&code=&area=2&timezone=0",
pageIndex, pageSize) pageIndex, pageSize)
method := "GET" method := "GET"
...@@ -54,7 +59,7 @@ func main() { ...@@ -54,7 +59,7 @@ func main() {
return return
} }
req.Header.Add("nonce", "hilo") req.Header.Add("nonce", "hilo")
req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcxNDcxNjcyOH0.Mt_gpOenB25vRXDFM4u-oReTNMBYgS7ZvzQumQHOuvU") req.Header.Add("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcyMjczNzEzMH0.LZDmjeRkUiYIQA7hVnbb6_xFQtyGf9yev-y6NQqVhRY")
res, err := client.Do(req) res, err := client.Do(req)
if err != nil { if err != nil {
...@@ -78,17 +83,97 @@ func main() { ...@@ -78,17 +83,97 @@ func main() {
data = append(data, response.Data.Data...) data = append(data, response.Data.Data...)
pageIndex++ pageIndex++
} }
excelFileName := fmt.Sprintf("./非阿语区黄钻充值20243月.xlsx") var userIds []uint64
for _, v := range data {
userIds = append(userIds, v.UserID)
}
phones := GetPhones(userIds)
charms := GetUserCharmLevel(userIds)
requsets := GetRequestLast(userIds)
for i, v := range data {
data[i].Phone = phones[v.UserID]
data[i].Charm = charms[v.UserID]
data[i].LastRequestTime = requsets[v.UserID]
}
excelFileName := fmt.Sprintf("./非阿语区黄钻充值202001-至今.xlsx")
xlFile := xlsx.NewFile() xlFile := xlsx.NewFile()
sheet, _ := xlFile.AddSheet("charge") sheet, _ := xlFile.AddSheet("charge")
row := sheet.AddRow() row := sheet.AddRow()
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, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13 := row.AddCell(), row.AddCell(), row.AddCell(), 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等级", "时段最高单笔", "历史最高单笔" c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value, c8.Value, c9.Value, c10.Value, c11.Value, c12.Value, c13.Value = "日期", "国家", "用户ID", "用户昵称", "充值金额", "注册时间", "是否举办首场活动", "svip等级", "时段最高单笔", "历史最高单笔", "手机号", "魅力等级", "最后登陆时间"
for _, d := range data { for _, d := range data {
row := sheet.AddRow() row := sheet.AddRow()
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, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13 := row.AddCell(), row.AddCell(), row.AddCell(), 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) 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, c9.Value, c10.Value = ats34(d.HaveFirst), ats34(d.SvipLevel), ats34(d.MaxDollarDuration), ats34(d.MaxDollar) c7.Value, c8.Value, c9.Value, c10.Value, c11.Value, c12.Value, c13.Value = ats34(d.HaveFirst), ats34(d.SvipLevel), ats34(d.MaxDollarDuration), ats34(d.MaxDollar), d.Phone, ats34(d.Charm), d.LastRequestTime
} }
_ = xlFile.Save(excelFileName) _ = xlFile.Save(excelFileName)
} }
type UserBindInfo struct {
UserId uint64 `gorm:"column:user_id"`
Phone string `gorm:"column:phone"` // 手机号码(包含区号)
AreaCode string `gorm:"column:area_code"` // 国家区号
}
func (UserBindInfo) TableName() string {
return "user_bind_info"
}
func GetPhones(userIds []uint64) map[uint64]string {
var rows []UserBindInfo
if err := mysql.ProdReadOnlyDB.Model(UserBindInfo{}).Where("user_id in ?", userIds).Find(&rows).Error; err != nil {
panic(err)
}
var res = make(map[uint64]string)
for _, v := range rows {
res[v.UserId] = v.AreaCode + v.Phone
}
return res
}
// MatchCharmUserScore 用户魅力分数
type MatchCharmUserScore struct {
UserId uint64 `gorm:"column:user_id"` // user_id
Score int64 `gorm:"column:score"` // 分数
Grade int `gorm:"column:grade"` // 等级
}
func (MatchCharmUserScore) TableName() string {
return "match_charm_user_score"
}
func GetUserCharmLevel(userIds []uint64) map[uint64]int {
var rows []MatchCharmUserScore
if err := mysql.ProdReadOnlyDB.Model(MatchCharmUserScore{}).Where("user_id in ?", userIds).Find(&rows).Error; err != nil {
panic(err)
}
res := make(map[uint64]int)
for _, v := range rows {
res[v.UserId] = v.Grade
}
return res
}
// UserRequestLast 用户请求最后时间
type UserRequestLast struct {
ID int64 `gorm:"column:id"` // id
UserId uint64 `gorm:"column:user_id"` // 用户id
TimeLast time.Time `gorm:"column:time_last"` // 最后的时间
}
func (UserRequestLast) TableName() string {
return "user_request_last"
}
func GetRequestLast(userIds []uint64) map[uint64]string {
var rows []UserRequestLast
if err := mysql.ProdReadOnlyDB.Model(UserRequestLast{}).Where("user_id in ?", userIds).Find(&rows).Error; err != nil {
panic(err)
}
res := make(map[uint64]string)
for _, v := range rows {
res[v.UserId] = v.TimeLast.Format("2006-01-02 15:04:05")
}
return res
}
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"time" "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"} 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() { func main() {
...@@ -22,7 +22,7 @@ func main() { ...@@ -22,7 +22,7 @@ func main() {
url := "https://test.apiv1.faceline.live/v1/imGroup/mic/in" url := "https://test.apiv1.faceline.live/v1/imGroup/mic/in"
method := "POST" method := "POST"
payload := strings.NewReader("groupUuid=HTGS%23a50923362&i=") payload := strings.NewReader("groupUuid=HTGS_3HIKK4QIV&i=")
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest(method, url, payload) req, err := http.NewRequest(method, url, payload)
......
...@@ -12,7 +12,7 @@ type Claims struct { ...@@ -12,7 +12,7 @@ type Claims struct {
jwt.StandardClaims jwt.StandardClaims
} }
//生成token // 生成token
func GenerateToken(userId uint64, externalId string, issuer string) (string, error) { func GenerateToken(userId uint64, externalId string, issuer string) (string, error) {
duration, err := time.ParseDuration("240h") duration, err := time.ParseDuration("240h")
if err != nil { if err != nil {
...@@ -37,7 +37,7 @@ func GetJWTSecret() []byte { ...@@ -37,7 +37,7 @@ func GetJWTSecret() []byte {
return []byte("hilo1632") return []byte("hilo1632")
} }
//解析token // 解析token
func ParseToken(token string) (*Claims, error) { func ParseToken(token string) (*Claims, error) {
tokenClaims, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) { tokenClaims, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) {
return GetJWTSecret(), nil return GetJWTSecret(), nil
......
...@@ -15,6 +15,6 @@ func TestJwt(t *testing.T) { ...@@ -15,6 +15,6 @@ func TestJwt(t *testing.T) {
} }
func TestJwtParse(t *testing.T) { func TestJwtParse(t *testing.T) {
c, err := jwt.ParseToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjQyNDAyNjEsIkV4dGVybmFsSWQiOiI0MTIwOWU5NTE0ZDI0ODQwYTliNTMxMDgyMWViNjRkNiIsImV4cCI6MTY5MjI2MTIxNiwiaXNzIjoiaGlsb0FwaSJ9.2ru292Z1q8p87Chzp5DWrR1hMHO3sQcD1X3QNwOio2U") c, _ := jwt.ParseToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjg4Nzc2OTEsIkV4dGVybmFsSWQiOiJkNmZlNmJhN2E3ZTI0NjRiYjhhNmU3OTFlNmQxY2E5ZCIsIlRva2VuVmVyc2lvbiI6NywiZXhwIjoxNzE5NTczOTkzLCJpc3MiOiJoaWxvQXBpIn0.EWSFvxzyPDRLWA5eNQ_MSrUDlAeoMhmn0RKw4vfvL6k")
println(c, err) println(c.UserId)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment