| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- package proto
- import (
- "context"
- badge "bet24.com/servers/micros/badge/proto"
- "bet24.com/log"
- "bet24.com/servers/micros/common"
- )
- // 用户装扮信息
- // 挡道具消失后,需要更新装扮设置,或者在获取装扮中判断时效
- type UserDecoration struct {
- Type int // 见item.go中DecorationType定义
- ItemId int // 生效ID
- }
- // 开关的信息
- const (
- SwitchType_Watch = iota
- SwitchType_Track
- SwitchType_Max
- )
- // 用户信息
- type UserHotInfo struct {
- UserId int
- NickName string
- Vip int
- FaceUrl string
- FaceId int
- Sex int
- UserWords string `json:",omitempty"`
- PrivateRoomCount int `json:",omitempty"` // 私人场局数
- Decorations []UserDecoration `json:",omitempty"`
- Switches []SwitchInfo // 开关
- Currency string // 国家币种
- Gold int // 金币
- VipPoint int
- VipExpire int
- Badges []badge.BadgePosition // 佩戴与展示的徽章列表
- Charm int // 魅力值
- Diamond int // 钻石数量
- }
- func (ui *UserHotInfo) GetUserGold() int {
- return ui.Gold
- }
- // 开关信息
- type SwitchInfo struct {
- SwitchType string // 开关类型
- SwitchStatus int // 开关状态
- }
- // 开关等级
- type SwitchLevel struct {
- SwitchType string // 开关类型
- ShowLevel int // 常驻等级
- PopLevel int // 弹出等级
- }
- func GetUserInfo(userId int) *UserHotInfo {
- xclient := getClient()
- args := &Request{
- UserId: userId,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetUserInfo", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return nil
- }
- return reply.UserInfo
- }
- func GetUserInfoInBulk(userIds []int) []UserHotInfo {
- xclient := getClient()
- args := &Request{
- UserIds: userIds,
- }
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetUserInfoInBulk", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return nil
- }
- return reply.UserInfos
- }
- func SaveCountry(userId int, countryName, currency string) string {
- args := &Request{
- UserId: userId,
- CountryName: countryName,
- Currency: currency,
- }
- reply := &Response{}
- err := getClient().Call(context.Background(), "SaveCountry", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return "0"
- }
- return reply.Data
- }
- func LockCountry(userId int, currency string) int {
- args := &Request{
- UserId: userId,
- Currency: currency,
- }
- reply := &Response{}
- err := getClient().Call(context.Background(), "LockCountry", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return 0
- }
- return reply.RetCode
- }
- func GetUserFaceUrl(userId int) string {
- args := &Request{
- UserId: userId,
- }
- reply := &Response{}
- err := getClient().Call(context.Background(), "GetUserFaceUrl", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return ""
- }
- return reply.Data
- }
- func UpdateUserInfo(userId int) {
- args := &Request{
- UserId: userId,
- }
- err := getClient().Call(context.Background(), "UpdateUserInfo", args, nil)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return
- }
- }
- func SetUserDecoration(userId int, decorationType int, itemId int) bool {
- args := &Request{
- UserId: userId,
- DecorationType: decorationType,
- ItemId: itemId,
- }
- reply := &Response{}
- err := getClient().Call(context.Background(), "SetUserDecoration", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return false
- }
- return reply.Success
- }
- func GetUserDecoration(userId int) []UserDecoration {
- var ret []UserDecoration
- usr := GetUserInfo(userId)
- if usr != nil {
- return usr.Decorations
- }
- return ret
- }
- func OnDecorationExpired(userId int, itemId int) {
- args := &Request{
- UserId: userId,
- ItemId: itemId,
- }
- err := getClient().Call(context.Background(), "OnDecorationExpired", args, nil)
- if err != nil {
- log.Debug("userservices.OnDecorationExpired failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return
- }
- }
- // 设置开关状态
- func ChangeSwitchStatus(userId int, switchInfo SwitchInfo) {
- args := &Request_Switch{
- UserId: userId,
- SwitchInfo: switchInfo,
- }
- // 设置后同时设置变量
- if err := getClient().Call(context.Background(), "ChangeSwitchStatus", args, nil); err != nil {
- log.Debug("userservices.ChangeSwitchStatus switchInfo: %v, failed to call: %v", switchInfo, err)
- common.GetClientPool().RemoveClient(ServiceName)
- return
- }
- return
- }
- func GetSwitchLevelInfo() []SwitchLevel {
- xclient := getClient()
- args := &Request{}
- reply := &Response{}
- err := xclient.Call(context.Background(), "GetSwitchLevelInfo", args, reply)
- if err != nil {
- log.Debug("userservices failed to call: %v", err)
- common.GetClientPool().RemoveClient(ServiceName)
- return nil
- }
- return reply.SwitchLevelList
- }
- func AddUserCharm(userId int, charm int) {
- args := &Request{
- UserId: userId,
- Charm: charm,
- }
- // 设置后同时设置变量
- if err := getClient().Call(context.Background(), "AddUserCharm", args, nil); err != nil {
- log.Debug("userservices.AddUserCharm : %d:%d, failed to call: %v", userId, charm, err)
- common.GetClientPool().RemoveClient(ServiceName)
- }
- }
|