diff --git a/script/Makefile b/script/Makefile index 4a6e1bf8135f17a9caeb176a42ec9ea8022a9c85..b1ccec347022f18d46f6029e1932192f0535ee82 100644 --- a/script/Makefile +++ b/script/Makefile @@ -26,4 +26,6 @@ race_day_award: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o race_day_award race_day_award.go race_ksa_rank: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o race_ksa_rank race_ksa_rank.go +promotion_data: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o promotion_data promotion_data.go diff --git a/script/promotion_data.go b/script/promotion_data.go new file mode 100644 index 0000000000000000000000000000000000000000..8eab1584bd34c6f48082df9abd378d6620ffef82 --- /dev/null +++ b/script/promotion_data.go @@ -0,0 +1,102 @@ +package main + +import ( + "encoding/json" + "fmt" + "github.com/tealeg/xlsx" + "io/ioutil" + "net/http" +) + +type PromotionData struct { + ID int `json:"id"` + AgentCode string `json:"agentCode"` // 推广员id + Name string `json:"name"` // 团队名称 + InviteeCode string `json:"inviteeCode"` // 被邀请人id + Platform string `json:"platform"` // 来自平台 + PlatformId string `json:"platformId"` // 平台ID + Reason string `json:"reason"` // 邀请原因 + GroupCode string `json:"groupCode"` // 群组ID + GroupMemberNum uint `json:"groupMemberNum"` // 群组人数 + GroupTotalConsume uint64 `json:"groupTotalConsume"` // 群组奖杯 + InviteDate string `json:"inviteDate"` // 邀请日期 + MonthPaySum float64 `json:"monthPaySum"` // 30天内充值 $ + TwoMonthPaySum float64 `json:"twoMonthPaySum"` // 60天内充值 $ + MonthDealPaySum float64 `json:"monthDealPaySum"` // 30天内代理充值 $ +} + +type PromotionDataResp struct { + Code int `json:"code"` + Message string `json:"message"` + Data struct { + Total int `json:"total"` + Items []PromotionData `json:"items"` + } `json:"data"` +} + +func ats37(a interface{}) string { + return fmt.Sprintf("%v", a) +} + +func main() { + var data []PromotionData + 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", + pageIndex, pageSize) + 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.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTcwMjU0NjkzMX0.-3OB6g_T9sX4XZIh3BaDlG7uSpYkRAcOh6PobBFyOKA") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + _ = res.Body.Close() + var resp PromotionDataResp + err = json.Unmarshal(body, &resp) + if err != nil { + panic(err) + } + if len(resp.Data.Items) <= 0 { + break + } + data = append(data, resp.Data.Items...) + pageIndex++ + } + excelFileName := fmt.Sprintf("./推广员数据10月.xlsx") + xlFile := xlsx.NewFile() + sheet, err := xlFile.AddSheet("promotion") + if err != nil { + panic(err) + } + row := sheet.AddRow() + 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, c11.Value, c12.Value, c13.Value = "推广员id", "团队名称", "被邀请人id", "来自平台", + "平台ID", "邀请原因", "群组ID", "群组人数", "群组奖杯", "邀请日期", "30天内充值 $", "60天内充值 $", "30天内代理充值 $" + for _, d := range data { + row := sheet.AddRow() + 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, c11.Value, c12.Value, c13.Value = + ats37(d.AgentCode), ats37(d.Name), ats37(d.InviteeCode), ats37(d.Platform), ats37(d.PlatformId), ats37(d.Reason), ats37(d.GroupCode), ats37(d.GroupMemberNum), ats37(d.GroupTotalConsume), ats37(d.InviteDate), + ats37(d.MonthPaySum), ats37(d.TwoMonthPaySum), ats37(d.MonthDealPaySum) + } + _ = xlFile.Save(excelFileName) +}