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
cf2e1015
Commit
cf2e1015
authored
Dec 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
c924b720
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
4 deletions
+122
-4
Makefile
script/Makefile
+2
-1
group_room_visit500.go
script/group_room_visit500.go
+117
-0
promotion_data.go
script/promotion_data.go
+3
-3
No files found.
script/Makefile
View file @
cf2e1015
...
@@ -28,4 +28,5 @@ race_ksa_rank:
...
@@ -28,4 +28,5 @@ race_ksa_rank:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
race_ksa_rank race_ksa_rank.go
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
race_ksa_rank race_ksa_rank.go
promotion_data
:
promotion_data
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
promotion_data promotion_data.go
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
promotion_data promotion_data.go
group_room_visit500
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
group_room_visit500 group_room_visit500.go
script/group_room_visit500.go
0 → 100644
View file @
cf2e1015
package
main
import
(
"context"
"fmt"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/go-redis/redis/v8"
"github.com/spf13/cast"
"github.com/tealeg/xlsx"
)
var
RedisClient
*
redis
.
Client
func
init
()
{
RedisClient
=
redis
.
NewClient
(
&
redis
.
Options
{
Addr
:
"172.28.16.47:6379"
,
// redis cluster
Password
:
""
,
DB
:
0
,
// use default DB
PoolSize
:
20
,
MinIdleConns
:
20
,
})
pong
,
err
:=
RedisClient
.
Ping
(
context
.
Background
())
.
Result
()
if
err
!=
nil
{
panic
(
err
)
}
else
{
mylogrus
.
MyLog
.
Info
(
"redis db0 connection success - "
,
pong
)
}
}
type
GroupRoomVisit
struct
{
GroupId
string
GroupCode
string
Country
string
Visit
string
Consume
string
Area
string
}
func
getGroupCode
(
groupId
string
)
string
{
var
code
string
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"group_info"
)
.
Where
(
"im_group_id = ?"
,
groupId
)
.
Select
(
"code"
)
.
Scan
(
&
code
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
return
code
}
func
getGroupCountry
(
groupId
string
)
string
{
var
code
string
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"group_info"
)
.
Where
(
"im_group_id = ?"
,
groupId
)
.
Select
(
"country"
)
.
Scan
(
&
code
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
return
code
}
func
getArea
(
country
string
)
string
{
code
:=
"非阿语区"
var
area
int
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"res_country"
)
.
Where
(
"name = ?"
,
country
)
.
Select
(
"area"
)
.
Scan
(
&
code
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
if
area
==
1
{
code
=
"阿语区"
}
return
code
}
func
getConsume
(
groupId
string
)
string
{
var
result
int64
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"room_day_consume"
)
.
Where
(
"group_id = ?"
,
groupId
)
.
Select
(
"SUM(diamond)"
)
.
Scan
(
&
result
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
return
cast
.
ToString
(
result
)
}
func
main
()
{
var
data
[]
GroupRoomVisit
zRes
,
err
:=
RedisClient
.
ZRevRangeByScoreWithScores
(
context
.
Background
(),
"room_visit_count_zset"
,
&
redis
.
ZRangeBy
{
Min
:
fmt
.
Sprintf
(
"%d"
,
500
),
Max
:
"+inf"
,
})
.
Result
()
if
err
!=
nil
{
panic
(
err
)
}
for
_
,
v
:=
range
zRes
{
d
:=
GroupRoomVisit
{
GroupId
:
cast
.
ToString
(
v
.
Member
),
GroupCode
:
""
,
Country
:
""
,
Visit
:
cast
.
ToString
(
v
.
Score
),
Consume
:
""
,
}
code
:=
getGroupCode
(
d
.
GroupId
)
country
:=
getGroupCountry
(
d
.
GroupId
)
area
:=
getArea
(
country
)
consume
:=
getConsume
(
d
.
GroupId
)
d
.
GroupCode
=
code
d
.
Country
=
country
d
.
Area
=
area
d
.
Consume
=
consume
}
excelFileName
:=
fmt
.
Sprintf
(
"./房间500热度.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
err
:=
xlFile
.
AddSheet
(
"room"
)
if
err
!=
nil
{
panic
(
err
)
}
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
=
"房间code"
,
"国家"
,
"访客热度"
,
"房间奖杯"
,
"区域"
for
_
,
d
:=
range
data
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
=
d
.
GroupCode
,
d
.
Country
,
d
.
Visit
,
d
.
Consume
,
d
.
Area
}
_
=
xlFile
.
Save
(
excelFileName
)
}
script/promotion_data.go
View file @
cf2e1015
...
@@ -34,7 +34,7 @@ type PromotionDataResp struct {
...
@@ -34,7 +34,7 @@ type PromotionDataResp struct {
}
`json:"data"`
}
`json:"data"`
}
}
func
ats3
7
(
a
interface
{})
string
{
func
ats3
8
(
a
interface
{})
string
{
return
fmt
.
Sprintf
(
"%v"
,
a
)
return
fmt
.
Sprintf
(
"%v"
,
a
)
}
}
...
@@ -95,8 +95,8 @@ func main() {
...
@@ -95,8 +95,8 @@ func main() {
row
:=
sheet
.
AddRow
()
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
,
c10
,
c11
,
c12
,
c13
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
,
c10
,
c11
,
c12
,
c13
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
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
,
c10
.
Value
,
c11
.
Value
,
c12
.
Value
,
c13
.
Value
=
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
,
c6
.
Value
,
c7
.
Value
,
c8
.
Value
,
c9
.
Value
,
c10
.
Value
,
c11
.
Value
,
c12
.
Value
,
c13
.
Value
=
ats3
7
(
d
.
AgentCode
),
ats37
(
d
.
Name
),
ats37
(
d
.
InviteeCode
),
ats37
(
d
.
Platform
),
ats37
(
d
.
PlatformId
),
ats37
(
d
.
Reason
),
ats37
(
d
.
GroupCode
),
ats37
(
d
.
GroupMemberNum
),
ats37
(
d
.
GroupTotalConsume
),
ats37
(
d
.
InviteDate
),
ats3
8
(
d
.
AgentCode
),
ats38
(
d
.
Name
),
ats38
(
d
.
InviteeCode
),
ats38
(
d
.
Platform
),
ats38
(
d
.
PlatformId
),
ats38
(
d
.
Reason
),
ats38
(
d
.
GroupCode
),
ats38
(
d
.
GroupMemberNum
),
ats38
(
d
.
GroupTotalConsume
),
ats38
(
d
.
InviteDate
),
ats3
7
(
d
.
MonthPaySum
),
ats37
(
d
.
TwoMonthPaySum
),
ats37
(
d
.
MonthDealPaySum
)
ats3
8
(
d
.
MonthPaySum
),
ats38
(
d
.
TwoMonthPaySum
),
ats38
(
d
.
MonthDealPaySum
)
}
}
_
=
xlFile
.
Save
(
excelFileName
)
_
=
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