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
2057e602
Commit
2057e602
authored
Mar 14, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update fruit_machine_charge.go
parent
5cda68e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
17 deletions
+53
-17
fruit_machine_charge.go
script/fruit_machine_charge.go
+53
-17
No files found.
script/fruit_machine_charge.go
View file @
2057e602
...
...
@@ -15,6 +15,9 @@ type FruitDayChargeData struct {
DayChargeUserIds
[]
uint64
// 当日充值用户id
DayChargeMoney
int64
// 当日充值金额
ChargeRecycle
float64
// 充值用户回收 M
Top100DayChargeCnt
int
// 投注榜TOP100的充值用户数
Top100DayChargeMoney
int64
// 投注榜TOP100的当日充值金额
Top100ChargeRecycle
float64
// 投注榜TOP100的回收
}
func
ats2
(
a
interface
{})
string
{
...
...
@@ -33,10 +36,20 @@ func main() {
var
data
[]
FruitDayChargeData
for
startTime
.
Before
(
endTime
)
{
var
userIds
[]
uint64
var
top100UserIds
[]
uint64
date
:=
startTime
.
Format
(
"2006-01-02"
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_stake"
)
.
Where
(
"`date` = ?"
,
date
)
.
Group
(
"user_id"
)
.
Select
(
"user_id"
)
.
Scan
(
&
userIds
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_stake"
)
.
Where
(
"`date` = ?"
,
date
)
.
Group
(
"user_id"
)
.
Order
(
"SUM(stake) DESC"
)
.
Limit
(
100
)
.
Select
(
"user_id"
)
.
Scan
(
&
top100UserIds
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
top100UserIdMap
:=
make
(
map
[
uint64
]
struct
{})
for
_
,
userId
:=
range
top100UserIds
{
top100UserIdMap
[
userId
]
=
struct
{}{}
}
um1
,
err
:=
GetDateChargeUserAndMoney
(
date
,
userIds
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -46,19 +59,33 @@ func main() {
panic
(
err
)
}
userChargeNum
:=
make
(
map
[
uint64
]
struct
{})
top100UserChargeNum
:=
make
(
map
[
uint64
]
struct
{})
userChargeMoney
:=
int64
(
0
)
top100UserChargeMoney
:=
int64
(
0
)
for
_
,
um
:=
range
um1
{
userChargeNum
[
um
.
UserId
]
=
struct
{}{}
userChargeMoney
+=
um
.
Money
if
_
,
ok
:=
top100UserIdMap
[
um
.
UserId
];
ok
{
top100UserChargeNum
[
um
.
UserId
]
=
struct
{}{}
top100UserChargeMoney
+=
um
.
Money
}
}
for
_
,
um
:=
range
um2
{
userChargeNum
[
um
.
UserId
]
=
struct
{}{}
userChargeMoney
+=
um
.
Money
if
_
,
ok
:=
top100UserIdMap
[
um
.
UserId
];
ok
{
top100UserChargeNum
[
um
.
UserId
]
=
struct
{}{}
top100UserChargeMoney
+=
um
.
Money
}
}
var
chargeUserIds
[]
uint64
for
userId
:=
range
userChargeNum
{
chargeUserIds
=
append
(
chargeUserIds
,
userId
)
}
var
top100ChargeUserIds
[]
uint64
for
userId
:=
range
top100UserChargeNum
{
top100ChargeUserIds
=
append
(
top100ChargeUserIds
,
userId
)
}
userNum
,
err
:=
GetFruitUserNum
(
date
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -71,6 +98,10 @@ func main() {
if
err
!=
nil
{
panic
(
err
)
}
top100FruitChargeRecycle
,
err
:=
GetFruitChargeRecycle
(
date
,
top100ChargeUserIds
)
if
err
!=
nil
{
panic
(
err
)
}
data
=
append
(
data
,
FruitDayChargeData
{
Date
:
date
,
FruitUserNum
:
userNum
,
...
...
@@ -79,6 +110,9 @@ func main() {
DayChargeUserIds
:
userIds
,
DayChargeMoney
:
userChargeMoney
,
ChargeRecycle
:
float64
(
fruitChargeRecycle
)
*
0.05
/
1000000
,
// 1M
Top100DayChargeCnt
:
len
(
top100UserChargeNum
),
Top100DayChargeMoney
:
top100UserChargeMoney
,
Top100ChargeRecycle
:
float64
(
top100FruitChargeRecycle
)
*
0.05
/
1000000
,
// 1M
})
startTime
=
startTime
.
AddDate
(
0
,
0
,
1
)
}
...
...
@@ -87,12 +121,14 @@ func main() {
xlFile
:=
xlsx
.
NewFile
()
sheet
,
_
:=
xlFile
.
AddSheet
(
"charge"
)
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
,
c6
.
Value
=
"日期"
,
"参与人数"
,
"总回收 M"
,
"当日充值用户数"
,
"当日充值金额(美分)"
,
"充值用户回收 M"
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
:=
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
=
"日期"
,
"参与人数"
,
"总回收 M"
,
"当日充值用户数"
,
"当日充值金额(美分)"
,
"充值用户回收 M"
,
"投注榜TOP100的充值用户数"
,
"投注榜TOP100的当日充值金额(美分)"
,
"投注榜TOP100的回收"
for
_
,
d
:=
range
data
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
:=
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
=
d
.
Date
,
ats2
(
d
.
FruitUserNum
),
ats2
(
d
.
Recycle
),
ats2
(
d
.
DayChargeCnt
),
ats2
(
d
.
DayChargeMoney
),
ats2
(
d
.
ChargeRecycle
)
c7
.
Value
,
c8
.
Value
,
c9
.
Value
=
ats2
(
d
.
Top100DayChargeCnt
),
ats2
(
d
.
Top100DayChargeMoney
),
ats2
(
d
.
Top100ChargeRecycle
)
}
_
=
xlFile
.
Save
(
excelFileName
)
}
...
...
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