room.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package admin
  2. import (
  3. "bet24.com/servers/micros/audioroom/handler/manager"
  4. pb "bet24.com/servers/micros/audioroom/proto"
  5. "sort"
  6. )
  7. var Mgr *adminMgr
  8. type adminMgr struct {
  9. }
  10. func LoadAdminMgr() {
  11. Mgr = new(adminMgr)
  12. return
  13. }
  14. // 获取房间列表 - 后台
  15. func (this *adminMgr) AdminGetRoomList(roomName, sortName, sortType string, roomId int) []pb.AdminRoomInfo {
  16. ret := manager.AdminMgr.GetRoomList(roomName, roomId)
  17. if sortName == "Level" {
  18. this.adminRoomLevelSort(ret, sortType) // 房间等级排序
  19. } else if sortName == "MemberCount" {
  20. this.adminMemberCountSort(ret, sortType) // 成员数量排序
  21. } else if sortName == "CollectDiamond" {
  22. this.adminCollectDiamondSort(ret, sortType) // 钻石收益排序
  23. } else if sortName == "DiamondAmount" {
  24. this.adminDiamondAmountSort(ret, sortType) // 钻石消耗排序
  25. } else if sortName == "CollectGold" {
  26. this.adminCollectGoldSort(ret, sortType) // 金币收益排序
  27. } else if sortName == "GoldAmount" {
  28. this.adminGoldAmountSort(ret, sortType) // 金币消耗排序
  29. } else {
  30. sort.SliceStable(ret, func(i, j int) bool {
  31. return ret[i].Crdate > ret[j].Crdate
  32. })
  33. }
  34. return ret
  35. }
  36. // 房间等级排序 - 后台
  37. func (this *adminMgr) adminRoomLevelSort(items []pb.AdminRoomInfo, sortOrder string) {
  38. sort.SliceStable(items, func(i, j int) bool {
  39. if sortOrder == "ASC" {
  40. if items[i].Level == items[j].Level {
  41. if items[i].Exps == items[j].Exps {
  42. return items[i].Crdate > items[j].Crdate
  43. }
  44. return items[i].Exps < items[j].Exps
  45. }
  46. return items[i].Level < items[j].Level
  47. }
  48. if items[i].Level == items[j].Level {
  49. if items[i].Exps == items[j].Exps {
  50. return items[i].Crdate > items[j].Crdate
  51. }
  52. return items[i].Exps > items[j].Exps
  53. }
  54. return items[i].Level > items[j].Level
  55. })
  56. }
  57. // 成员数量排序 - 后台
  58. func (this *adminMgr) adminMemberCountSort(items []pb.AdminRoomInfo, sortOrder string) {
  59. sort.SliceStable(items, func(i, j int) bool {
  60. if items[i].MemberCount == items[j].MemberCount {
  61. return items[i].Crdate > items[j].Crdate
  62. }
  63. if sortOrder == "ASC" {
  64. return items[i].MemberCount < items[j].MemberCount
  65. }
  66. return items[i].MemberCount > items[j].MemberCount
  67. })
  68. }
  69. // 钻石收益排序 - 后台
  70. func (this *adminMgr) adminCollectDiamondSort(items []pb.AdminRoomInfo, sortOrder string) {
  71. sort.SliceStable(items, func(i, j int) bool {
  72. if items[i].CollectDiamond == items[j].CollectDiamond {
  73. return items[i].Crdate > items[j].Crdate
  74. }
  75. if sortOrder == "ASC" {
  76. return items[i].CollectDiamond < items[j].CollectDiamond
  77. }
  78. return items[i].CollectDiamond > items[j].CollectDiamond
  79. })
  80. }
  81. // 钻石消耗排序 - 后台
  82. func (this *adminMgr) adminDiamondAmountSort(items []pb.AdminRoomInfo, sortOrder string) {
  83. sort.SliceStable(items, func(i, j int) bool {
  84. if items[i].DiamondAmount == items[j].DiamondAmount {
  85. return items[i].Crdate > items[j].Crdate
  86. }
  87. if sortOrder == "ASC" {
  88. return items[i].DiamondAmount < items[j].DiamondAmount
  89. }
  90. return items[i].DiamondAmount > items[j].DiamondAmount
  91. })
  92. }
  93. // 金币收益排序 - 后台
  94. func (this *adminMgr) adminCollectGoldSort(items []pb.AdminRoomInfo, sortOrder string) {
  95. sort.SliceStable(items, func(i, j int) bool {
  96. if items[i].CollectGold == items[j].CollectGold {
  97. return items[i].Crdate > items[j].Crdate
  98. }
  99. if sortOrder == "ASC" {
  100. return items[i].CollectGold < items[j].CollectGold
  101. }
  102. return items[i].CollectGold > items[j].CollectGold
  103. })
  104. }
  105. // 金币消耗排序 - 后台
  106. func (this *adminMgr) adminGoldAmountSort(items []pb.AdminRoomInfo, sortOrder string) {
  107. sort.SliceStable(items, func(i, j int) bool {
  108. if items[i].GoldAmount == items[j].GoldAmount {
  109. return items[i].Crdate > items[j].Crdate
  110. }
  111. if sortOrder == "ASC" {
  112. return items[i].GoldAmount < items[j].GoldAmount
  113. }
  114. return items[i].GoldAmount > items[j].GoldAmount
  115. })
  116. }
  117. // 获取语聊房详细信息 - 后台
  118. func (this *adminMgr) AdminGetRoomDetail(roomId int) pb.AdminRoomDetail {
  119. var resp pb.AdminRoomDetail
  120. roomInfo := manager.AdminMgr.GetRoom(roomId)
  121. if roomInfo == nil {
  122. return resp
  123. }
  124. expend := manager.AdminMgr.GetRoomExpend(roomId)
  125. resp.RoomId = roomInfo.RoomId
  126. resp.RoomName = roomInfo.RoomName
  127. resp.RoomImg = roomInfo.RoomImg
  128. resp.Family = roomInfo.Family
  129. resp.Country = roomInfo.Country
  130. resp.Language = roomInfo.Language
  131. resp.JoinFee = roomInfo.JoinFee
  132. resp.Announce = roomInfo.Announce
  133. resp.Tag = roomInfo.Tag
  134. resp.MemberCount = roomInfo.MemberCount
  135. resp.Crdate = roomInfo.Crdate
  136. resp.Level = roomInfo.Level
  137. resp.Exps = roomInfo.Exps
  138. resp.UpMicCount = roomInfo.GetUpMicCount()
  139. resp.CollectDiamond = expend.CollectDiamond
  140. resp.DiamondAmount = expend.DiamondAmount
  141. resp.CollectGold = expend.CollectGold
  142. resp.GoldAmount = expend.GoldAmount
  143. resp.OnlineCount = roomInfo.OnlineCount
  144. resp.CumulativeDuration = 0
  145. return resp
  146. }