Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
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
chenweijian
hilo-user
Commits
4f4b4144
Commit
4f4b4144
authored
Jun 15, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群组中送礼升级
parent
db812065
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
level.go
domain/model/cp_m/level.go
+19
-1
cp_level.go
domain/service/event_s/cp_level.go
+1
-1
No files found.
domain/model/cp_m/level.go
View file @
4f4b4144
...
...
@@ -4,10 +4,13 @@ import (
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/txop/headwear_tx"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-user/_const/enum/cp_e"
"hilo-user/_const/enum/gift_e"
"hilo-user/domain/model/user_m"
"hilo-user/myerr"
"time"
)
...
...
@@ -134,7 +137,7 @@ func InitCpLevel(model *domain.Model, cpId, userId1, userId2 mysql.ID) error {
// 2.记录存在
// 2.1 在有效期内,直接加points后判断新level,升级需要更新有效期
// 2.2 不有效期内,算首充,重置points后判断新level,升级需要更新有效期
func
AddCpLevelPoints
(
model
*
domain
.
Model
,
cpRelation
CpRelation
,
points
mysql
.
Num
)
(
err
error
)
{
func
AddCpLevelPoints
(
model
*
domain
.
Model
,
cpRelation
CpRelation
,
points
mysql
.
Num
,
sceneType
gift_e
.
GiftOperateSceneType
)
(
err
error
)
{
start
:=
time
.
Now
()
defer
func
()
{
model
.
Log
.
Infof
(
"AddCpLevelPoints cost:%v,err:%v"
,
time
.
Now
()
.
Sub
(
start
),
err
)
...
...
@@ -281,6 +284,21 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N
return
err
}
}
// 群组中送礼升级
if
oldLevel
!=
cpLevel
.
Level
&&
sceneType
==
gift_e
.
GroupSceneType
{
go
func
()
{
userId1
,
userId2
:=
cpRelation
.
UserId1
,
cpRelation
.
UserId2
model
:=
domain
.
CreateModelContext
(
model
.
MyContext
)
users
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
[]
mysql
.
ID
{
userId1
,
userId2
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
""
)
return
}
if
err
:=
rpc
.
SendCpUpgrade
(
users
[
userId1
]
.
Nick
,
users
[
userId2
]
.
Nick
,
users
[
userId1
]
.
Avatar
,
users
[
userId2
]
.
Avatar
,
uint32
(
cpLevel
.
Level
),
"成为 todo"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendCpUpgrade fail:%v"
,
err
)
}
}()
}
return
cpLevel
.
Persistence
(
model
)
}
...
...
domain/service/event_s/cp_level.go
View file @
4f4b4144
...
...
@@ -26,7 +26,7 @@ func CpGiftEvent() {
diamonds
:=
sendGiftEvent
.
GiftN
*
sendGiftEvent
.
ResGift
.
DiamondNum
// 有cp关系
if
cpRelation
,
exits
:=
cp_m
.
GetCpRelationPair
(
model
,
sendGiftEvent
.
SendUserId
,
receiverUid
);
exits
{
if
err
:=
cp_m
.
AddCpLevelPoints
(
model
,
cpRelation
,
diamonds
);
err
!=
nil
{
if
err
:=
cp_m
.
AddCpLevelPoints
(
model
,
cpRelation
,
diamonds
,
sendGiftEvent
.
SceneType
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddCpLevelPoints fail:%v"
,
err
)
}
if
err
:=
cp_m
.
AddCpDayRank
(
model
,
cpRelation
,
diamonds
);
err
!=
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