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
5cda68e6
Commit
5cda68e6
authored
Mar 14, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update fruit_machine_charge.go
parent
c2fdaaf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
fruit_machine_charge.go
script/fruit_machine_charge.go
+16
-9
No files found.
script/fruit_machine_charge.go
View file @
5cda68e6
...
...
@@ -32,12 +32,16 @@ func main() {
endTime
:=
time
.
Date
(
2023
,
time
.
March
,
1
,
0
,
0
,
0
,
0
,
time
.
Local
)
var
data
[]
FruitDayChargeData
for
startTime
.
Before
(
endTime
)
{
var
userIds
[]
uint64
date
:=
startTime
.
Format
(
"2006-01-02"
)
um1
,
err
:=
GetDateChargeUserAndMoney
(
date
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"fruit_machine_stake"
)
.
Where
(
"`date` = ?"
,
date
)
.
Group
(
"user_id"
)
.
Select
(
"user_id"
)
.
Scan
(
&
userIds
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
um1
,
err
:=
GetDateChargeUserAndMoney
(
date
,
userIds
)
if
err
!=
nil
{
panic
(
err
)
}
um2
,
err
:=
GetUserDealerTransferUserAndMoney
(
date
)
um2
,
err
:=
GetUserDealerTransferUserAndMoney
(
date
,
userIds
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -51,9 +55,9 @@ func main() {
userChargeNum
[
um
.
UserId
]
=
struct
{}{}
userChargeMoney
+=
um
.
Money
}
var
u
serIds
[]
uint64
var
chargeU
serIds
[]
uint64
for
userId
:=
range
userChargeNum
{
userIds
=
append
(
u
serIds
,
userId
)
chargeUserIds
=
append
(
chargeU
serIds
,
userId
)
}
userNum
,
err
:=
GetFruitUserNum
(
date
)
if
err
!=
nil
{
...
...
@@ -63,7 +67,7 @@ func main() {
if
err
!=
nil
{
panic
(
err
)
}
fruitChargeRecycle
,
err
:=
GetFruitChargeRecycle
(
date
,
u
serIds
)
fruitChargeRecycle
,
err
:=
GetFruitChargeRecycle
(
date
,
chargeU
serIds
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -84,7 +88,7 @@ func main() {
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
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
,
c6
.
Value
=
"日期"
,
"参与人数"
,
"总回收 M"
,
"当日充值用户数"
,
"当日充值金额
(美分)
"
,
"充值用户回收 M"
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
()
...
...
@@ -95,12 +99,13 @@ func main() {
// 获取充值用户以及金额
// return 充值userIds,充值金额
func
GetDateChargeUserAndMoney
(
date
string
)
([]
UserAndMoney
,
error
)
{
func
GetDateChargeUserAndMoney
(
date
string
,
userIds
[]
uint64
)
([]
UserAndMoney
,
error
)
{
var
money
[]
UserAndMoney
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN pay_order AS p ON d.origin_id = p.id"
)
.
Where
(
"DATE(d.created_time) >= ? AND DATE(d.created_time) <= ? AND operate_type in (?) AND add_reduce = 1"
,
date
,
date
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)})
.
Where
(
"d.user_id in ?"
,
userIds
)
.
Group
(
"d.user_id"
)
.
Select
(
"d.user_id,SUM(p.price) as money"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
nil
,
err
...
...
@@ -110,12 +115,14 @@ func GetDateChargeUserAndMoney(date string) ([]UserAndMoney, error) {
// 获取代理充值用户以及金额
// return 充值userIds,充值金额
func
GetUserDealerTransferUserAndMoney
(
date
string
)
([]
UserAndMoney
,
error
)
{
func
GetUserDealerTransferUserAndMoney
(
date
string
,
userIds
[]
uint64
)
([]
UserAndMoney
,
error
)
{
var
money
[]
UserAndMoney
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN dealer_transfer_detail AS t ON d.origin_id = t.id"
)
.
Where
(
"DATE(d.created_time) >= ? AND DATE(d.created_time) <= ? AND operate_type = ? AND add_reduce = 1"
,
date
,
date
,
26
)
.
Select
(
"d.user_id,SUM(t.dollar) as money"
)
.
date
,
date
,
26
)
.
Where
(
"d.user_id in ?"
,
userIds
)
.
Select
(
"d.user_id,SUM(t.dollar) as money"
)
.
Group
(
"d.user_id"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
nil
,
err
...
...
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