Commit edd07972 authored by hujiebin's avatar hujiebin

feat:钻石数变化

parent 5a89b999
...@@ -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
......
...@@ -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) // 随机一个
......
...@@ -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
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment