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
a3ca6720
Commit
a3ca6720
authored
Apr 12, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:家族数据
parent
80e26bb7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
1 deletion
+104
-1
group_power_data.go
script/group_power_data.go
+103
-0
utils_test.go
script/utils/utils_test.go
+1
-1
No files found.
script/group_power_data.go
0 → 100644
View file @
a3ca6720
package
main
import
(
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
"io/ioutil"
"net/http"
)
type
GroupPowerResponse
struct
{
Data
struct
{
Total
int64
`json:"total"`
Data
[]
GroupPowerData
`json:"data"`
}
}
type
GroupPowerData
struct
{
Code
string
`json:"code"`
// 家族长ID
Area
string
`json:"-"`
GroupPowerExp
int64
`json:"groupPowerExp"`
// 经验值
GroupPowerConsume
int64
`json:"groupPowerConsume"`
// 家族房间流水
GroupPowerMemberNum
int
`json:"groupPowerMemberNum"`
// 成员数
GroupPowerMemberCharge
float64
`json:"groupPowerMemberCharge"`
// 成员充值$
GroupPowerNewMemberNum
int
`json:"groupPowerNewMemberNum"`
// 新成员数
GroupPowerNewMemberCharge
float64
`json:"groupPowerNewMemberCharge"`
// 新成员充值$
}
func
ats23
(
a
interface
{})
string
{
return
fmt
.
Sprintf
(
"%v"
,
a
)
}
func
getAreaByCode
(
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
"非阿语区"
}
func
main
()
{
var
data
[]
GroupPowerData
pageIndex
:=
1
pageSize
:=
500
for
{
url
:=
fmt
.
Sprintf
(
"https://apiv2.faceline.live/v1/groupPower/page?lang=zh-cn&ownerCode=&beginDate=2023-04-01&endDate=2023-04-12&pageIndex=%d&pageSize=%d&status=1"
,
pageIndex
,
pageSize
)
method
:=
"GET"
client
:=
&
http
.
Client
{}
req
,
err
:=
http
.
NewRequest
(
method
,
url
,
nil
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
req
.
Header
.
Add
(
"nonce"
,
"hilo"
)
req
.
Header
.
Add
(
"token"
,
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjI1MSwiRXh0ZXJuYWxJZCI6IiIsImV4cCI6MTY4Mzg3NTI2MH0.EH4OFsM8WIjBxvQjvq6vBuEPaHR0vOoCUdS53wmB-yo"
)
res
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
_
=
res
.
Body
.
Close
()
var
resp
GroupPowerResponse
err
=
json
.
Unmarshal
(
body
,
&
resp
)
if
err
!=
nil
{
panic
(
err
)
}
if
len
(
resp
.
Data
.
Data
)
<=
0
{
break
}
data
=
append
(
data
,
resp
.
Data
.
Data
...
)
pageIndex
++
}
excelFileName
:=
fmt
.
Sprintf
(
"./家族4月数据.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
err
:=
xlFile
.
AddSheet
(
"slot"
)
if
err
!=
nil
{
panic
(
err
)
}
row
:=
sheet
.
AddRow
()
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
=
"家族长ID"
,
"区域"
,
"经验值"
,
"家族房间流水"
,
"成员数"
,
"成员充值$"
,
"新成员数"
,
"新成员充值$"
for
_
,
d
:=
range
data
{
row
:=
sheet
.
AddRow
()
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
=
d
.
Code
,
getAreaByCode
(
d
.
Code
),
ats23
(
d
.
GroupPowerExp
),
ats23
(
d
.
GroupPowerConsume
),
ats23
(
d
.
GroupPowerMemberNum
),
ats23
(
d
.
GroupPowerMemberCharge
),
ats23
(
d
.
GroupPowerNewMemberNum
),
ats23
(
d
.
GroupPowerNewMemberCharge
)
}
_
=
xlFile
.
Save
(
excelFileName
)
}
script/utils/utils_test.go
View file @
a3ca6720
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
}
}
func
TestJwt
(
t
*
testing
.
T
)
{
func
TestJwt
(
t
*
testing
.
T
)
{
token
,
_
:=
jwt
.
GenerateToken
(
3951
,
"7b0535559da045a187ba25a2d27482c0
"
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
4510
,
"4474ac74c17e42f4820586279eda37c9
"
,
"hiloApi"
)
t
.
Logf
(
token
)
t
.
Logf
(
token
)
}
}
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