Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
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-group
Commits
561c371d
Commit
561c371d
authored
Mar 22, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:多加一个家族之星的日统计
parent
446fdf5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
2 deletions
+46
-2
group_grade.go
domain/model/groupPower_m/group_grade.go
+3
-1
group_star.go
domain/model/groupPower_m/group_star.go
+36
-1
event_init.go
domain/service/event_s/event_init.go
+6
-0
router.go
route/router.go
+1
-0
No files found.
domain/model/groupPower_m/group_grade.go
View file @
561c371d
...
...
@@ -255,7 +255,9 @@ func IncrGroupPowerStarOnMic(model *domain.Model, groupPowerId, userId mysql.ID,
curTs
=
month0Ts
}
score
:=
nowTs
-
curTs
return
IncrGroupPowerMonthStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
nowTs
)
err
=
IncrGroupPowerMonthStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
nowTs
)
err
=
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
nowTs
)
return
err
})
}
...
...
domain/model/groupPower_m/group_star.go
View file @
561c371d
...
...
@@ -9,7 +9,7 @@ import (
"time"
)
// 家族之星
// 家族之星
-月
type
GroupPowerMonthStar
struct
{
Month
string
GroupPowerId
mysql
.
ID
...
...
@@ -21,6 +21,18 @@ type GroupPowerMonthStar struct {
UpdatedTime
time
.
Time
`gorm:"->"`
}
// 家族之星-日
type
GroupPowerDayStar
struct
{
Date
time
.
Time
GroupPowerId
mysql
.
ID
UserId
mysql
.
ID
Type
groupPower_e
.
GroupPowerStarType
Score
mysql
.
Num
LastCalTs
int64
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
// 增加家族之星分数
func
IncrGroupPowerMonthStarScore
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
score
mysql
.
Num
,
lastCalTs
int64
)
error
{
month
:=
time
.
Now
()
.
Format
(
"200601"
)
...
...
@@ -45,6 +57,29 @@ func IncrGroupPowerMonthStarScore(model *domain.Model, groupPowerId, userId mysq
return
nil
}
// 增加家族之星分数
func
IncrGroupPowerDayStarScore
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
score
mysql
.
Num
,
lastCalTs
int64
)
error
{
star
:=
&
GroupPowerDayStar
{
Date
:
time
.
Now
(),
GroupPowerId
:
groupPowerId
,
UserId
:
userId
,
Type
:
_type
,
Score
:
score
,
LastCalTs
:
lastCalTs
,
}
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerDayStar
{})
.
Clauses
(
clause
.
OnConflict
{
Columns
:
[]
clause
.
Column
{{
Name
:
"date"
},
{
Name
:
"group_power_id"
},
{
Name
:
"user_id"
},
{
Name
:
"type"
}},
DoUpdates
:
clause
.
Assignments
(
map
[
string
]
interface
{}{
"score"
:
gorm
.
Expr
(
"score + ?"
,
star
.
Score
),
"last_cal_ts"
:
lastCalTs
,
}),
})
.
Create
(
star
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore fail:%v"
,
err
)
return
err
}
return
nil
}
// 获取家族之星分数
// 允许返回gorm.ErrRecordNotFound
func
GetGroupPowerMonthStar
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
)
(
*
GroupPowerMonthStar
,
error
)
{
...
...
domain/service/event_s/event_init.go
View file @
561c371d
...
...
@@ -493,6 +493,9 @@ func SendGift() {
if
err
:=
groupPower_m
.
IncrGroupPowerMonthStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeFamous
,
diamonds
,
0
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerMonthStarScore famous fail:%v"
,
err
)
}
if
err
:=
groupPower_m
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeFamous
,
diamonds
,
0
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore famous fail:%v"
,
err
)
}
}
// 收礼加分
for
_
,
userId
:=
range
sendGiftEvent
.
ReceiveUserIds
{
...
...
@@ -501,6 +504,9 @@ func SendGift() {
if
err
:=
groupPower_m
.
IncrGroupPowerMonthStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeCharm
,
diamonds
,
0
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerMonthStarScore charm fail:%v"
,
err
)
}
if
err
:=
groupPower_m
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeCharm
,
diamonds
,
0
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore charm fail:%v"
,
err
)
}
}
}
return
nil
...
...
route/router.go
View file @
561c371d
...
...
@@ -139,6 +139,7 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/rank/:period"
,
wrapper
(
group_power_r
.
GroupPowerRank
))
groupPower
.
GET
(
"/rankTop"
,
wrapper
(
group_power_r
.
GroupPowerRankTop
))
groupPower
.
GET
(
"/star"
,
wrapper
(
group_power_r
.
GroupPowerStar
))
groupPower
.
GET
(
"/star/:period"
,
wrapper
(
group_power_r
.
GroupPowerStar
))
groupPower
.
POST
(
"/info/set"
,
wrapper
(
group_power_r
.
GroupPowerSetInfo
))
}
h5GroupPower
:=
v1
.
Group
(
"/h5/groupPower"
)
...
...
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