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
b34a7a8c
Commit
b34a7a8c
authored
Mar 08, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:经验增加明细
parent
9c643008
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
group_grade.go
domain/model/groupPower_m/group_grade.go
+31
-6
event_init.go
domain/service/event_s/event_init.go
+3
-2
No files found.
domain/model/groupPower_m/group_grade.go
View file @
b34a7a8c
...
@@ -14,20 +14,31 @@ import (
...
@@ -14,20 +14,31 @@ import (
type
GroupPowerDayExp
struct
{
type
GroupPowerDayExp
struct
{
Date
string
Date
string
GroupPowerId
mysql
.
ID
GroupPowerId
mysql
.
ID
Exp
int64
Exp
mysql
.
Num
CreatedTime
time
.
Time
`gorm:"->"`
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
}
type
GroupPowerGrade
struct
{
type
GroupPowerGrade
struct
{
GroupPowerId
mysql
.
ID
GroupPowerId
mysql
.
ID
Exp
int64
Exp
mysql
.
Num
Grade
groupPower_e
.
GroupPowerGrade
Grade
groupPower_e
.
GroupPowerGrade
ExpireAt
time
.
Time
ExpireAt
time
.
Time
CreatedTime
time
.
Time
`gorm:"->"`
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
}
type
GroupPowerExpDetail
struct
{
mysql
.
Entity
GroupPowerId
mysql
.
ID
UserId
mysql
.
ID
Exp
mysql
.
Num
AddReduce
mysql
.
AddReduce
BefNum
mysql
.
Num
AftNum
mysql
.
Num
Remark
string
}
type
GroupPowerOnMic
struct
{
type
GroupPowerOnMic
struct
{
Date
string
Date
string
GroupPowerId
mysql
.
ID
GroupPowerId
mysql
.
ID
...
@@ -50,7 +61,7 @@ type GroupPowerOnMicDetail struct {
...
@@ -50,7 +61,7 @@ type GroupPowerOnMicDetail struct {
// 增加家族经验
// 增加家族经验
// 达到经验值之后升级
// 达到经验值之后升级
// 单进程同步执行,不考虑并发
// 单进程同步执行,不考虑并发
func
IncrGroupPowerExp
(
txModel
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
exp
int64
)
error
{
func
IncrGroupPowerExp
(
txModel
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
exp
mysql
.
Num
,
userId
mysql
.
ID
,
remark
string
)
error
{
var
err
error
var
err
error
defer
func
()
{
defer
func
()
{
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -81,13 +92,27 @@ func IncrGroupPowerExp(txModel *domain.Model, groupPowerId mysql.ID, exp int64)
...
@@ -81,13 +92,27 @@ func IncrGroupPowerExp(txModel *domain.Model, groupPowerId mysql.ID, exp int64)
"exp"
:
gorm
.
Expr
(
"exp + ?"
,
gpg
.
Exp
)})})
.
Create
(
gpg
)
.
Error
;
err
!=
nil
{
"exp"
:
gorm
.
Expr
(
"exp + ?"
,
gpg
.
Exp
)})})
.
Create
(
gpg
)
.
Error
;
err
!=
nil
{
return
err
return
err
}
}
//
达到经验值之后升级
//
当前写后读
latestGrade
:=
new
(
GroupPowerGrade
)
latestGrade
:=
new
(
GroupPowerGrade
)
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
groupPowerId
)
.
First
(
latestGrade
)
.
Error
;
err
!=
nil
{
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
groupPowerId
)
.
First
(
latestGrade
)
.
Error
;
err
!=
nil
{
return
err
return
err
}
}
// 记录明细
detail
:=
&
GroupPowerExpDetail
{
GroupPowerId
:
groupPowerId
,
UserId
:
userId
,
Exp
:
exp
,
AddReduce
:
mysql
.
ADD
,
BefNum
:
latestGrade
.
Exp
-
exp
,
AftNum
:
latestGrade
.
Exp
,
Remark
:
remark
,
}
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerExpDetail
{})
.
Create
(
detail
)
.
Error
;
err
!=
nil
{
return
err
}
// 达到经验值之后升级
for
grade
:=
groupPower_e
.
GroupPowerGradeMax
;
grade
>=
groupPower_e
.
GroupPowerGrade0
;
grade
--
{
for
grade
:=
groupPower_e
.
GroupPowerGradeMax
;
grade
>=
groupPower_e
.
GroupPowerGrade0
;
grade
--
{
if
latestGrade
.
Exp
>
groupPower_e
.
GroupPowerGradeExp
[
grade
]
{
if
latestGrade
.
Exp
>
mysql
.
Num
(
groupPower_e
.
GroupPowerGradeExp
[
grade
])
{
if
latestGrade
.
Grade
<
grade
{
// 积分清零后,等级保持一段时间
if
latestGrade
.
Grade
<
grade
{
// 积分清零后,等级保持一段时间
expireAt
:=
now
.
EndOfMonth
()
expireAt
:=
now
.
EndOfMonth
()
expireAt
=
utils
.
AddDate
(
expireAt
,
0
,
1
)
// 等级有效期到下个月月底
expireAt
=
utils
.
AddDate
(
expireAt
,
0
,
1
)
// 等级有效期到下个月月底
...
@@ -176,7 +201,7 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID,
...
@@ -176,7 +201,7 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID,
return
err
return
err
}
}
// 每10分钟增加100点经验
// 每10分钟增加100点经验
if
err
:=
IncrGroupPowerExp
(
model
,
groupPowerId
,
100
);
err
!=
nil
{
if
err
:=
IncrGroupPowerExp
(
model
,
groupPowerId
,
100
,
userId
,
"上麦10分钟"
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
domain/service/event_s/event_init.go
View file @
b34a7a8c
...
@@ -3,6 +3,7 @@ package event_s
...
@@ -3,6 +3,7 @@ package event_s
import
(
import
(
"encoding/json"
"encoding/json"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/group_e"
...
@@ -411,8 +412,8 @@ func SendGift() {
...
@@ -411,8 +412,8 @@ func SendGift() {
return
err
return
err
}
}
if
exist
{
if
exist
{
exp
:=
int64
(
sendGiftEvent
.
GiftN
)
*
int64
(
len
(
sendGiftEvent
.
ReceiveUserIds
))
*
int64
(
sendGiftEvent
.
ResGift
.
DiamondNum
)
exp
:=
sendGiftEvent
.
GiftN
*
mysql
.
Num
(
len
(
sendGiftEvent
.
ReceiveUserIds
))
*
sendGiftEvent
.
ResGift
.
DiamondNum
return
groupPower_m
.
IncrGroupPowerExp
(
model
,
groupPowerId
,
exp
)
return
groupPower_m
.
IncrGroupPowerExp
(
model
,
groupPowerId
,
exp
,
sendGiftEvent
.
SendUserId
,
"送礼"
)
}
}
return
nil
return
nil
})
})
...
...
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