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
1f4a82ea
Commit
1f4a82ea
authored
Apr 10, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ksa的同步
parent
a1f37709
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
sync_fruit_rank.go
script/sync_fruit_rank.go
+18
-8
No files found.
script/sync_fruit_rank.go
View file @
1f4a82ea
...
...
@@ -12,6 +12,13 @@ type FruitDayRank struct {
Award
int64
}
type
FruitDayRankKsa
struct
{
Period
string
UserId
uint64
Stake
int64
Award
int64
}
type
FruitMachineStake
struct
{
Date
string
UserId
uint64
...
...
@@ -24,17 +31,19 @@ type FruitMachineAward struct {
Award
int64
}
var
Cstzone
=
time
.
FixedZone
(
"CST"
,
3
*
3600
)
// 东三
func
main
()
{
start
:=
time
.
Date
(
2023
,
time
.
January
,
1
,
0
,
0
,
0
,
0
,
time
.
Local
)
start
:=
time
.
Date
(
2023
,
time
.
January
,
2
,
0
,
0
,
0
,
0
,
Cstzone
)
for
start
.
Before
(
time
.
Now
())
{
var
rows
[]
FruitMachineStake
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_stake
"
)
.
Where
(
"`date`
= ?"
,
start
.
Format
(
"2006-01-02"
))
.
Select
(
"`date`,user_id,SUM(stake) stake"
)
.
Group
(
"
`date`
,user_id"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_stake
FORCE INDEX(created_time)"
)
.
Where
(
"DATE(`created_time`)
= ?"
,
start
.
Format
(
"2006-01-02"
))
.
Select
(
"`date`,user_id,SUM(stake) stake"
)
.
Group
(
"
DATE(`created_time`)
,user_id"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
row
:=
range
rows
{
if
err
:=
mysql
.
ProdWriteDB
.
Create
(
FruitDayRank
{
Period
:
row
.
Date
,
if
err
:=
mysql
.
ProdWriteDB
.
Create
(
FruitDayRank
Ksa
{
Period
:
start
.
Format
(
"2006-01-02"
)
,
UserId
:
row
.
UserId
,
Stake
:
row
.
Stake
,
Award
:
0
,
...
...
@@ -43,16 +52,17 @@ func main() {
}
}
var
rows2
[]
FruitMachineAward
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_player
"
)
.
Where
(
"`date`
= ?"
,
start
.
Format
(
"2006-01-02"
))
.
Select
(
"`date`,user_id,SUM(award) award"
)
.
Group
(
"
`date`
,user_id"
)
.
Find
(
&
rows2
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_player
FORCE INDEX(created_time)"
)
.
Where
(
"DATE(`created_time`)
= ?"
,
start
.
Format
(
"2006-01-02"
))
.
Select
(
"`date`,user_id,SUM(award) award"
)
.
Group
(
"
DATE(`created_time`)
,user_id"
)
.
Find
(
&
rows2
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
row
:=
range
rows2
{
if
err
:=
mysql
.
ProdWriteDB
.
Table
(
"fruit_day_rank"
)
.
Where
(
"period = ? AND user_id = ?"
,
start
.
Format
(
"2006-01-02"
),
row
.
UserId
)
.
if
err
:=
mysql
.
ProdWriteDB
.
Table
(
"fruit_day_rank
_ksa
"
)
.
Where
(
"period = ? AND user_id = ?"
,
start
.
Format
(
"2006-01-02"
),
row
.
UserId
)
.
Update
(
"award"
,
row
.
Award
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
}
start
=
start
.
AddDate
(
0
,
0
,
1
)
//break
}
}
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