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
b2576d93
Commit
b2576d93
authored
Feb 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:获取用户范围内充值金额
parent
dcdb599d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
user_charge.go
script/user_charge.go
+64
-0
No files found.
script/user_charge.go
0 → 100644
View file @
b2576d93
package
main
import
(
"fmt"
"github.com/hilo-common/mysql"
"time"
)
func
main
()
{
uids
:=
[]
uint64
{
889621
,
904971
,
1072931
,
1083981
,
1108951
,
1147471
,
1187511
,
1365041
,
1496521
,
1540091
,
1888121
,
2037771
,
2236221
,
2396461
,
2603721
,
2613321
,
2648851
,
2778081
,
3142631
,
3219391
,
3401561
,
3533911
,
3602511
,
3791481
,
3840571
,
3845671
,
3865481
,
3873381
,
3892321
,
4009941
}
since
,
_
:=
time
.
Parse
(
"2006-01-02"
,
"2023-02-05"
)
since
=
since
.
AddDate
(
0
,
0
,
-
7
)
var
data
[][
2
]
uint64
for
_
,
uid
:=
range
uids
{
m1
,
_
:=
GetUsersChargeMoneySum
([]
uint64
{
uid
},
since
)
m2
,
_
:=
GetUserDealerTransferMoneySum
([]
uint64
{
uid
},
since
)
data
=
append
(
data
,
[
2
]
uint64
{
uid
,
uint64
(
m1
+
m2
)})
}
for
_
,
r
:=
range
data
{
fmt
.
Println
(
r
)
}
}
// 获取用户范围内充值金额
// param sinceTime: 过去n时间内
// 返回美分
func
GetUsersChargeMoneySum
(
uids
[]
uint64
,
sinceTime
time
.
Time
)
(
int64
,
error
)
{
if
len
(
uids
)
<=
0
{
return
0
,
nil
}
type
R
struct
{
Money
int64
}
var
money
R
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN pay_order AS p ON d.origin_id = p.id"
)
.
Where
(
"d.user_id in (?) AND operate_type in (?) AND add_reduce = 1 AND d.created_time >= ?"
,
uids
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)},
sinceTime
)
.
Select
(
"SUM(p.price) as money"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
,
err
}
return
money
.
Money
,
nil
}
// 获取代理范围内总充值金额
// param sinceTime: 过去n时间内
// 返回美分
func
GetUserDealerTransferMoneySum
(
uids
[]
uint64
,
sinceTime
time
.
Time
)
(
int64
,
error
)
{
if
len
(
uids
)
<=
0
{
return
0
,
nil
}
type
R
struct
{
Price
int64
}
var
money
R
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
(
"d.user_id in (?) AND operate_type = ? AND add_reduce = 1 AND d.created_time >= ?"
,
uids
,
26
,
sinceTime
)
.
Select
(
"SUM(t.dollar) as price"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
,
err
}
return
money
.
Price
,
nil
}
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