Commit edd07972 authored by hujiebin's avatar hujiebin

feat:钻石数变化

parent 5a89b999
......@@ -351,6 +351,11 @@ message RoomInviteMember {
string group_id = 1;
}
/* id == 145 钻石变化 */
message DiamondChange {
uint32 remainDiamond = 1;
}
/* id == 146 游戏横幅 */
message GlobalGameBanner {
uint32 gameType = 1; // 0.h5游戏 1.ludo 2.uno 3.dice 4.lucky wheel 5.lucky box 6.fruit
......
......@@ -64,9 +64,9 @@ func GetUserLevel(model *domain.Model, userId mysql.ID) (CvUserLevel, error) {
// 批量获取用户等级
func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUserLevel, error) {
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data map[mysql.ID]CvUserLevel
Code int `json:"code"`
Message string `json:"message"`
Data map[mysql.ID]CvUserLevel `json:"data"`
}
var res = make(map[mysql.ID]CvUserLevel)
if len(userIds) <= 0 {
......@@ -99,6 +99,41 @@ func MGetUserLevel(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]CvUser
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 {
l := len(UserServerHost)
r := rand.Intn(l) // 随机一个
......
......@@ -67,18 +67,26 @@ func SendGlobalRocketNotice(groupId string, period string, round uint32, stage u
}
// 发送钻石变化通知
func SendDiamondChange(userId uint64) error {
rspUids, err := multicast([]uint64{userId}, MsgDiamondChange, []byte(""))
//记录socket,注意闭包问题
go func(userId uint64, rspUids []uint64, err error) {
AddRpcLog(MsgDiamondChange, userId, "", rspUids, err)
}(userId, rspUids, err)
func SendDiamondChange(userId uint64, diamond uint32) error {
msg := &userProxy.DiamondChange{
RemainDiamond: diamond,
}
if buffer, err := proto.Marshal(msg); err == nil {
rspUids, err := multicast([]uint64{userId}, MsgDiamondChange, buffer)
//记录socket,注意闭包问题
go func(userId uint64, msg *userProxy.DiamondChange, rspUids []uint64, err error) {
buf, _ := json.Marshal(msg)
AddRpcLog(MsgDiamondChange, userId, string(buf[:]), rspUids, err)
}(userId, msg, rspUids, err)
if err != nil {
mylogrus.MyLog.Errorf("grpc SendDiamondChange send fail")
return err
if err != nil {
mylogrus.MyLog.Errorf("grpc SendDiamondChange send fail")
return err
} else {
mylogrus.MyLog.Info("grpc SendDiamondChange send success")
}
} else {
mylogrus.MyLog.Info("grpc SendDiamondChange send success")
return err
}
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