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
c0c38910
Commit
c0c38910
authored
Jun 27, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:小助手
parent
3e071612
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
0 deletions
+131
-0
enum.go
_const/enum/msg_e/enum.go
+3
-0
Makefile
script/Makefile
+2
-0
charge_month.go
script/charge_month.go
+126
-0
No files found.
_const/enum/msg_e/enum.go
View file @
c0c38910
...
...
@@ -112,6 +112,9 @@ const (
NewUserRegisterPush1
=
44
// 首次充值免费获得永久充值勋章!累积充值$50可申请特殊ID:ABBABB!
NewUserRegisterPush2
=
45
// 邀请朋友来Hilo,最高获得100,000钻石奖励!
NewUserRegisterPush3
=
46
// 举办首个活动,领取10,000钻石和35%奖杯奖励!
AddUserBag
=
50
// 赠送背包礼物
ActSlotDayRankAward
=
52
// slot每日福利
ActSlotStageAwardNotice
=
55
// slot阶梯活动
NewUserRegisterPush1_1
=
56
// 首次充值免费获得永久充值勋章!累积充值$50可申请特殊ID:ABBABB!
CpAnniversaryNotice
=
57
// cp纪念日提醒
)
...
...
script/Makefile
View file @
c0c38910
...
...
@@ -12,4 +12,6 @@ group_power_data:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
group_power_data group_power_data.go
cp_pairs_stat
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
cp_pairs_stat cp_pairs_stat.go
charge_month
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
charge_month charge_month.go
script/charge_month.go
0 → 100644
View file @
c0c38910
package
main
import
(
"fmt"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
)
type
ChargeMonthData
struct
{
Area
string
// 区域
Code
string
// 用户ID
Month
string
// 月份
Dollar
float64
// 当月充值金额$
}
func
ats27
(
a
interface
{})
string
{
return
fmt
.
Sprintf
(
"%v"
,
a
)
}
func
main
()
{
type
ChargeMaxUid
struct
{
Code
string
Month
string
Dollar
int64
}
var
chargeUids
[]
ChargeMaxUid
/*
SELECT
u. CODE,
t2.d,
t2.dollar
FROM
(
SELECT
user_id,
d,
SUM(dollar) dollar
FROM
(
SELECT
user_id,
DATE_FORMAT(created_time, "%Y-%m") d,
SUM(price) AS dollar
FROM
`pay_order`
WHERE
`status` = '2'
AND `type` = '0'
AND created_time >= "2022-05-01"
GROUP BY
user_id,
d
UNION ALL
SELECT
receiver_id AS user_id,
DATE_FORMAT(created_time, "%Y-%m") d,
SUM(dollar) AS dollar
FROM
dealer_transfer_detail
WHERE
created_time >= "2022-05-01"
GROUP BY
receiver_id,
d
) t
GROUP BY
user_id,
d
) t2,
`user` u
WHERE
u.id = t2.user_id
*/
if
err
:=
mysql
.
ProdReadOnlyDB
.
Raw
(
"SELECT
\n\t
code,
\n\t
t2.d month,
\n\t
t2.dollar
\n
FROM
\n\t
(
\n\t\t
SELECT
\n\t\t\t
user_id,
\n\t\t\t
d,
\n\t\t\t
SUM(dollar) dollar
\n\t\t
FROM
\n\t\t\t
(
\n\t\t\t\t
SELECT
\n\t\t\t\t\t
user_id,
\n\t\t\t\t\t
DATE_FORMAT(created_time,
\"
%Y-%m
\"
) d,
\n\t\t\t\t\t
SUM(price) AS dollar
\n\t\t\t\t
FROM
\n\t\t\t\t\t
`pay_order`
\n\t\t\t\t
WHERE
\n\t\t\t\t\t
`status` = '2'
\n\t\t\t\t
AND `type` = '0'
\n\t\t\t\t
AND created_time >=
\"
2022-05-01
\"\n\t\t\t\t
GROUP BY
\n\t\t\t\t\t
user_id,
\n\t\t\t\t\t
d
\n\t\t\t\t
UNION ALL
\n\t\t\t\t\t
SELECT
\n\t\t\t\t\t\t
receiver_id AS user_id,
\n\t\t\t\t\t\t
DATE_FORMAT(created_time,
\"
%Y-%m
\"
) d,
\n\t\t\t\t\t\t
SUM(dollar) AS dollar
\n\t\t\t\t\t
FROM
\n\t\t\t\t\t\t
dealer_transfer_detail
\n\t\t\t\t\t
WHERE
\n\t\t\t\t\t\t
created_time >=
\"
2022-05-01
\"\n\t\t\t\t\t
GROUP BY
\n\t\t\t\t\t\t
receiver_id,
\n\t\t\t\t\t\t
d
\n\t\t\t
) t
\n\t\t
GROUP BY
\n\t\t\t
user_id,
\n\t\t\t
d
\n\t
) t2,
\n\t
`user` u
\n
WHERE
\n\t
u.id = t2.user_id"
)
.
Find
(
&
chargeUids
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
data
[]
ChargeMonthData
maxData
:=
make
(
map
[
string
]
ChargeMonthData
)
// code->maxMonthData
for
_
,
uc
:=
range
chargeUids
{
data
=
append
(
data
,
ChargeMonthData
{
Dollar
:
float64
(
uc
.
Dollar
)
/
100
,
Code
:
uc
.
Code
,
Area
:
GetAreaByCode27
(
uc
.
Code
),
Month
:
uc
.
Month
,
})
//break
}
for
_
,
d
:=
range
data
{
if
d
.
Dollar
>
maxData
[
d
.
Code
]
.
Dollar
{
maxData
[
d
.
Code
]
=
ChargeMonthData
{
Area
:
d
.
Area
,
Code
:
d
.
Code
,
Month
:
d
.
Month
,
Dollar
:
d
.
Dollar
,
}
}
}
excelFileName
:=
fmt
.
Sprintf
(
"./202205当月最高充值.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
err
:=
xlFile
.
AddSheet
(
"slot"
)
if
err
!=
nil
{
panic
(
err
)
}
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
=
"区域"
,
"用户ID"
,
"充值月份"
,
"单月充值金额$"
for
_
,
d
:=
range
maxData
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
=
ats27
(
d
.
Area
),
ats27
(
d
.
Code
),
ats27
(
d
.
Month
),
ats27
(
d
.
Dollar
)
}
_
=
xlFile
.
Save
(
excelFileName
)
}
func
GetAreaByCode27
(
code
string
)
string
{
sql
:=
"SELECT area FROM res_country c,user u WHERE u.country = c.name AND u.code = ?"
var
area
int
if
err
:=
mysql
.
ProdReadOnlyDB
.
Raw
(
sql
,
code
)
.
Scan
(
&
area
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
if
area
==
1
{
return
"阿语区"
}
return
"非阿语区"
}
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