XYChatRoomInfoManager.m 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. //
  2. // XYChatRoomInfoManager.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/7/8.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYChatRoomInfoManager.h"
  9. #import "XYChatRoomMenuItemModel.h"
  10. #import "XYChatRoomDiamondRankModel.h"
  11. #import "XYLiveRoomAPIManager.h"
  12. #import "XYChatRoomListModel.h"
  13. #import "XYChatRoomPKTimeModel.h"
  14. #import "XYChatRoomAuctionRankItemModel.h"
  15. @implementation XYChatRoomInfoManager
  16. - (void)clear {
  17. }
  18. - (instancetype)init
  19. {
  20. self = [super init];
  21. if (self) {
  22. [self initValue];
  23. }
  24. return self;
  25. }
  26. - (void)initValue {
  27. self.enableSpeakerphone = YES;
  28. self.KFPkMatchNumber = 10;
  29. }
  30. #pragma mark — 更新管理菜单 根据角色生成对应的菜单数组
  31. - (NSArray *)updateMenuData {
  32. [self.menuItemModelArray removeAllObjects];
  33. NSMutableArray *oneSetionArray = [NSMutableArray array];
  34. if (self.role > XYVoiceRoomRoleAudience) {
  35. if (self.roomInfoModel.roomType != XYVoiceRoomTypeLove && self.roomInfoModel.roomType != XYVoiceRoomTypeAuction) {
  36. XYChatRoomMenuItemModel *heratModel = XYChatRoomMenuItemModel.new;
  37. heratModel.title = @"心动值";
  38. heratModel.imageName = @"xy-chatroom-menu-herat";
  39. heratModel.menuType = XYChatRoomMenuTypeCardiacValue;
  40. heratModel.typesWitch = self.roomInfoModel.roomScoreEnabled;
  41. [oneSetionArray addObject:heratModel];
  42. XYChatRoomMenuItemModel *freeMicrophoneModel = XYChatRoomMenuItemModel.new;
  43. freeMicrophoneModel.title = @"自由上麦";
  44. freeMicrophoneModel.imageName = @"xy-chatroom-menu-microphone";
  45. freeMicrophoneModel.menuType = XYChatRoomMenuTypeFreeMacphone;
  46. freeMicrophoneModel.typesWitch = self.roomInfoModel.roomMicFree;
  47. [oneSetionArray addObject:freeMicrophoneModel];
  48. }
  49. // XYChatRoomMenuItemModel *lockModel = XYChatRoomMenuItemModel.new;
  50. // lockModel.title = @"自动锁麦";
  51. // lockModel.imageName = @"xy-chatroom-menu-lock";
  52. // lockModel.menuType = XYChatRoomMenuTypeFreeLockMacphone;
  53. // lockModel.typesWitch = self.isFreeLockMacphone;
  54. // [oneSetionArray addObject:lockModel];
  55. XYChatRoomMenuItemModel *roomLockModel = XYChatRoomMenuItemModel.new;
  56. roomLockModel.title = @"房间上锁";
  57. roomLockModel.imageName = @"xy-chatroom-menu-lockHome";
  58. roomLockModel.menuType = XYChatRoomMenuTypeRoomLock;
  59. roomLockModel.typesWitch = self.roomInfoModel.needPass;
  60. [oneSetionArray addObject:roomLockModel];
  61. XYChatRoomMenuItemModel *closeBarrageModel = XYChatRoomMenuItemModel.new;
  62. closeBarrageModel.title = @"关闭公屏";
  63. closeBarrageModel.imageName = @"xy-chatroom-menu-closeBarrage";
  64. closeBarrageModel.menuType = XYChatRoomMenuTypeClearScreen;
  65. closeBarrageModel.typesWitch = !self.roomInfoModel.roomChatEnabled;
  66. [oneSetionArray addObject:closeBarrageModel];
  67. if (self.roomInfoModel.roomType != XYVoiceRoomTypeLove) {
  68. XYChatRoomMenuItemModel *incomeModel = XYChatRoomMenuItemModel.new;
  69. incomeModel.title = @"麦位收益";
  70. incomeModel.imageName = @"xy-chatroom-menu-income";
  71. incomeModel.menuType = XYChatRoomMenuTypeMcphoneSeatIncome;
  72. [oneSetionArray addObject:incomeModel];
  73. }
  74. }
  75. if (self.isCurrentOnMicrophone) {
  76. XYChatRoomMenuItemModel *recordModel = XYChatRoomMenuItemModel.new;
  77. recordModel.title = @"背景音乐";
  78. recordModel.imageName = @"xy-chatroom-menu-record";
  79. recordModel.menuType = XYChatRoomMenuTypeMcphoneBackgroundMusic;
  80. [oneSetionArray addObject:recordModel];
  81. // XYChatRoomMenuItemModel *soundModel = XYChatRoomMenuItemModel.new;
  82. // soundModel.title = @"混响音效";
  83. // soundModel.imageName = @"xy-chatroom-menu-sound";
  84. // soundModel.menuType = XYChatRoomMenuTypeRoomSound;
  85. // [oneSetionArray addObject:soundModel];
  86. }
  87. if (self.role > XYVoiceRoomRoleAudience) {
  88. XYChatRoomMenuItemModel *roomSetModel = XYChatRoomMenuItemModel.new;
  89. roomSetModel.title = @"房间管理";
  90. roomSetModel.imageName = @"xy-chatroom-menu-setting";
  91. roomSetModel.menuType = XYChatRoomMenuTypeRoomManage;
  92. [oneSetionArray addObject:roomSetModel];
  93. XYChatRoomMenuItemModel *seatModel = XYChatRoomMenuItemModel.new;
  94. seatModel.title = @"麦序管理";
  95. seatModel.imageName = @"xy-chatroom-menu-seat";
  96. seatModel.menuType = XYChatRoomMenuTypeMcphoneSeatManage;
  97. [oneSetionArray addObject:seatModel];
  98. }
  99. if (self.isCurrentOnMicrophone) {
  100. XYChatRoomMenuItemModel *speakerModel = XYChatRoomMenuItemModel.new;
  101. speakerModel.title = kLocalizedString(@"召集粉丝");
  102. speakerModel.imageName = @"xy-chatroom-menu-speaker";
  103. speakerModel.menuType = XYChatRoomMenuTypeRoomConveneFans;
  104. [oneSetionArray addObject:speakerModel];
  105. }
  106. if (self.role > XYVoiceRoomRoleAudience) {
  107. if (self.roomInfoModel.roomType != XYVoiceRoomTypeLove && self.roomInfoModel.roomType != XYVoiceRoomTypeAuction) {
  108. XYChatRoomMenuItemModel *heratValueListModel = XYChatRoomMenuItemModel.new;
  109. heratValueListModel.title = @"心动值列表";
  110. heratValueListModel.imageName = @"xy-chatroom-heartvalue-listbtn";
  111. heratValueListModel.menuType = XYChatRoomMenuTypeCardiacValueList;
  112. [oneSetionArray addObject:heratValueListModel];
  113. }
  114. }
  115. // 主持人才有转盘图标
  116. if (self.isCurrentHost) {
  117. XYChatRoomMenuItemModel *heratValueListModel = XYChatRoomMenuItemModel.new;
  118. heratValueListModel.title = @"大冒险";
  119. heratValueListModel.imageName = @"xy-chatroom-menu-rotaryTable";
  120. heratValueListModel.menuType = XYChatRoomMenuTypeRotaryTable;
  121. [oneSetionArray addObject:heratValueListModel];
  122. }
  123. if (self.battleEnabled) {
  124. if (self.isCurrentHost) {
  125. // PK玩法
  126. XYChatRoomMenuItemModel *pkModel = XYChatRoomMenuItemModel.new;
  127. pkModel.title = @"PK玩法";
  128. pkModel.imageName = @"xy-chatroom-menu-pk";
  129. pkModel.menuType = XYChatRoomMenuTypePK;
  130. [oneSetionArray addObject:pkModel];
  131. }
  132. }
  133. // 开关播
  134. if (self.role > XYVoiceRoomRoleMaster) {
  135. if (self.roomInfoModel.roomType != XYVoiceRoomTypeVoiceLive) {
  136. XYChatRoomMenuItemModel *liveModel = XYChatRoomMenuItemModel.new;
  137. if (self.isLive) {
  138. liveModel.title = @"关播";
  139. liveModel.imageName = @"xy-chatroom-menu-close";
  140. }else {
  141. liveModel.title = @"开播";
  142. liveModel.imageName = @"xy-chatroom-menu-start";
  143. }
  144. liveModel.menuType = XYChatRoomMenuTypeStartAndEnd;
  145. [oneSetionArray addObject:liveModel];
  146. }
  147. }
  148. if (oneSetionArray.count > 0) {
  149. [self.menuItemModelArray addObject:oneSetionArray];
  150. }
  151. // 常驻功能
  152. NSMutableArray *commonSectionArray = [NSMutableArray array];
  153. // XYChatRoomMenuItemModel *shareModel = XYChatRoomMenuItemModel.new;
  154. // shareModel.title = @"分享";
  155. // shareModel.imageName = @"xy-chatroom-menu-share";
  156. // shareModel.menuType = XYChatRoomMenuTypeRoomShare;
  157. // [commonSectionArray addObject:shareModel];
  158. XYChatRoomMenuItemModel *weModel = XYChatRoomMenuItemModel.new;
  159. weModel.title = @"在线用户";
  160. weModel.imageName = @"xy-chatroom-menu-we";
  161. weModel.menuType = XYChatRoomMenuTypeRoomOnlineUsers;
  162. [commonSectionArray addObject:weModel];
  163. XYChatRoomMenuItemModel *receiverModel = XYChatRoomMenuItemModel.new;
  164. receiverModel.title = @"使用听筒";
  165. receiverModel.imageName = @"xy-chatroom-menu-headset";
  166. receiverModel.menuType = XYChatRoomMenuTypeRoomReceiver;
  167. [commonSectionArray addObject:receiverModel];
  168. if (commonSectionArray.count > 0) {
  169. [self.menuItemModelArray addObject:commonSectionArray];
  170. }
  171. XYChatRoomMenuItemModel *effectModel = XYChatRoomMenuItemModel.new;
  172. effectModel.title = @"礼物动效";
  173. effectModel.imageName = @"xy-chatroom-menu-effect";
  174. effectModel.menuType = XYChatRoomMenuTypeRoomEffect;
  175. effectModel.typesWitch = ![XYUserSwitchManager sharedInstance].isEffectEnabled;
  176. [commonSectionArray addObject:effectModel];
  177. return self.menuItemModelArray;
  178. }
  179. #pragma mark — Public
  180. // 获取直播间信息
  181. - (void)getRoomInfoRequestCompleted:(void(^)(NSError *error))completed {
  182. dispatch_group_t group = dispatch_group_create();
  183. dispatch_queue_t queue = dispatch_queue_create("chat.room.info", DISPATCH_QUEUE_SERIAL);
  184. NSError *error = nil;
  185. if (!self.roomInfoModel.roomMicFree) {
  186. // 非自由上麦需要请求麦序队列当前上麦用户列表
  187. dispatch_group_enter(group);
  188. dispatch_async(queue, ^{
  189. [self getQueueUsersRequestCompleted:^(NSError *error) {
  190. error = error;
  191. dispatch_group_leave(group);
  192. }];
  193. });
  194. if (self.roomInfoModel.roomType == XYVoiceRoomTypeAuction) {
  195. dispatch_group_enter(group);
  196. dispatch_async(queue, ^{
  197. [self getAcutionQueueUsersRequestCompleted:^(NSError *error) {
  198. error = error;
  199. dispatch_group_leave(group);
  200. }];
  201. });
  202. }
  203. }
  204. // 获取房间周榜
  205. dispatch_group_enter(group);
  206. dispatch_async(queue, ^{
  207. [self getDiamondRankWeekCompleted:^(NSError *error) {
  208. dispatch_group_leave(group);
  209. }];
  210. });
  211. // 获取房间昨日MVP
  212. dispatch_group_enter(group);
  213. dispatch_async(queue, ^{
  214. [self getYesterdayDiamondRankMVPCompleted:^(NSError *error) {
  215. dispatch_group_leave(group);
  216. }];
  217. });
  218. // 获取语音房活动列表
  219. dispatch_group_enter(group);
  220. dispatch_async(queue, ^{
  221. [self getActivityRequestCompleted:^(NSError * _Nonnull error) {
  222. dispatch_group_leave(group);
  223. }];
  224. });
  225. // 小时榜排名
  226. dispatch_group_enter(group);
  227. dispatch_async(queue, ^{
  228. [self getRtcHourRankCompleted:^(NSError * _Nonnull error) {
  229. dispatch_group_leave(group);
  230. }];
  231. });
  232. // 房间内PK配置
  233. if ([AppDelegate sharedDelegate].appConfigModel.battleTimeConfigArray.count == 0) {
  234. dispatch_group_enter(group);
  235. dispatch_async(queue, ^{
  236. [[XYConfigAPIManager new] getBattleRoomInConfigSuccessHandler:^(ZYLResponseModel *responseModel) {
  237. NSMutableArray *temp = [NSMutableArray array];
  238. for (NSDictionary *dict in responseModel.data[@"list"]) {
  239. XYChatRoomPKTimeModel *model = XYChatRoomPKTimeModel.new;
  240. [model yy_modelSetWithDictionary:dict];
  241. [temp addObject:model];
  242. }
  243. [AppDelegate sharedDelegate].appConfigModel.battleTimeConfigArray = temp;
  244. dispatch_group_leave(group);
  245. } failureHandler:^(ZYLNetworkError *error) {
  246. dispatch_group_leave(group);
  247. }];
  248. });
  249. }
  250. dispatch_group_notify(group, queue, ^{
  251. dispatch_async(dispatch_get_main_queue(), ^{
  252. !completed?:completed(error);
  253. });
  254. });
  255. }
  256. /// 获取当前房间小时榜排名
  257. - (void)getRtcHourRankCompleted:(void(^)(NSError *error))completed {
  258. [[XYVoiceRoomAPIManager new] getRtcHourRankSuccessHandler:^(ZYLResponseModel *responseModel) {
  259. // 小时榜url
  260. NSString *hourRank = responseModel.data[@"hourRank"];
  261. self.hoursRankUrl = hourRank;
  262. NSMutableArray *temp = [NSMutableArray array];
  263. self.hoursRankIndex = -1;
  264. for (NSDictionary *dict in responseModel.data[@"list"]) {
  265. XYChatRoomListModel *model = XYChatRoomListModel.new;
  266. [model yy_modelSetWithDictionary:dict];
  267. [temp addObject:model];
  268. if ([self.roomInfoModel.roomId isEqualToString:model.roomId]) {
  269. self.hoursRankIndex = model.rankNo;
  270. }
  271. }
  272. self.hoursDataSource = [NSArray arrayWithArray:temp];
  273. !completed?:completed(nil);
  274. } failureHandler:^(ZYLNetworkError *error) {
  275. !completed?:completed(error);
  276. }];
  277. }
  278. // 获取昨日榜单MVP
  279. - (void)getYesterdayDiamondRankMVPCompleted:(void(^)(NSError *error))completed {
  280. [[XYVoiceRoomAPIManager new] getYesterdayDiamondRankMVPWithRoomId:self.roomInfoModel.roomId successHandler:^(ZYLResponseModel *responseModel) {
  281. if (responseModel.data) {
  282. self.roomYesterdayMVPModel = XYChatRoomMVPModel.new;
  283. [self.roomYesterdayMVPModel yy_modelSetWithDictionary:responseModel.data];
  284. }else {
  285. self->_roomYesterdayMVPModel = nil;
  286. }
  287. !completed?:completed(nil);
  288. } failureHandler:^(ZYLNetworkError *error) {
  289. !completed?:completed(error);
  290. }];
  291. }
  292. // 获取聊天室活动
  293. - (void)getActivityRequestCompleted:(void(^)(NSError *error))completed{
  294. [[XYLiveRoomAPIManager new] getChatRoomActivities:@{@"roomId":self.roomInfoModel.roomId} successHandler:^(ZYLResponseModel *responseModel) {
  295. [self.allActivityArrs removeAllObjects];
  296. for (NSDictionary *dict in responseModel.data[@"list"]) {
  297. XYLiveRoomActivityInfo *info = [[XYLiveRoomActivityInfo alloc] init];
  298. [info yy_modelSetWithDictionary:dict];
  299. [self.allActivityArrs addObject:info];
  300. }
  301. !completed?:completed(nil);
  302. } failureHandler:^(ZYLNetworkError *error) {
  303. !completed?:completed(error);
  304. }];
  305. }
  306. - (void)getDiamondRankWeekCompleted:(void(^)(NSError *error))completed {
  307. [[XYVoiceRoomAPIManager new] getDiamondRankWeekWithRoomId:self.roomInfoModel.roomId successHandler:^(ZYLResponseModel *responseModel) {
  308. [self.diamondRankArray removeAllObjects];
  309. for (NSDictionary *dict in responseModel.data[@"list"]) {
  310. XYChatRoomDiamondRankModel *modle = XYChatRoomDiamondRankModel.new;
  311. [modle yy_modelSetWithDictionary:dict];
  312. [self.diamondRankArray addObject:modle];
  313. }
  314. !completed?:completed(nil);
  315. } failureHandler:^(ZYLNetworkError *error) {
  316. !completed?:completed(error);
  317. }];
  318. }
  319. /// 获取麦序队列数量和判断出自己是否加入麦序队列
  320. - (void)getQueueUsersRequestCompleted:(void(^)(NSError *error))completed {
  321. if (self.roomInfoModel.roomType == XYVoiceRoomTypeAuction) {
  322. [[XYVoiceRoomAPIManager new] getQueueUsersInAuctionWithRoomId:self->_roomInfoModel.roomId type:2 successHandler:^(ZYLResponseModel *responseModel) {
  323. self.isJoinQueue = NO;
  324. // 获取当前麦序队列用户数量
  325. NSArray *list = responseModel.data[@"list"];
  326. self.queueUsersCount = [list count];
  327. for (NSDictionary *dict in list) {
  328. NSString *userId = dict[@"userId"];
  329. // 判断自己有没有在麦序里
  330. if ([userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  331. self.isJoinQueue = YES;
  332. break;
  333. }
  334. }
  335. !completed?:completed(nil);
  336. } failureHandler:^(ZYLNetworkError *error) {
  337. !completed?:completed(error);
  338. }];
  339. }else {
  340. [[XYVoiceRoomAPIManager new] getQueueUsersWithRoomId:self->_roomInfoModel.roomId successHandler:^(ZYLResponseModel *responseModel) {
  341. self.isJoinQueue = NO;
  342. // 获取当前麦序队列用户数量
  343. NSArray *list = responseModel.data[@"list"];
  344. self.queueUsersCount = [list count];
  345. for (NSDictionary *dict in list) {
  346. NSString *userId = dict[@"userId"];
  347. // 判断自己有没有在麦序里
  348. if ([userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  349. self.isJoinQueue = YES;
  350. break;
  351. }
  352. }
  353. !completed?:completed(nil);
  354. } failureHandler:^(ZYLNetworkError *error) {
  355. !completed?:completed(error);
  356. }];
  357. }
  358. }
  359. /// 获取拍卖麦序队列数量和判断出自己是否加入麦序队列
  360. - (void)getAcutionQueueUsersRequestCompleted:(void(^)(NSError *error))completed {
  361. [[XYVoiceRoomAPIManager new] getQueueUsersInAuctionWithRoomId:self->_roomInfoModel.roomId type:1 successHandler:^(ZYLResponseModel *responseModel) {
  362. self.isJoinAuctionQueue = NO;
  363. // 获取当前麦序队列用户数量
  364. NSArray *list = responseModel.data[@"list"];
  365. self.auctionQueueUsersCount = [list count];
  366. for (NSDictionary *dict in list) {
  367. NSString *userId = dict[@"userId"];
  368. // 判断自己有没有在麦序里
  369. if ([userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  370. self.isJoinAuctionQueue = YES;
  371. break;
  372. }
  373. }
  374. !completed?:completed(nil);
  375. } failureHandler:^(ZYLNetworkError *error) {
  376. !completed?:completed(error);
  377. }];
  378. }
  379. /// 获取麦序队列数量和判断出自己是否加入麦序队列
  380. - (void)getSeatsInfoRequestCompleted:(void(^)(NSError *error))completed {
  381. // 保留被选中接受礼物的用户
  382. NSMutableArray *tempArray = [NSMutableArray array];
  383. for (XYChatRoomSeatsModel *model in self.seatsArray) {
  384. if (model.user) {
  385. if (model.user.isSelected) {
  386. [tempArray addObject:model.user];
  387. }
  388. }
  389. }
  390. [[XYVoiceRoomAPIManager new] getSeatsWithRoomId:self.roomInfoModel.roomId successHandler:^(ZYLResponseModel *responseModel) {
  391. [self.seatsArray removeAllObjects];
  392. [self.seatUserArray removeAllObjects];
  393. NSMutableArray *seats = [NSMutableArray array];
  394. if (self.roomInfoModel.roomType == XYVoiceRoomTypeVoiceLive) {
  395. NSArray *tempSeats = responseModel.data[@"list"];
  396. if (tempSeats.count > 5) {
  397. [seats addObjectsFromArray:[tempSeats subarrayWithRange:NSMakeRange(0, 5)]];
  398. }else {
  399. [seats addObjectsFromArray:responseModel.data[@"list"]];
  400. }
  401. }else {
  402. [seats addObjectsFromArray:responseModel.data[@"list"]];
  403. }
  404. // 先重置用户的上麦状态
  405. self.isCurrentOnMicrophone = NO;
  406. self.isCurrentHost = NO;
  407. for (NSDictionary *dict in seats) {
  408. XYChatRoomSeatsModel *model = XYChatRoomSeatsModel.new;
  409. [model yy_modelSetWithDictionary:dict];
  410. model.isShowScore = self.roomInfoModel.roomScoreEnabled;
  411. [self.seatsArray addObject:model];
  412. if (model.user) {
  413. // 礼物选中状态更新
  414. for (XYChatRoomSeatsUserModel *giftModel in tempArray) {
  415. if ([model.user.userId isEqualToString:giftModel.userId]) {
  416. model.user.isSelected = giftModel.isSelected;
  417. }
  418. }
  419. // 麦位用户
  420. [self.seatUserArray addObject:model.user];
  421. // 获取当前用户的上麦的状态
  422. if ([model.user.userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  423. self.isCurrentOnMicrophone = YES;
  424. if (model.seatNo == 0) {
  425. self.isCurrentHost = YES;
  426. }
  427. }
  428. }
  429. }
  430. !completed?:completed(nil);
  431. } failureHandler:^(ZYLNetworkError *error) {
  432. !completed?:completed(error);
  433. }];
  434. }
  435. /// 更新心动值显示开关
  436. - (id)updateCardiacValueSwitch:(BOOL)scoreEnabled {
  437. // 更新状态
  438. self.roomInfoModel.roomScoreEnabled = scoreEnabled;
  439. XYChatRoomMenuItemModel *model = [self getMenuItemModelWithType:XYChatRoomMenuTypeCardiacValue];
  440. model.typesWitch = self.roomInfoModel.roomScoreEnabled;
  441. for (XYChatRoomSeatsModel *model in self.seatsArray) {
  442. model.isShowScore = self.roomInfoModel.roomScoreEnabled;
  443. }
  444. return model;
  445. }
  446. /// 更新自由上麦开关状态
  447. - (id)updateRoomMicFreeSwitch:(BOOL)roomMicFree {
  448. // 更新状态
  449. self.roomInfoModel.roomMicFree = roomMicFree;
  450. XYChatRoomMenuItemModel *model = [self getMenuItemModelWithType:XYChatRoomMenuTypeFreeMacphone];
  451. model.typesWitch = self.roomInfoModel.roomMicFree;
  452. return model;
  453. }
  454. /// 更新房间密码锁开关状态
  455. - (id)updateRoomLockSwitch:(BOOL)needPass {
  456. // 更新状态
  457. self.roomInfoModel.needPass = needPass;
  458. XYChatRoomMenuItemModel *model = [self getMenuItemModelWithType:XYChatRoomMenuTypeRoomLock];
  459. model.typesWitch = self.roomInfoModel.needPass;
  460. return model;
  461. }
  462. /// 更新公屏开关状态
  463. - (id)updateClearChatEnabledSwitch:(BOOL)chatEnabled {
  464. // 更新状态
  465. self.roomInfoModel.roomChatEnabled = chatEnabled;
  466. XYChatRoomMenuItemModel *model = [self getMenuItemModelWithType:XYChatRoomMenuTypeClearScreen];
  467. model.typesWitch = !self.roomInfoModel.roomChatEnabled;
  468. return model;
  469. }
  470. - (XYChatRoomSeatsUserModel *)auctionSeatUserModel {
  471. if (self.seatsArray.count > 2) {
  472. XYChatRoomSeatsModel *seatModel = self.seatsArray[1];
  473. if (seatModel.user && StringIsNotEmpty(seatModel.user.userId)) {
  474. return seatModel.user;
  475. }
  476. }
  477. return nil;
  478. }
  479. - (void)setIsCurrentHost:(BOOL)isCurrentHost {
  480. if (_isCurrentHost != isCurrentHost) {
  481. _isCurrentHost = isCurrentHost;
  482. !self.currentHostStateUpdateBlock?:self.currentHostStateUpdateBlock();
  483. }
  484. }
  485. #pragma mark — Method
  486. - (void)setRole:(XYVoiceRoomRole)role {
  487. _role = role;
  488. if (_profile) {
  489. [_profile setValue:@(role) forKey:@"userRole"];
  490. }
  491. }
  492. /// 获取空缺的普通麦位号 -1说明没有空缺的普通麦位
  493. - (NSInteger)getNoUserGeneralSeatNo {
  494. for (XYChatRoomSeatsModel *model in self.seatsArray) {
  495. if (model.seatNo != 0) {
  496. if (!model.user) {
  497. return model.seatNo;
  498. break;
  499. }
  500. }
  501. }
  502. return -1;
  503. }
  504. /// 找到指定菜单model
  505. - (XYChatRoomMenuItemModel *)getMenuItemModelWithType:(XYChatRoomMenuType)type {
  506. for (NSInteger i = 0; i < self.menuItemModelArray.count; i++) {
  507. NSArray *tempArray = self.menuItemModelArray[i];
  508. for (NSInteger y = 0; y < tempArray.count; y++) {
  509. XYChatRoomMenuItemModel *model = tempArray[y];
  510. if (model.menuType == type) {
  511. return model;
  512. break;
  513. }
  514. }
  515. }
  516. return nil;
  517. }
  518. /// 判断用户是否有权限
  519. - (BOOL)isLimitUser{
  520. if (self.role > XYVoiceRoomRoleAudience) {
  521. return YES;
  522. }
  523. return NO;
  524. }
  525. /// 获取指定用户资料的操作功能项
  526. - (NSArray *)getUserFunctionTitleWithUserId:(NSString *)userId andHideFunction:(BOOL )hideFunction{
  527. NSMutableArray *itemTitleArray = [NSMutableArray array];
  528. self.personDetailItemTitleArray = itemTitleArray;
  529. if (hideFunction) {//隐藏操作功能项,如点击全区礼物人时
  530. if (![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  531. // 不是自己才会显示私信和关注
  532. [itemTitleArray addObject:kLocalizedString(@"关注")];
  533. [itemTitleArray addObject:kLocalizedString(@"私信")];
  534. [itemTitleArray addObject:kLocalizedString(@"@TA")];
  535. [itemTitleArray addObject:kLocalizedString(@"送礼物")];
  536. }
  537. return itemTitleArray;
  538. }
  539. if (self.roomInfoModel.roomType == XYVoiceRoomTypeVoiceLive) {
  540. // 个播模式下房主及以上权限才可以设置管理,不能设置主持人
  541. if (self.role > XYVoiceRoomRoleMaster && ![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  542. [itemTitleArray addObject:kLocalizedString(@"管理")];
  543. }
  544. }else {
  545. if (self.role > XYVoiceRoomRoleHost && ![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  546. [itemTitleArray addObject:kLocalizedString(@"管理")];
  547. }
  548. }
  549. //[itemTitleArray addObject:kLocalizedString(@"查看资料")];
  550. if (![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  551. // 不是自己才会显示私信和关注
  552. [itemTitleArray addObject:kLocalizedString(@"关注")];
  553. [itemTitleArray addObject:kLocalizedString(@"私信")];
  554. [itemTitleArray addObject:kLocalizedString(@"@TA")];
  555. }
  556. // 常驻功能(除了自己都能送礼物)
  557. if (![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  558. [itemTitleArray addObject:kLocalizedString(@"送礼物")];
  559. }
  560. // 权限功能
  561. // 上下麦
  562. // 判断这个用户有没有上麦
  563. BOOL isOnMicrophone = [self judgeUserIsOnMicrophoneWithUserId:userId];
  564. if (isOnMicrophone) {
  565. // 上麦中
  566. if (self.role > XYVoiceRoomRoleAudience || [userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  567. if (self.roomInfoModel.roomType == XYVoiceRoomTypeLove) {
  568. XYChatRoomSeatsModel *seatModel = [self getUserSeatModelWithUserId:userId];
  569. if (seatModel.seatNo != 9) {
  570. // 老板麦上下麦后台控制
  571. [itemTitleArray addObject:kLocalizedString(@"下麦")];
  572. }
  573. }
  574. else if (self.roomInfoModel.roomType == XYVoiceRoomTypeVoiceLive) {
  575. XYChatRoomSeatsModel *seatModel = [self getUserSeatModelWithUserId:userId];
  576. if (seatModel.seatNo != 0) {
  577. // 个播模式下主持人不显示下麦操作
  578. [itemTitleArray addObject:kLocalizedString(@"下麦")];
  579. }
  580. }
  581. else {
  582. // 当主持人或者自己触发弹出时才会出现下麦功能
  583. [itemTitleArray addObject:kLocalizedString(@"下麦")];
  584. }
  585. }
  586. }else {
  587. // 没上麦
  588. if (self.role > XYVoiceRoomRoleAudience || [userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  589. // 当主持人或者自己触发弹出时才会出现上麦功能
  590. [itemTitleArray addObject:kLocalizedString(@"上麦")];
  591. }
  592. }
  593. // 禁言
  594. if (self.role > XYVoiceRoomRoleAudience && ![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  595. // 当前用户的权限大于观众就出现禁言功能
  596. XYChatRoomSeatsModel *seatModel = [self getUserSeatModelWithUserId:userId];
  597. if (seatModel==nil) {
  598. [itemTitleArray addObject:kLocalizedString(@"禁言")];
  599. }
  600. }
  601. // 清空心动值
  602. if (self.roomInfoModel.roomType != XYVoiceRoomTypeLove && self.roomInfoModel.roomType != XYVoiceRoomTypeAuction) {
  603. if (self.roomInfoModel.roomScoreEnabled && self.role > XYVoiceRoomRoleAudience) {
  604. // 房间开启了心动值开关且该用户在主持人麦
  605. [itemTitleArray addObject:kLocalizedString(@"清空心动值")];
  606. }
  607. }
  608. // 踢出房间
  609. if (self.role > XYVoiceRoomRoleAudience && ![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  610. // 当前用户的权限大于观众就出现禁言功能
  611. [itemTitleArray addObject:kLocalizedString(@"踢出房间")];
  612. }
  613. // 倒计时、麦位开麦闭麦
  614. if (self.role > XYVoiceRoomRoleAudience) {
  615. XYChatRoomSeatsModel *seatModel = [self getUserSeatModelWithUserId:userId];
  616. if (seatModel) {
  617. if (self.roomInfoModel.roomType != XYVoiceRoomTypeLove) {
  618. // 设置倒计时
  619. if (seatModel.countDownSeconds <= 0) {
  620. [itemTitleArray addObject:kLocalizedString(@"开启倒计时")];
  621. }else {
  622. [itemTitleArray addObject:kLocalizedString(@"结束倒计时")];
  623. }
  624. }
  625. // 设置麦位
  626. if (![userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  627. if (seatModel.micDisabled) {
  628. [itemTitleArray addObject:kLocalizedString(@"开麦")];
  629. }else {
  630. [itemTitleArray addObject:kLocalizedString(@"闭麦")];
  631. }
  632. }
  633. }
  634. }
  635. if (![[XYUserInfoManager nowUser].userId isEqualToString:userId]) {
  636. if (([XYChatRoomManager sharedInstance].chatRoomController.infoManager.roomInfoModel.roomType == XYVoiceRoomTypeOrder) && (self.isCurrentHost == YES)) {
  637. [itemTitleArray addObject:kLocalizedString(@"派单")];
  638. }
  639. }
  640. return itemTitleArray;
  641. }
  642. /// 判断这个用户是否在麦上
  643. /// @param userId 指定的用户id
  644. - (BOOL)judgeUserIsOnMicrophoneWithUserId:(NSString *)userId {
  645. BOOL isOnMicrophone = NO;
  646. for (XYChatRoomSeatsUserModel *model in self.seatUserArray) {
  647. if ([model.userId isEqualToString:userId]) {
  648. isOnMicrophone = YES;
  649. break;
  650. }
  651. }
  652. return isOnMicrophone;
  653. }
  654. /// 根据uid获取麦位model 不在麦上则返回nil
  655. /// @param userId 指定的用户id
  656. - (XYChatRoomSeatsModel *)getUserSeatModelWithUserId:(NSString *)userId {
  657. for (XYChatRoomSeatsModel *model in self.seatsArray) {
  658. if ([model.user.userId isEqualToString:userId]) {
  659. return model;
  660. break;
  661. }
  662. }
  663. return nil;
  664. }
  665. /// 获取主持人麦位model
  666. - (XYChatRoomSeatsModel *)getHostSeatModel {
  667. if (self.seatsArray.count > 0) {
  668. XYChatRoomSeatsModel *model = [self.seatsArray firstObject];
  669. return model;
  670. }
  671. return nil;
  672. }
  673. /// 根据菜单类型获取指定类型的model
  674. /// @param type 需要的类型
  675. - (XYChatRoomMenuItemModel *)getMenuModelWithMenuType:(XYChatRoomMenuType)type {
  676. for (NSArray *tempArray in self.menuItemModelArray) {
  677. for (XYChatRoomMenuItemModel *model in tempArray) {
  678. if (model.menuType == type) {
  679. return model;
  680. break;
  681. }
  682. }
  683. }
  684. return nil;
  685. }
  686. - (NSArray *)getLoveLeftSeatArray {
  687. NSMutableArray *tempArray = [NSMutableArray array];
  688. [tempArray addObject:self.seatsArray[1]];
  689. [tempArray addObject:self.seatsArray[2]];
  690. [tempArray addObject:self.seatsArray[5]];
  691. [tempArray addObject:self.seatsArray[6]];
  692. return tempArray;
  693. }
  694. - (NSArray *)getLoveRightSeatArray {
  695. NSMutableArray *tempArray = [NSMutableArray array];
  696. [tempArray addObject:self.seatsArray[3]];
  697. [tempArray addObject:self.seatsArray[4]];
  698. [tempArray addObject:self.seatsArray[7]];
  699. [tempArray addObject:self.seatsArray[8]];
  700. return tempArray;
  701. }
  702. /// 获取左右边心动值最大的麦位 -1则是没有人
  703. /// @param isLeft YES左边 NO右边
  704. - (NSInteger)getLoveHatSeatNoWithLeft:(BOOL)isLeft {
  705. NSInteger seatNo = -1;
  706. NSArray *tempArray = [NSArray array];
  707. if (isLeft) {
  708. tempArray = [self getLoveLeftSeatArray];
  709. }else {
  710. tempArray = [self getLoveRightSeatArray];
  711. }
  712. NSInteger max_number = 0;
  713. for (NSInteger i = 0; i<tempArray.count; i++) {
  714. XYChatRoomSeatsModel *model = tempArray[i];
  715. //取最大值和最大值的对应麦位
  716. NSInteger a = model.seatScore;
  717. if (a > max_number) {
  718. seatNo = model.seatNo;
  719. }
  720. max_number = a>max_number?a:max_number;
  721. }
  722. return seatNo;
  723. }
  724. - (int )getMicIndex:(NSString *)userId{
  725. for (XYChatRoomSeatsModel *seatInfo in self.seatsArray) {
  726. if ([userId isEqualToString:seatInfo.user.userId]) {
  727. return (int )seatInfo.seatNo;
  728. }
  729. }
  730. return -1;
  731. }
  732. //根据麦为获取用户id
  733. - (NSString *)getUserIdByMicIndex:(NSInteger)micIndex{
  734. XYChatRoomSeatsModel *seatInfo = self.seatsArray[micIndex];
  735. return seatInfo.user.userId;
  736. }
  737. - (NSMutableArray *)getLeftCacheUserArr:(NSString *)userIdStrs{
  738. for (XYPKProceedInfo *info in [XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserLeftCacheArrs) {
  739. if ([info.userId isEqualToString:userIdStrs]) {
  740. return info.dataArrs;
  741. }
  742. }
  743. return nil;
  744. }
  745. - (NSMutableArray *)getRightCacheUserArr:(NSString *)userIdStrs{
  746. for (XYPKProceedInfo *info in [XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserRightCacheArrs) {
  747. if ([info.userId isEqualToString:userIdStrs]) {
  748. return info.dataArrs;
  749. }
  750. }
  751. return nil;
  752. }
  753. ///获取用户信息并缓存
  754. //- (void)getUserInfo:(NSArray *)userIdArrs andUserStr:(NSString *)userStr result1:(void(^)(NSString *result1))result1{
  755. //
  756. // dispatch_group_t group = dispatch_group_create();
  757. // dispatch_queue_t queue = dispatch_queue_create("getuserinfo.main.data", DISPATCH_QUEUE_SERIAL);
  758. //
  759. // for (NSString *userId in userIdArrs) {
  760. // dispatch_group_enter(group);
  761. // dispatch_async(queue, ^{
  762. //
  763. // BOOL isHave = NO;
  764. // for (XYPKProceedInfo *info in [XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserLeftCacheArrs) {
  765. // if ([info.userId isEqualToString:userId]) {
  766. // isHave = YES;
  767. // dispatch_group_leave(group);
  768. // }
  769. // }
  770. //
  771. // if (!isHave) {
  772. // [[XYUserAPIManager new] getSimpleInfoWithUserIds:userId successHandler:^(ZYLResponseModel *responseModel) {
  773. // NSDictionary *dict = responseModel.data[@"map"];
  774. // NSDictionary *userDict = dict[userId];
  775. // XYPKProceedInfo *uerInfo = [[XYPKProceedInfo alloc] init];
  776. // [uerInfo yy_modelSetWithDictionary:userDict];
  777. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserLeftCacheArrs addObject:uerInfo];
  778. // dispatch_group_leave(group);
  779. //
  780. // } failureHandler:^(ZYLNetworkError *error) {
  781. // XYPKProceedInfo *uerInfo = [[XYPKProceedInfo alloc] init];
  782. // uerInfo.userId = @"0";
  783. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserLeftCacheArrs addObject:uerInfo];
  784. // dispatch_group_leave(group);
  785. // }];
  786. // }
  787. //
  788. // });
  789. // }
  790. //
  791. // dispatch_group_notify(group, queue, ^{
  792. // dispatch_async(dispatch_get_main_queue(), ^{
  793. // result1(userStr);
  794. // });
  795. // });
  796. //
  797. //}
  798. /// 解析获取用户完整信息
  799. /// @param dataDict 消息数据
  800. /// @param result 1左方 2右方
  801. - (void)parsePkRank:(NSDictionary *)dataDict result:(void (^)(int))result{
  802. // NSString *type = dataDict[@"msg"][@"type"];
  803. // pk左阵营主要贡献者
  804. // if ([type isEqualToString:LEFT_CAMP_VIP]) {
  805. // if ([dataDict[@"msg"][@"leftCampScore"] integerValue] > 0) {
  806. // NSString *userIdStr = dataDict[@"msg"][@"leftCampVip"];
  807. // userIdStr = [userIdStr stringByReplacingOccurrencesOfString:@"null" withString:@"0"];
  808. // NSArray *userIdArrs = [userIdStr componentsSeparatedByString:@","];
  809. // NSString *tempUserIdStr = [NSString stringWithFormat:@"%@",userIdStr];
  810. //
  811. // [self getUserInfo:userIdArrs andUserStr:userIdStr result1:^(NSString *result1) {
  812. //
  813. // if (![result1 isEqualToString:tempUserIdStr]) { return; }
  814. //
  815. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips removeAllObjects];
  816. // int index = 1;
  817. // for (NSString *userId in userIdArrs) {
  818. // for (XYPKProceedInfo *info in [XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserCacheArrs) {
  819. // if ([userId isEqualToString:info.userId]) {
  820. // XYPKProceedInfo *rankInfo = [[XYPKProceedInfo alloc] init];
  821. // rankInfo = info;
  822. // rankInfo.rankRole = 1;
  823. // rankInfo.rankIndex = index++;
  824. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips addObject:rankInfo];
  825. // break;
  826. // }
  827. // }
  828. // }
  829. // result(1);
  830. // }];
  831. NSDictionary *leftUserDicts = [BaseMethod objectWithJsonString:dataDict[@"msg"][@"leftCampVipUsers"]];
  832. if (leftUserDicts.allValues) {
  833. [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips removeAllObjects];
  834. NSMutableArray *arr = [[NSMutableArray alloc] init];
  835. for (NSDictionary *dict in leftUserDicts.allValues) {
  836. XYPKProceedInfo *info = [[XYPKProceedInfo alloc] init];
  837. [info yy_modelSetWithDictionary:dict];
  838. info.rankRole = 1;
  839. [arr addObject:info];
  840. }
  841. NSArray *sortedScoreArray = [arr sortedArrayUsingComparator:^NSComparisonResult(XYPKProceedInfo *obj1, XYPKProceedInfo *obj2) {
  842. if (obj1.rank < obj2.rank) {
  843. return NSOrderedAscending;
  844. }else {
  845. return NSOrderedDescending;
  846. }
  847. }];
  848. int index = 1;
  849. for (XYPKProceedInfo *info in sortedScoreArray) {
  850. info.rankIndex = index++;
  851. [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips addObject:info];
  852. }
  853. result(1);
  854. }
  855. // else{//没有头像url时接口获取
  856. // NSString *leftUserIdStr = dataDict[@"msg"][@"leftCampVip"];
  857. // leftUserIdStr = [leftUserIdStr stringByReplacingOccurrencesOfString:@"null" withString:@"0"];
  858. // //NSArray *userIds = [userIdStr componentsSeparatedByString:@","];
  859. // if (leftUserIdStr.length) {
  860. //
  861. // NSMutableArray *userIdArrs = [self getLeftCacheUserArr:leftUserIdStr];
  862. // if (userIdArrs.count) {
  863. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips removeAllObjects];
  864. // for (XYPKProceedInfo *info in userIdArrs) {
  865. // XYPKProceedInfo *newInfo = [[XYPKProceedInfo alloc] init];
  866. // newInfo = info;
  867. // newInfo.rankRole = 1;
  868. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips addObject:newInfo];
  869. // }
  870. // result(1);
  871. //
  872. // }else{
  873. // [[XYUserAPIManager new] getSimpleInfoWithUserIds:leftUserIdStr successHandler:^(ZYLResponseModel *responseModel) {
  874. // NSDictionary *dataDict = responseModel.data[@"map"];
  875. // XYPKProceedInfo *cache = [[XYPKProceedInfo alloc] init];
  876. // cache.userId = leftUserIdStr;
  877. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserLeftCacheArrs addObject:cache];
  878. //
  879. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips removeAllObjects];
  880. // int index = 1;
  881. // for (NSDictionary *dict in dataDict.allValues) {
  882. // XYPKProceedInfo *rankInfo = [[XYPKProceedInfo alloc] init];
  883. // [rankInfo yy_modelSetWithDictionary:dict];
  884. // rankInfo.rankRole = 1;
  885. // rankInfo.rankIndex = index++;
  886. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkLeftVips addObject:rankInfo];
  887. //
  888. // [cache.dataArrs addObject:rankInfo];
  889. // }
  890. // result(1);
  891. //
  892. // } failureHandler:^(ZYLNetworkError *error) {
  893. // }];
  894. // }
  895. // }
  896. //
  897. // }
  898. // pk右阵营主要贡献者
  899. // if ([type isEqualToString:RIGHT_CAMP_VIP]) {
  900. // if ([dataDict[@"msg"][@"rightCampScore"] integerValue] > 0) {
  901. // NSString *userIdStr = dataDict[@"msg"][@"rightCampVip"];
  902. // userIdStr = [userIdStr stringByReplacingOccurrencesOfString:@"null" withString:@"0"];
  903. // NSArray *userIdArrs = [userIdStr componentsSeparatedByString:@","];
  904. // NSString *tempUserIdStr = [NSString stringWithFormat:@"%@",userIdStr];
  905. //
  906. // [self getUserInfo:userIdArrs andUserStr:userIdStr result1:^(NSString *result1) {
  907. // if (![result1 isEqualToString:tempUserIdStr]) { return; }
  908. //
  909. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips removeAllObjects];
  910. // int index = 1;
  911. // for (NSString *userId in userIdArrs) {
  912. // for (XYPKProceedInfo *info in [XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserCacheArrs) {
  913. // if ([userId isEqualToString:info.userId]) {
  914. // XYPKProceedInfo *rankInfo = [[XYPKProceedInfo alloc] init];
  915. // rankInfo = info;
  916. // rankInfo.rankRole = 1;
  917. // rankInfo.rankIndex = index++;
  918. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips addObject:rankInfo];
  919. // break;
  920. // }
  921. // }
  922. // }
  923. // result(1);
  924. // }];
  925. NSDictionary *rightUserDicts = [BaseMethod objectWithJsonString:dataDict[@"msg"][@"rightCampVipUsers"]];
  926. if (rightUserDicts.allValues) {
  927. [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips removeAllObjects];
  928. NSMutableArray *arr = [[NSMutableArray alloc] init];
  929. for (NSDictionary *dict in rightUserDicts.allValues) {
  930. XYPKProceedInfo *info = [[XYPKProceedInfo alloc] init];
  931. [info yy_modelSetWithDictionary:dict];
  932. info.rankRole = 2;
  933. [arr addObject:info];
  934. }
  935. NSArray *sortedScoreArray = [arr sortedArrayUsingComparator:^NSComparisonResult(XYPKProceedInfo *obj1, XYPKProceedInfo *obj2) {
  936. if (obj1.rank < obj2.rank) {
  937. return NSOrderedAscending;
  938. }else {
  939. return NSOrderedDescending;
  940. }
  941. }];
  942. int index = 1;
  943. for (XYPKProceedInfo *info in sortedScoreArray) {
  944. info.rankIndex = index++;
  945. [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips addObject:info];
  946. }
  947. result(2);
  948. }
  949. // else{//没有头像url时接口获取
  950. // NSString *rightUserIdStr = dataDict[@"msg"][@"rightCampVip"];
  951. // rightUserIdStr = [rightUserIdStr stringByReplacingOccurrencesOfString:@"null" withString:@"0"];
  952. // if (rightUserIdStr.length) {
  953. // NSMutableArray *userIdArrs = [self getRightCacheUserArr:rightUserIdStr];
  954. // if (userIdArrs.count) {
  955. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips removeAllObjects];
  956. // for (XYPKProceedInfo *info in userIdArrs) {
  957. // XYPKProceedInfo *newInfo = [[XYPKProceedInfo alloc] init];
  958. // newInfo = info;
  959. // newInfo.rankRole = 2;
  960. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips addObject:newInfo];
  961. // }
  962. // result(2);
  963. //
  964. // }else{
  965. // [[XYUserAPIManager new] getSimpleInfoWithUserIds:rightUserIdStr successHandler:^(ZYLResponseModel *responseModel) {
  966. // NSDictionary *dataDict = responseModel.data[@"map"];
  967. // XYPKProceedInfo *cache = [[XYPKProceedInfo alloc] init];
  968. // cache.userId = rightUserIdStr;
  969. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkUserRightCacheArrs addObject:cache];
  970. //
  971. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips removeAllObjects];
  972. // int index = 1;
  973. // for (NSDictionary *dict in dataDict.allValues) {
  974. // XYPKProceedInfo *rankInfo = [[XYPKProceedInfo alloc] init];
  975. // [rankInfo yy_modelSetWithDictionary:dict];
  976. // rankInfo.rankRole = 2;
  977. // rankInfo.rankIndex = index++;
  978. // [[XYChatRoomManager sharedInstance].chatRoomController.infoManager.pkRightVips addObject:rankInfo];
  979. //
  980. // [cache.dataArrs addObject:rankInfo];
  981. // }
  982. // result(2);
  983. // } failureHandler:^(ZYLNetworkError *error) {
  984. // }];
  985. // }
  986. //
  987. // }
  988. // }
  989. }
  990. #pragma mark — Get
  991. - (NSMutableArray *)menuItemModelArray {
  992. if (!_menuItemModelArray) {
  993. _menuItemModelArray = [NSMutableArray array];
  994. }
  995. return _menuItemModelArray;
  996. }
  997. - (NSMutableArray *)seatUserArray {
  998. if (!_seatUserArray) {
  999. _seatUserArray = [NSMutableArray array];
  1000. }
  1001. return _seatUserArray;
  1002. }
  1003. - (NSMutableArray *)diamondRankArray {
  1004. if (!_diamondRankArray) {
  1005. _diamondRankArray = [NSMutableArray array];
  1006. }
  1007. return _diamondRankArray;
  1008. }
  1009. - (NSMutableArray <XYLiveRoomActivityInfo *>*)allActivityArrs {
  1010. if (!_allActivityArrs) {
  1011. _allActivityArrs = [NSMutableArray array];
  1012. }
  1013. return _allActivityArrs;
  1014. }
  1015. - (NSMutableArray <XYPKProceedInfo *>*)pkLeftVips {
  1016. if (!_pkLeftVips) {
  1017. _pkLeftVips = [NSMutableArray array];
  1018. }
  1019. return _pkLeftVips;
  1020. }
  1021. - (NSMutableArray <XYPKProceedInfo *>*)pkRightVips {
  1022. if (!_pkRightVips) {
  1023. _pkRightVips = [NSMutableArray array];
  1024. }
  1025. return _pkRightVips;
  1026. }
  1027. - (NSMutableArray <XYPKProceedInfo *>*)pkUserLeftCacheArrs {
  1028. if (!_pkUserLeftCacheArrs) {
  1029. _pkUserLeftCacheArrs = [NSMutableArray array];
  1030. }
  1031. return _pkUserLeftCacheArrs;
  1032. }
  1033. - (NSMutableArray <XYPKProceedInfo *>*)pkUserRightCacheArrs {
  1034. if (!_pkUserRightCacheArrs) {
  1035. _pkUserRightCacheArrs = [NSMutableArray array];
  1036. }
  1037. return _pkUserRightCacheArrs;
  1038. }
  1039. - (NSMutableArray <XYChatRoomAuctionRankItemModel *>*)auctionRankArray {
  1040. if (!_auctionRankArray) {
  1041. _auctionRankArray = [NSMutableArray array];
  1042. }
  1043. return _auctionRankArray;
  1044. }
  1045. @end
  1046. @implementation XYChatRoomBattleRoomInModel
  1047. @end
  1048. @implementation XYChatRoomKFBattleRoomInModel
  1049. @end
  1050. @implementation XYChatRoomAuctionInfoModel
  1051. @end