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) }