userinfo.pb.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package proto
  2. import (
  3. "context"
  4. badge "bet24.com/servers/micros/badge/proto"
  5. "bet24.com/log"
  6. "bet24.com/servers/micros/common"
  7. )
  8. // 用户装扮信息
  9. // 挡道具消失后,需要更新装扮设置,或者在获取装扮中判断时效
  10. type UserDecoration struct {
  11. Type int // 见item.go中DecorationType定义
  12. ItemId int // 生效ID
  13. }
  14. // 开关的信息
  15. const (
  16. SwitchType_Watch = iota
  17. SwitchType_Track
  18. SwitchType_Max
  19. )
  20. // 用户信息
  21. type UserHotInfo struct {
  22. UserId int
  23. NickName string
  24. Vip int
  25. FaceUrl string
  26. FaceId int
  27. Sex int
  28. UserWords string `json:",omitempty"`
  29. PrivateRoomCount int `json:",omitempty"` // 私人场局数
  30. Decorations []UserDecoration `json:",omitempty"`
  31. Switches []SwitchInfo // 开关
  32. Currency string // 国家币种
  33. Gold int // 金币
  34. VipPoint int
  35. VipExpire int
  36. Badges []badge.BadgePosition // 佩戴与展示的徽章列表
  37. Charm int // 魅力值
  38. Diamond int // 钻石数量
  39. }
  40. func (ui *UserHotInfo) GetUserGold() int {
  41. return ui.Gold
  42. }
  43. // 开关信息
  44. type SwitchInfo struct {
  45. SwitchType string // 开关类型
  46. SwitchStatus int // 开关状态
  47. }
  48. // 开关等级
  49. type SwitchLevel struct {
  50. SwitchType string // 开关类型
  51. ShowLevel int // 常驻等级
  52. PopLevel int // 弹出等级
  53. }
  54. func GetUserInfo(userId int) *UserHotInfo {
  55. xclient := getClient()
  56. args := &Request{
  57. UserId: userId,
  58. }
  59. reply := &Response{}
  60. err := xclient.Call(context.Background(), "GetUserInfo", args, reply)
  61. if err != nil {
  62. log.Debug("userservices failed to call: %v", err)
  63. common.GetClientPool().RemoveClient(ServiceName)
  64. return nil
  65. }
  66. return reply.UserInfo
  67. }
  68. func GetUserInfoInBulk(userIds []int) []UserHotInfo {
  69. xclient := getClient()
  70. args := &Request{
  71. UserIds: userIds,
  72. }
  73. reply := &Response{}
  74. err := xclient.Call(context.Background(), "GetUserInfoInBulk", args, reply)
  75. if err != nil {
  76. log.Debug("userservices failed to call: %v", err)
  77. common.GetClientPool().RemoveClient(ServiceName)
  78. return nil
  79. }
  80. return reply.UserInfos
  81. }
  82. func SaveCountry(userId int, countryName, currency string) string {
  83. args := &Request{
  84. UserId: userId,
  85. CountryName: countryName,
  86. Currency: currency,
  87. }
  88. reply := &Response{}
  89. err := getClient().Call(context.Background(), "SaveCountry", args, reply)
  90. if err != nil {
  91. log.Debug("userservices failed to call: %v", err)
  92. common.GetClientPool().RemoveClient(ServiceName)
  93. return "0"
  94. }
  95. return reply.Data
  96. }
  97. func LockCountry(userId int, currency string) int {
  98. args := &Request{
  99. UserId: userId,
  100. Currency: currency,
  101. }
  102. reply := &Response{}
  103. err := getClient().Call(context.Background(), "LockCountry", args, reply)
  104. if err != nil {
  105. log.Debug("userservices failed to call: %v", err)
  106. common.GetClientPool().RemoveClient(ServiceName)
  107. return 0
  108. }
  109. return reply.RetCode
  110. }
  111. func GetUserFaceUrl(userId int) string {
  112. args := &Request{
  113. UserId: userId,
  114. }
  115. reply := &Response{}
  116. err := getClient().Call(context.Background(), "GetUserFaceUrl", args, reply)
  117. if err != nil {
  118. log.Debug("userservices failed to call: %v", err)
  119. common.GetClientPool().RemoveClient(ServiceName)
  120. return ""
  121. }
  122. return reply.Data
  123. }
  124. func UpdateUserInfo(userId int) {
  125. args := &Request{
  126. UserId: userId,
  127. }
  128. err := getClient().Call(context.Background(), "UpdateUserInfo", args, nil)
  129. if err != nil {
  130. log.Debug("userservices failed to call: %v", err)
  131. common.GetClientPool().RemoveClient(ServiceName)
  132. return
  133. }
  134. }
  135. func SetUserDecoration(userId int, decorationType int, itemId int) bool {
  136. args := &Request{
  137. UserId: userId,
  138. DecorationType: decorationType,
  139. ItemId: itemId,
  140. }
  141. reply := &Response{}
  142. err := getClient().Call(context.Background(), "SetUserDecoration", args, reply)
  143. if err != nil {
  144. log.Debug("userservices failed to call: %v", err)
  145. common.GetClientPool().RemoveClient(ServiceName)
  146. return false
  147. }
  148. return reply.Success
  149. }
  150. func GetUserDecoration(userId int) []UserDecoration {
  151. var ret []UserDecoration
  152. usr := GetUserInfo(userId)
  153. if usr != nil {
  154. return usr.Decorations
  155. }
  156. return ret
  157. }
  158. func OnDecorationExpired(userId int, itemId int) {
  159. args := &Request{
  160. UserId: userId,
  161. ItemId: itemId,
  162. }
  163. err := getClient().Call(context.Background(), "OnDecorationExpired", args, nil)
  164. if err != nil {
  165. log.Debug("userservices.OnDecorationExpired failed to call: %v", err)
  166. common.GetClientPool().RemoveClient(ServiceName)
  167. return
  168. }
  169. }
  170. // 设置开关状态
  171. func ChangeSwitchStatus(userId int, switchInfo SwitchInfo) {
  172. args := &Request_Switch{
  173. UserId: userId,
  174. SwitchInfo: switchInfo,
  175. }
  176. // 设置后同时设置变量
  177. if err := getClient().Call(context.Background(), "ChangeSwitchStatus", args, nil); err != nil {
  178. log.Debug("userservices.ChangeSwitchStatus switchInfo: %v, failed to call: %v", switchInfo, err)
  179. common.GetClientPool().RemoveClient(ServiceName)
  180. return
  181. }
  182. return
  183. }
  184. func GetSwitchLevelInfo() []SwitchLevel {
  185. xclient := getClient()
  186. args := &Request{}
  187. reply := &Response{}
  188. err := xclient.Call(context.Background(), "GetSwitchLevelInfo", args, reply)
  189. if err != nil {
  190. log.Debug("userservices failed to call: %v", err)
  191. common.GetClientPool().RemoveClient(ServiceName)
  192. return nil
  193. }
  194. return reply.SwitchLevelList
  195. }
  196. func AddUserCharm(userId int, charm int) {
  197. args := &Request{
  198. UserId: userId,
  199. Charm: charm,
  200. }
  201. // 设置后同时设置变量
  202. if err := getClient().Call(context.Background(), "AddUserCharm", args, nil); err != nil {
  203. log.Debug("userservices.AddUserCharm : %d:%d, failed to call: %v", userId, charm, err)
  204. common.GetClientPool().RemoveClient(ServiceName)
  205. }
  206. }