Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
ef3cced0
Commit
ef3cced0
authored
Nov 11, 2023
by
iamhujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create game_race_1m.go
parent
445e2dff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
game_race_1m.go
script/game_race_1m.go
+56
-0
No files found.
script/game_race_1m.go
0 → 100644
View file @
ef3cced0
package
main
import
(
"fmt"
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
)
type
GameRacePlayer
struct
{
Date
string
Round
int
Award
int64
Stake
int64
Code
string
UserId
uint64
}
func
main
()
{
var
rows
[]
GameRacePlayer
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"game_race_player"
)
.
Select
(
"`date`,round,user_id,award,u.code"
)
.
Joins
(
"JOIN user u ON u.id = user_id"
)
.
Where
(
"award >= 1000000 AND `date` = '2023-11-06'"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
i
,
v
:=
range
rows
{
var
user
model
.
User
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"user"
)
.
Where
(
"id = ?"
,
v
.
UserId
)
.
First
(
&
user
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
rows
[
i
]
.
Code
=
user
.
Code
var
stake
int64
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"game_race_stake"
)
.
Select
(
"SUM(stake)"
)
.
Where
(
"`date` = ? AND round = ? AND user_id = ?"
,
v
.
Date
,
v
.
Round
,
v
.
UserId
)
.
Scan
(
&
stake
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
rows
[
i
]
.
Stake
=
stake
}
excelFileName
:=
fmt
.
Sprintf
(
"./赛车1M.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
_
:=
xlFile
.
AddSheet
(
"race"
)
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
=
"用户ID"
,
"轮次"
,
"投注"
,
"中奖"
for
_
,
d
:=
range
rows
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
=
ats37
(
d
.
Code
),
ats37
(
d
.
Round
),
ats37
(
d
.
Stake
),
ats37
(
d
.
Award
)
}
_
=
xlFile
.
Save
(
excelFileName
)
}
func
ats37
(
d
interface
{})
string
{
return
fmt
.
Sprintf
(
"%v"
,
d
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment