Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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-common
Commits
edd07972
Commit
edd07972
authored
Feb 21, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:钻石数变化
parent
5a89b999
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
13 deletions
+61
-13
userProxy.proto
protocol/userProxy.proto
+5
-0
user.go
rpc/user.go
+38
-3
user_center_func.go
rpc/user_center_func.go
+18
-10
No files found.
protocol/userProxy.proto
View file @
edd07972
...
@@ -351,6 +351,11 @@ message RoomInviteMember {
...
@@ -351,6 +351,11 @@ message RoomInviteMember {
string
group_id
=
1
;
string
group_id
=
1
;
}
}
/* id == 145 钻石变化 */
message
DiamondChange
{
uint32
remainDiamond
=
1
;
}
/* id == 146 游戏横幅 */
/* id == 146 游戏横幅 */
message
GlobalGameBanner
{
message
GlobalGameBanner
{
uint32
gameType
=
1
;
// 0.h5游戏 1.ludo 2.uno 3.dice 4.lucky wheel 5.lucky box 6.fruit
uint32
gameType
=
1
;
// 0.h5游戏 1.ludo 2.uno 3.dice 4.lucky wheel 5.lucky box 6.fruit
...
...
rpc/user.go
View file @
edd07972
...
@@ -66,7 +66,7 @@ func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUser
...
@@ -66,7 +66,7 @@ func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUser
type
Response
struct
{
type
Response
struct
{
Code
int
`json:"code"`
Code
int
`json:"code"`
Message
string
`json:"message"`
Message
string
`json:"message"`
Data
map
[
mysql
.
ID
]
CvUserLevel
Data
map
[
mysql
.
ID
]
CvUserLevel
`json:"data"`
}
}
var
res
=
make
(
map
[
mysql
.
ID
]
CvUserLevel
)
var
res
=
make
(
map
[
mysql
.
ID
]
CvUserLevel
)
if
len
(
userIds
)
<=
0
{
if
len
(
userIds
)
<=
0
{
...
@@ -99,6 +99,41 @@ func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUser
...
@@ -99,6 +99,41 @@ func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUser
return
res
,
nil
return
res
,
nil
}
}
type
CvUserBag
struct
{
BagId
mysql
.
ID
`json:"bagId"`
// 背包id
ResType
mysql
.
Type
`json:"resType"`
// 道具类型 1:礼物道具
ResId
mysql
.
ID
`json:"resId"`
// 道具资源id
Name
string
`json:"name"`
// 资源名称
DiamondNum
mysql
.
Num
`json:"diamondNum"`
// 钻石数量
IconUrl
string
`json:"iconUrl"`
// icon url
SvgaUrl
string
`json:"svgaUrl"`
// svga url
Count
mysql
.
Num
`json:"count"`
// 拥有数量
RemainDays
int
`json:"remainDays"`
// 有效天数
}
// 批量用户背包
func
GetUserBag
(
model
*
domain
.
Model
,
bagId
mysql
.
ID
)
(
CvUserBag
,
error
)
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
Data
CvUserBag
`json:"data"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/user/bag"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpGet
(
model
,
_url
,
nil
,
map
[
string
][]
string
{
"bagId"
:
{
fmt
.
Sprintf
(
"%d"
,
bagId
)},
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserBag fail:%v"
,
err
)
return
CvUserBag
{},
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserBag json fail:%v"
,
err
)
return
CvUserBag
{},
err
}
return
response
.
Data
,
nil
}
func
getUserHost
()
string
{
func
getUserHost
()
string
{
l
:=
len
(
UserServerHost
)
l
:=
len
(
UserServerHost
)
r
:=
rand
.
Intn
(
l
)
// 随机一个
r
:=
rand
.
Intn
(
l
)
// 随机一个
...
...
rpc/user_center_func.go
View file @
edd07972
...
@@ -67,12 +67,17 @@ func SendGlobalRocketNotice(groupId string, period string, round uint32, stage u
...
@@ -67,12 +67,17 @@ func SendGlobalRocketNotice(groupId string, period string, round uint32, stage u
}
}
// 发送钻石变化通知
// 发送钻石变化通知
func
SendDiamondChange
(
userId
uint64
)
error
{
func
SendDiamondChange
(
userId
uint64
,
diamond
uint32
)
error
{
rspUids
,
err
:=
multicast
([]
uint64
{
userId
},
MsgDiamondChange
,
[]
byte
(
""
))
msg
:=
&
userProxy
.
DiamondChange
{
RemainDiamond
:
diamond
,
}
if
buffer
,
err
:=
proto
.
Marshal
(
msg
);
err
==
nil
{
rspUids
,
err
:=
multicast
([]
uint64
{
userId
},
MsgDiamondChange
,
buffer
)
//记录socket,注意闭包问题
//记录socket,注意闭包问题
go
func
(
userId
uint64
,
rspUids
[]
uint64
,
err
error
)
{
go
func
(
userId
uint64
,
msg
*
userProxy
.
DiamondChange
,
rspUids
[]
uint64
,
err
error
)
{
AddRpcLog
(
MsgDiamondChange
,
userId
,
""
,
rspUids
,
err
)
buf
,
_
:=
json
.
Marshal
(
msg
)
}(
userId
,
rspUids
,
err
)
AddRpcLog
(
MsgDiamondChange
,
userId
,
string
(
buf
[
:
]),
rspUids
,
err
)
}(
userId
,
msg
,
rspUids
,
err
)
if
err
!=
nil
{
if
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"grpc SendDiamondChange send fail"
)
mylogrus
.
MyLog
.
Errorf
(
"grpc SendDiamondChange send fail"
)
...
@@ -80,6 +85,9 @@ func SendDiamondChange(userId uint64) error {
...
@@ -80,6 +85,9 @@ func SendDiamondChange(userId uint64) error {
}
else
{
}
else
{
mylogrus
.
MyLog
.
Info
(
"grpc SendDiamondChange send success"
)
mylogrus
.
MyLog
.
Info
(
"grpc SendDiamondChange send success"
)
}
}
}
else
{
return
err
}
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