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
87a22ad5
Commit
87a22ad5
authored
Mar 22, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复跨天的
parent
561c371d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
group_grade.go
domain/model/groupPower_m/group_grade.go
+24
-0
group_star.go
domain/model/groupPower_m/group_star.go
+11
-0
No files found.
domain/model/groupPower_m/group_grade.go
View file @
87a22ad5
...
...
@@ -256,6 +256,30 @@ func IncrGroupPowerStarOnMic(model *domain.Model, groupPowerId, userId mysql.ID,
}
score
:=
nowTs
-
curTs
err
=
IncrGroupPowerMonthStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
nowTs
)
return
err
})
}
// 增加势力上麦时长-家族之星
// 事务操作
func
IncrGroupPowerStarOnMicDay
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
joinMicTimestamp
int64
)
error
{
return
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
// 日统计
star
,
err
:=
GetGroupPowerDayStar
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
)
curTs
:=
joinMicTimestamp
nowTs
:=
time
.
Now
()
.
Unix
()
day0Ts
:=
now
.
BeginningOfDay
()
.
Unix
()
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
err
}
if
star
!=
nil
&&
joinMicTimestamp
<
star
.
LastCalTs
{
// 加入的时间比上次计算时间小
curTs
=
star
.
LastCalTs
}
// 跨天
if
curTs
<
day0Ts
{
curTs
=
day0Ts
}
score
:=
nowTs
-
curTs
err
=
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
nowTs
)
return
err
})
...
...
domain/model/groupPower_m/group_star.go
View file @
87a22ad5
...
...
@@ -80,6 +80,17 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
return
nil
}
// 获取家族之星分数
// 允许返回gorm.ErrRecordNotFound
func
GetGroupPowerDayStar
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
)
(
*
GroupPowerDayStar
,
error
)
{
res
:=
new
(
GroupPowerDayStar
)
date
:=
time
.
Now
()
if
err
:=
model
.
DB
()
.
Where
(
"date = ? AND group_power_id = ? AND user_id = ? AND `type` = ?"
,
date
,
groupPowerId
,
userId
,
_type
)
.
First
(
res
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
// 获取家族之星分数
// 允许返回gorm.ErrRecordNotFound
func
GetGroupPowerMonthStar
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
)
(
*
GroupPowerMonthStar
,
error
)
{
...
...
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