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
85969f50
Commit
85969f50
authored
Mar 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:势力经验值
parent
34116196
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
2 deletions
+112
-2
grade.go
_const/enum/groupPower_e/grade.go
+22
-0
group_grade.go
domain/model/groupPower_m/group_grade.go
+79
-0
event_init.go
domain/service/event_s/event_init.go
+11
-2
No files found.
_const/enum/groupPower_e/grade.go
0 → 100644
View file @
85969f50
package
groupPower_e
type
GroupPowerGrade
int
const
(
GroupPowerGrade0
GroupPowerGrade
=
0
GroupPowerGrade1
GroupPowerGrade
=
1
GroupPowerGrade2
GroupPowerGrade
=
2
GroupPowerGrade3
GroupPowerGrade
=
3
GroupPowerGrade4
GroupPowerGrade
=
4
GroupPowerGradeMax
=
GroupPowerGrade4
)
var
(
GroupPowerGradeExp
=
map
[
GroupPowerGrade
]
int64
{
GroupPowerGrade1
:
2500000
,
GroupPowerGrade2
:
15000000
,
GroupPowerGrade3
:
45000000
,
// todo
GroupPowerGrade4
:
60000000
,
}
)
domain/model/groupPower_m/group_grade.go
0 → 100644
View file @
85969f50
package
groupPower_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-group/_const/enum/groupPower_e"
"time"
)
type
GroupPowerExp
struct
{
Date
string
GroupPowerId
mysql
.
ID
Exp
int64
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
type
GroupPowerGrade
struct
{
GroupPowerId
mysql
.
ID
Exp
int64
Grade
groupPower_e
.
GroupPowerGrade
ExpiredAt
time
.
Time
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
// 增加家族经验
// 达到经验值之后升级
// 单进程同步执行,不考虑并发
func
IncrGroupPowerExp
(
txModel
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
exp
int64
)
error
{
var
err
error
defer
func
()
{
if
err
!=
nil
{
txModel
.
Log
.
Errorf
(
"IncrGroupPowerExp fail,id:%v,exp:%v,err:%v"
,
groupPowerId
,
exp
,
err
)
}
}()
// 增加家族经验-天
date
:=
time
.
Now
()
.
Format
(
"2006-01-02"
)
gpe
:=
&
GroupPowerExp
{
Date
:
date
,
GroupPowerId
:
groupPowerId
,
Exp
:
exp
,
}
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerExp
{})
.
Clauses
(
clause
.
OnConflict
{
Columns
:
[]
clause
.
Column
{{
Name
:
"date"
},
{
Name
:
"group_power_id"
}},
DoUpdates
:
clause
.
Assignments
(
map
[
string
]
interface
{}{
"exp"
:
gorm
.
Expr
(
"exp + ?"
,
gpe
.
Exp
)})})
.
Create
(
gpe
)
.
Error
;
err
!=
nil
{
return
err
}
// 增加家族经验-总
gpg
:=
&
GroupPowerGrade
{
GroupPowerId
:
groupPowerId
,
Exp
:
exp
,
Grade
:
0
,
ExpiredAt
:
time
.
Time
{},
}
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Clauses
(
clause
.
OnConflict
{
Columns
:
[]
clause
.
Column
{{
Name
:
"group_power_id"
}},
DoUpdates
:
clause
.
Assignments
(
map
[
string
]
interface
{}{
"exp"
:
gorm
.
Expr
(
"exp + ?"
,
gpg
.
Exp
)})})
.
Create
(
gpg
)
.
Error
;
err
!=
nil
{
return
err
}
// 达到经验值之后升级
latestGrade
:=
new
(
GroupPowerGrade
)
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
groupPowerId
)
.
First
(
latestGrade
)
.
Error
;
err
!=
nil
{
return
err
}
for
grade
:=
groupPower_e
.
GroupPowerGradeMax
;
grade
>=
groupPower_e
.
GroupPowerGrade0
;
grade
--
{
if
latestGrade
.
Exp
>
groupPower_e
.
GroupPowerGradeExp
[
grade
]
{
if
latestGrade
.
Grade
!=
grade
{
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
latestGrade
.
GroupPowerId
)
.
UpdateColumn
(
"grade"
,
grade
)
.
Error
;
err
!=
nil
{
return
err
}
}
break
}
}
return
nil
}
domain/service/event_s/event_init.go
View file @
85969f50
...
...
@@ -397,14 +397,23 @@ func FlushHiloInfo(extId string, isVip bool, isPrettyCode bool, medals []uint32,
}
func
SendGift
()
{
// 送礼事件-
火箭
gift_ev
.
AddSendGiftEvent
As
ync
(
func
(
model
*
domain
.
Model
,
event
interface
{})
error
{
// 送礼事件-
势力经验
gift_ev
.
AddSendGiftEvent
S
ync
(
func
(
model
*
domain
.
Model
,
event
interface
{})
error
{
sendGiftEvent
,
ok
:=
event
.
(
*
gift_ev
.
SendGiftEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync event type err"
)
return
nil
}
model
.
Log
.
Infof
(
"AddSendGiftEventAsync %+v"
,
sendGiftEvent
)
exist
,
groupPowerId
,
err
:=
groupPower_m
.
CheckGroupPowerUser
(
model
,
sendGiftEvent
.
SendUserId
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"CheckGroupPowerUser fail %+v"
,
err
)
return
err
}
if
exist
{
exp
:=
int64
(
sendGiftEvent
.
GiftN
)
*
int64
(
len
(
sendGiftEvent
.
ReceiveUserIds
))
*
int64
(
sendGiftEvent
.
ResGift
.
DiamondNum
)
return
groupPower_m
.
IncrGroupPowerExp
(
model
,
groupPowerId
,
exp
)
}
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