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
52bd8e8d
Commit
52bd8e8d
authored
Mar 17, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:活动扶持奖励数据
parent
d30b4869
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
group_activity_award.go
script/group_activity_award.go
+108
-0
res.go
script/model/res.go
+6
-0
No files found.
script/group_activity_award.go
0 → 100644
View file @
52bd8e8d
package
main
import
(
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
)
type
GroupActivityAwardLog
struct
{
GroupActId
uint64
// 活动id
UserId
uint64
// 用户id
ImGroupId
string
// imGroupId
Award
string
CreatedTime
string
}
type
Award
struct
{
ResGiftId
uint64
Num
int
}
type
GroupActivityData
struct
{
Country
string
// 国家
Area
string
// 区域
OwnerCode
string
// 房主靓号
GroupCode
string
// 群组靓号
AwardGift3111Num
int
// 3111礼物id数量
AwardGift3101Num
int
// 3101礼物id数量
AwardGift3091Num
int
// 3091礼物id数量
AwardPrice
int
// 总的礼物价值
AwardTime
string
// 奖励时间
}
func
ats3
(
a
int
)
string
{
return
fmt
.
Sprintf
(
"%d"
,
a
)
}
func
main
()
{
var
awardLogs
[]
GroupActivityAwardLog
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
GroupActivityAwardLog
{})
.
Where
(
"created_time < ?"
,
"2023-03-17 12:15:18"
)
.
Find
(
&
awardLogs
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
countrys
[]
model
.
ResCountry
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
ResCountry
{})
.
Find
(
&
countrys
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
cm
:=
make
(
map
[
string
]
int
)
for
_
,
c
:=
range
countrys
{
cm
[
c
.
Name
]
=
c
.
Area
}
var
data
[]
GroupActivityData
for
_
,
log
:=
range
awardLogs
{
var
user
=
new
(
model
.
User
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"user"
)
.
Where
(
"id = ?"
,
log
.
UserId
)
.
First
(
user
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
group
=
new
(
model
.
GroupInfo
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"group_info"
)
.
Where
(
"im_group_id = ?"
,
log
.
ImGroupId
)
.
First
(
group
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
area
:=
"阿语"
if
cm
[
user
.
Country
]
==
2
{
area
=
"非阿语"
}
var
awards
[]
Award
if
err
:=
json
.
Unmarshal
([]
byte
(
log
.
Award
),
&
awards
);
err
!=
nil
{
panic
(
err
)
}
var
num3111
,
num3101
,
num3091
int
for
_
,
a
:=
range
awards
{
if
a
.
ResGiftId
==
3111
{
num3111
=
a
.
Num
}
if
a
.
ResGiftId
==
3101
{
num3101
=
a
.
Num
}
if
a
.
ResGiftId
==
3091
{
num3091
=
a
.
Num
}
}
data
=
append
(
data
,
GroupActivityData
{
Country
:
user
.
Country
,
Area
:
area
,
OwnerCode
:
user
.
Code
,
GroupCode
:
group
.
Code
,
AwardGift3111Num
:
num3111
,
AwardGift3101Num
:
num3101
,
AwardGift3091Num
:
num3091
,
AwardPrice
:
num3111
*
10000
+
num3101
*
3000
+
num3091
*
1000
,
AwardTime
:
log
.
CreatedTime
,
})
}
excelFileName
:=
fmt
.
Sprintf
(
"./群组扶持数据.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
_
:=
xlFile
.
AddSheet
(
"charge"
)
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
:=
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
=
"国家"
,
"区域"
,
"房主靓号"
,
"群组靓号"
,
"3111礼物数量"
,
"3101礼物数量"
,
"3091礼物数量"
,
"总的礼物价值"
,
"奖励时间"
for
_
,
d
:=
range
data
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
,
c6
,
c7
,
c8
,
c9
:=
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
=
d
.
Country
,
d
.
Area
,
d
.
OwnerCode
,
d
.
GroupCode
,
ats3
(
d
.
AwardGift3111Num
),
ats3
(
d
.
AwardGift3101Num
),
ats3
(
d
.
AwardGift3091Num
),
ats3
(
d
.
AwardPrice
),
d
.
AwardTime
}
_
=
xlFile
.
Save
(
excelFileName
)
}
script/model/res.go
0 → 100644
View file @
52bd8e8d
package
model
type
ResCountry
struct
{
Name
string
Area
int
}
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