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
f20aca1a
Commit
f20aca1a
authored
Jun 21, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:补充两个列
parent
86981200
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
11 deletions
+52
-11
cp_pairs_stat.go
script/cp_pairs_stat.go
+52
-11
No files found.
script/cp_pairs_stat.go
View file @
f20aca1a
...
...
@@ -5,13 +5,17 @@ import (
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
"time"
)
type
CpPairData
struct
{
Level
string
Cnt
int
KsaCnt
int
NotKsaCnt
int
// cp等级积分
var
CpLevelPoints
=
map
[
uint64
]
uint64
{
0
:
0
,
1
:
200000
,
2
:
800000
,
3
:
1000000
,
4
:
3000000
,
5
:
10000000
,
}
func
ats26
(
a
interface
{})
string
{
...
...
@@ -30,6 +34,38 @@ func getAreaByCode2(code string) string {
return
"非阿语区"
}
func
getChargeMoneyDiamond
(
uid
uint64
,
sinceTime
time
.
Time
)
int64
{
type
R
struct
{
Money
int64
Diamond
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"
,
uid
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)})
.
Where
(
"d.created_time >= ?"
,
sinceTime
)
.
Order
(
"d.user_id"
)
.
Select
(
"SUM(p.price) as money,SUM(d.num) as diamond"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
}
type
R2
struct
{
Price
int64
Diamond
int64
}
var
money2
R2
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"
,
uid
,
26
)
.
Select
(
"SUM(t.dollar) as price,SUM(d.num) as diamond"
)
.
Where
(
"d.created_time >= ?"
,
sinceTime
)
.
Order
(
"d.user_id"
)
.
Scan
(
&
money2
)
.
Error
;
err
!=
nil
{
return
0
}
return
money
.
Money
+
money2
.
Price
}
type
CpInfo
struct
{
Id
uint64
UserId1
uint64
...
...
@@ -39,6 +75,9 @@ type CpInfo struct {
UserId1Area
string
UserId2Area
string
Level
uint64
Points
uint64
CreatedTime
time
.
Time
Charge
float64
}
type
CpLevel
struct
{
...
...
@@ -48,7 +87,7 @@ type CpLevel struct {
func
main
()
{
var
cpInfos
[]
CpInfo
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"cp_relation"
)
.
Select
(
"id,user_id1,user_id2"
)
.
Find
(
&
cpInfos
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"cp_relation"
)
.
Select
(
"id,user_id1,user_id2
,created_time
"
)
.
Find
(
&
cpInfos
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
cpIds
[]
uint64
...
...
@@ -83,6 +122,8 @@ func main() {
cpInfos
[
i
]
.
Code2
=
uM
[
v
.
UserId2
]
.
Code
cpInfos
[
i
]
.
UserId1Area
=
getAreaByCode2
(
uM
[
v
.
UserId1
]
.
Code
)
cpInfos
[
i
]
.
UserId2Area
=
getAreaByCode2
(
uM
[
v
.
UserId2
]
.
Code
)
cpInfos
[
i
]
.
Points
=
v
.
Points
+
CpLevelPoints
[
v
.
Level
]
cpInfos
[
i
]
.
Charge
=
float64
(
getChargeMoneyDiamond
(
v
.
UserId1
,
v
.
CreatedTime
)
+
getChargeMoneyDiamond
(
v
.
UserId2
,
v
.
CreatedTime
))
/
100
}
excelFileName
:=
fmt
.
Sprintf
(
"./cp数据.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
...
...
@@ -91,13 +132,13 @@ func main() {
panic
(
err
)
}
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
=
"cp ID"
,
"userId1"
,
"userId2"
,
"user1区域"
,
"user2区域"
,
"等级
"
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
:=
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
=
"cp ID"
,
"userId1"
,
"userId2"
,
"user1区域"
,
"user2区域"
,
"等级"
,
"积分"
,
"绑定后充值金额 $
"
for
_
,
d
:=
range
cpInfos
{
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
=
ats26
(
d
.
Id
),
ats26
(
d
.
Code1
),
ats26
(
d
.
Code2
),
ats26
(
d
.
UserId1Area
),
ats26
(
d
.
UserId2Area
),
ats26
(
d
.
Level
)
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
:=
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
=
ats26
(
d
.
Id
),
ats26
(
d
.
Code1
),
ats26
(
d
.
Code2
),
ats26
(
d
.
UserId1Area
),
ats26
(
d
.
UserId2Area
),
ats26
(
d
.
Level
)
,
ats26
(
d
.
Points
),
ats26
(
d
.
Charge
)
}
_
=
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