vipservice.pb.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. package proto
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/common"
  5. "context"
  6. "encoding/json"
  7. )
  8. type Request_vip struct {
  9. ProductId string
  10. PrivilegeType int
  11. PurchaseSeconds int
  12. Point int
  13. UserId int
  14. Level int
  15. Name string
  16. ToUserId int
  17. }
  18. type Reponse_vip struct {
  19. Value int
  20. Code int
  21. Data string
  22. Success bool
  23. UserVip *UserVip
  24. VipList []VipInfo
  25. VipInfo *VipInfo
  26. PurchasePackages []PurchasePackage
  27. }
  28. // 根据用户ID查询用户vip状态
  29. func GetUserVip(userId int) string {
  30. xclient := getClient()
  31. args := &Request_vip{
  32. UserId: userId,
  33. }
  34. reply := &Reponse_vip{}
  35. err := xclient.Call(context.Background(), "GetUserVip", args, reply)
  36. if err != nil {
  37. log.Debug("vipservice.GetUserVip failed to call: %v", err)
  38. common.GetClientPool().RemoveClient(ServiceName)
  39. return ""
  40. }
  41. if reply.UserVip == nil {
  42. return ""
  43. }
  44. d, _ := json.Marshal(reply.UserVip)
  45. return string(d)
  46. }
  47. func GetUserVipInfo(userId int) *UserVip {
  48. xclient := getClient()
  49. args := &Request_vip{
  50. UserId: userId,
  51. }
  52. reply := &Reponse_vip{}
  53. err := xclient.Call(context.Background(), "GetUserVip", args, reply)
  54. if err != nil {
  55. log.Debug("vipservice.GetUserVip failed to call: %v", err)
  56. common.GetClientPool().RemoveClient(ServiceName)
  57. return nil
  58. }
  59. return reply.UserVip
  60. }
  61. // 获取vip列表,前端展现用
  62. func GetVipList() string {
  63. xclient := getClient()
  64. args := &Request_vip{}
  65. reply := &Reponse_vip{}
  66. err := xclient.Call(context.Background(), "GetVipList", args, reply)
  67. if err != nil {
  68. log.Debug("vipservice.GetVipList failed to call: %v", err)
  69. common.GetClientPool().RemoveClient(ServiceName)
  70. return ""
  71. }
  72. if reply.VipList == nil {
  73. return ""
  74. }
  75. d, _ := json.Marshal(reply.VipList)
  76. return string(d)
  77. }
  78. // 获取购买礼包列表
  79. func GetPurchasePackageList(userId int) string {
  80. xclient := getClient()
  81. args := &Request_vip{UserId: userId}
  82. reply := &Reponse_vip{}
  83. err := xclient.Call(context.Background(), "GetPurchasePackageList", args, reply)
  84. if err != nil {
  85. log.Debug("vipsvc.GetPurchasePackageList failed to call: %v", err)
  86. common.GetClientPool().RemoveClient(ServiceName)
  87. return ""
  88. }
  89. if reply.PurchasePackages == nil {
  90. return ""
  91. }
  92. d, _ := json.Marshal(reply.PurchasePackages)
  93. return string(d)
  94. }
  95. // 根据等级获取vip配置信息
  96. func GetVipByLevel(level int) *VipInfo {
  97. xclient := getClient()
  98. args := &Request_vip{
  99. Level: level,
  100. }
  101. reply := &Reponse_vip{}
  102. err := xclient.Call(context.Background(), "GetVipByLevel", args, reply)
  103. if err != nil {
  104. log.Debug("vipservice.GetVipByLevel failed to call: %v", err)
  105. common.GetClientPool().RemoveClient(ServiceName)
  106. return nil
  107. }
  108. log.Debug("GetVipByLevel return %+v", reply.VipInfo)
  109. return reply.VipInfo
  110. }
  111. // 获取额外补助百分比
  112. func GetExtraBankruptcy(userId int) int {
  113. xclient := getClient()
  114. args := &Request_vip{
  115. UserId: userId,
  116. }
  117. reply := &Reponse_vip{}
  118. err := xclient.Call(context.Background(), "GetExtraBankruptcy", args, reply)
  119. if err != nil {
  120. log.Debug("vipservice.GetExtraBankruptcy failed to call: %v", err)
  121. common.GetClientPool().RemoveClient(ServiceName)
  122. return 0
  123. }
  124. return reply.Value
  125. }
  126. // 获取额外经验百分比
  127. func GetExtraExperience(userId int) int {
  128. xclient := getClient()
  129. args := &Request_vip{
  130. UserId: userId,
  131. }
  132. reply := &Reponse_vip{}
  133. err := xclient.Call(context.Background(), "GetExtraExperience", args, reply)
  134. if err != nil {
  135. log.Debug("vipservice.GetExtraExperience failed to call: %v", err)
  136. common.GetClientPool().RemoveClient(ServiceName)
  137. return 0
  138. }
  139. return reply.Value
  140. }
  141. // 获取额外好友上限数量
  142. func GetExtraFriendCount(userId int) int {
  143. xclient := getClient()
  144. args := &Request_vip{
  145. UserId: userId,
  146. }
  147. reply := &Reponse_vip{}
  148. err := xclient.Call(context.Background(), "GetExtraFriendCount", args, reply)
  149. if err != nil {
  150. log.Debug("vipservice.GetExtraFriendCount failed to call: %v", err)
  151. common.GetClientPool().RemoveClient(ServiceName)
  152. return 0
  153. }
  154. return reply.Value
  155. }
  156. func GetUserPrivilegeValue(userId, privilegeType int) int {
  157. xclient := getClient()
  158. args := &Request_vip{
  159. UserId: userId,
  160. PrivilegeType: privilegeType,
  161. }
  162. reply := &Reponse_vip{}
  163. err := xclient.Call(context.Background(), "GetUserPrivilegeValue", args, reply)
  164. if err != nil {
  165. log.Debug("vipservice.GetUserPrivilegeValue failed to call: %v", err)
  166. common.GetClientPool().RemoveClient(ServiceName)
  167. return 0
  168. }
  169. return reply.Value
  170. }
  171. func CanKickPrivateRoomUser(userId, toUserId int) bool {
  172. xclient := getClient()
  173. args := &Request_vip{
  174. UserId: userId,
  175. ToUserId: toUserId,
  176. }
  177. reply := &Reponse_vip{}
  178. err := xclient.Call(context.Background(), "CanKickPrivateRoomUser", args, reply)
  179. if err != nil {
  180. log.Debug("vipservice.CanKickPrivateRoomUser failed to call: %v", err)
  181. common.GetClientPool().RemoveClient(ServiceName)
  182. return false
  183. }
  184. return reply.Success
  185. }
  186. // 判断是否能购买礼包
  187. func CanBuyPackage(userId int, productId string) bool {
  188. xclient := getClient()
  189. args := &Request_vip{
  190. UserId: userId,
  191. ProductId: productId,
  192. }
  193. reply := &Reponse_vip{}
  194. err := xclient.Call(context.Background(), "CanBuyPackage", args, reply)
  195. if err != nil {
  196. log.Debug("vipservice.CanBuyPackage failed to call: %v", err)
  197. common.GetClientPool().RemoveClient(ServiceName)
  198. return false
  199. }
  200. return reply.Success
  201. }
  202. // 实际购买礼包(已完成支付),发放道具,添加购买历史记录
  203. func BuyPackage(userId int, productId string) {
  204. xclient := getClient()
  205. args := &Request_vip{
  206. UserId: userId,
  207. ProductId: productId,
  208. }
  209. err := xclient.Call(context.Background(), "BuyPackage", args, nil)
  210. if err != nil {
  211. log.Debug("vipservice.BuyPackage failed to call: %v", err)
  212. common.GetClientPool().RemoveClient(ServiceName)
  213. }
  214. }
  215. // 添加vip点数,可能触发升级,升级如果当前是vip,则需要发放登录道具和升级道具
  216. func AddVipPoint(userId int, point int) {
  217. xclient := getClient()
  218. args := &Request_vip{
  219. UserId: userId,
  220. Point: point,
  221. }
  222. err := xclient.Call(context.Background(), "AddVipPoint", args, nil)
  223. if err != nil {
  224. log.Debug("vipservice.AddVipPoint failed to call: %v", err)
  225. common.GetClientPool().RemoveClient(ServiceName)
  226. }
  227. }
  228. // 添加vip时长(已完成支付)
  229. func AddVipSeconds(userId int, purchaseSeconds int) {
  230. xclient := getClient()
  231. args := &Request_vip{
  232. UserId: userId,
  233. PurchaseSeconds: purchaseSeconds,
  234. }
  235. err := xclient.Call(context.Background(), "AddVipSeconds", args, nil)
  236. if err != nil {
  237. log.Debug("vipservice.AddVipSeconds failed to call: %v", err)
  238. common.GetClientPool().RemoveClient(ServiceName)
  239. }
  240. }
  241. // 检查是否能够领取每日礼包
  242. func CheckDailyAward(userId int) (bool, int) {
  243. xclient := getClient()
  244. args := &Request_vip{
  245. UserId: userId,
  246. }
  247. reply := &Reponse_vip{}
  248. err := xclient.Call(context.Background(), "CheckDailyAward", args, reply)
  249. if err != nil {
  250. log.Debug("vipservice.CheckDailyAward failed to call: %v", err)
  251. common.GetClientPool().RemoveClient(ServiceName)
  252. return false, -1
  253. }
  254. return reply.Success, reply.Code
  255. }
  256. // 领取每日奖励
  257. func GiftDailyAward(userId int) string {
  258. xclient := getClient()
  259. args := &Request_vip{
  260. UserId: userId,
  261. }
  262. reply := &Reponse_vip{}
  263. err := xclient.Call(context.Background(), "GiftDailyAward", args, reply)
  264. if err != nil {
  265. log.Debug("vipservice.GiftDailyAward failed to call: %v", err)
  266. common.GetClientPool().RemoveClient(ServiceName)
  267. return "fail"
  268. }
  269. return "ok"
  270. }