| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 |
- //
- // MOTtmEntiry.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/21.
- //
- #import "MORtmEntity.h"
- #import "MOWishStatusList.h"
- @implementation MORtmFanBean
- @end
- @implementation MORtmVipBean
- @end
- @implementation MORtmFamilyBean
- @end
- @implementation MORtmHeaddress
- @end
- @implementation MORtmDressing
- @end
- @implementation MORtmUser
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"vip":[MORtmVipBean class],
- @"fans":[MORtmFanBean class],
- @"family":[MORtmFamilyBean class],
- @"headdress":[MORtmHeaddress class],
- @"dressing":[MORtmDressing class]};
- }
- @end
- @implementation MORtmGiftRebate
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"user":[MORtmUser class]};
- }
- @end
- @implementation MORtmLiveRoomViewer
- @end
- @implementation MORedEnvelopeObject
- @end
- @implementation MORtmRoomResolution
- @end
- @implementation MORtmUserDialogItem
- @end
- @implementation MORtmUserDialog
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"iconItems":[MORtmUserDialogItem class]};
- }
- @end
- @implementation MORtmFlexActivityPiggy
- @end
- @implementation MORtmWishList
- @end
- @implementation MORTMLinkMic
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"user":[MORtmUser class]};
- }
- @end
- @implementation MORtmFansClub
- @end
- @implementation MORtmOpenVipNotice
- @end
- @implementation MORtmUserLevelUpgrade
- @end
- @implementation MORtmFastGive
- @end
- @implementation MORtmFollowGive
- @end
- @implementation MORtmRoomDesireDone
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"sender":[MORtmUser class]};
- }
- @end
- @implementation MORtmBlindboxGift
- @end
- @implementation MORtmBlindboxDrawResult
- + (NSDictionary *)modelContainerPropertyGenericClass {
- return @{@"list": [MORtmBlindboxGift class]};
- }
- @end
- @implementation MORtmGiftReturnForMultiple
- + (NSDictionary *)modelContainerPropertyGenericClass {
- return @{@"user":[MORtmUser class]};
- }
- @end
- @implementation MORtmTranslate
- @end
- @implementation MORtmJosnEntity
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"giftRebate":[MORtmGiftRebate class],
- @"l":[MORtmLiveRoomViewer class],
- @"linkMics":[MORTMLinkMic class],
- @"roomUser":[MORtmUser class],
- @"resolution":[MORtmRoomResolution class],
- @"activityPiggy":[MORtmFlexActivityPiggy class],
- @"fansClub":[MORtmFansClub class],
- @"openVipNotice":[MORtmOpenVipNotice class],
- @"rtmUserDialog":[MORtmUserDialog class],
- @"roomDesires":[MORoomDesire class],
- @"fastGive": [MORtmFastGive class],
- @"followGive": [MORtmFollowGive class],
- @"translateArr":[MORtmTranslate class],
- @"desireDone":[MORtmRoomDesireDone class],
- @"blindboxDrawResult":[MORtmBlindboxDrawResult class],
- @"dressing":[MORtmDressing class],
- @"pkLinkInvite":[MORtmLivePKLinkInvite class],
- @"pkV2Status":[MORtmPkV2Status class],
- @"pkV2StatusExpand":[MORtmPkV2StatusExpand class],
- @"returnForMultiple":[MORtmGiftReturnForMultiple class],
- @"rtmToast": [MORtmToast class],
- };
- }
- @end
- @implementation MORtmEntity
- + (NSDictionary *)modelContainerPropertyGenericClass {
- // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别
- return @{@"user":[MORtmUser class]};
- }
- - (id)copyWithZone:(NSZone *)zone {
- MORtmEntity *copy = [[MORtmEntity alloc] init];
- if (copy) {
- copy.type = self.type;
- copy.data = self.data;
- copy.roomId = self.roomId;
- }
- return copy;
- }
- + (MORtmEntity *)prepareRealObjectWith:(MORtmEntity *)entity{
- if(entity.type == MORtmChat ||
- entity.type == MORtmEnter ||
- entity.type == MORtmExit ||
- entity.type == RoomClose ||
- entity.type == MORtmLink ||
- entity.type == PeerPK ||
- entity.type == MORtmGift ||
- entity.type == SystemOrder ||
- entity.type == MOPKStatus ||
- entity.type == MORtmChatSilence ||
- entity.type == MORtmKick ||
- entity.type == MORtmChatManage ||
- entity.type == MORtmGiftEndNum ||
- entity.type == MORtmRoomTip ||
- entity.type == MORoomCleanRtmTip ||
- entity.type == MOLikeComboTip ||
- entity.type == SystemLiveUpdate ||
- entity.type == MOChangeRoomType ||
- entity.type == MORoomTipTwo ||
- entity.type == MORoomVoiceTranslate){
- MORtmJosnEntity *josnData = [MORtmJosnEntity modelWithJSON:entity.data];
- josnData.changeSettingInfo = [MOSettingInfo modelObjectWithDictionary:josnData.multipleChange];
- entity.data = josnData;
- return entity;
- }
- else if (entity.type == MOWishListTip){
- NSArray<MORtmWishList *> *wishListArr = [NSArray modelArrayWithClass:[MORtmWishList class] json:entity.data];
- entity.data = wishListArr;
- return entity;
- }
- else if (entity.type == MORtmMicApply ||
- entity.type == MORtmMicAuditPass ||
- entity.type == MORtmMicAuditRefuse){
- MORtmJosnEntity *josnData = [MORtmJosnEntity modelWithJSON:entity.data];
- entity.data = josnData;
- return entity;
- }
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmTextMessageWithType:(MORtmContentType )type AndText:(NSString *)text And:(BOOL)danMu AndRoomId:(NSString *)roomId{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.content = text ? text : @"";
- jsonEntity.danmu = danMu;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = type;
- entity.roomId = roomId ? roomId : @"";
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- //创建一条艾特的文本
- + (MORtmEntity *)prepareRtmTextMessageWithType:(MORtmContentType )type AndText:(NSString *)text And:(BOOL)danMu AndRoomId:(NSString *)roomId AndAtDict:(NSDictionary *)dict{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.content = text ? text : @"";
- jsonEntity.danmu = danMu;
-
- if(dict){
- NSArray *allkeyArr = [dict allKeys];
-
- if(allkeyArr.count > 0){
- NSMutableArray *userIdArr = [NSMutableArray array];
- for (NSString *key in allkeyArr) {
- [userIdArr addObject:dict[key]];
- }
-
- if(userIdArr.count == allkeyArr.count){
- NSString *atlist = [userIdArr componentsJoinedByString:@","];
- NSString *atNameList = [allkeyArr componentsJoinedByString:@","];
-
- jsonEntity.atList = atlist;
- jsonEntity.atNameList = atNameList;
- }
- }
- }
-
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = type;
- entity.roomId = roomId ? roomId : @"";
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmUser *)prepareBaseUser{
- MORtmUser *userInfo = [MORtmUser new];
- userInfo.userId = GetUserId ? GetUserId : @"";
- userInfo.username = GetNickName ? GetNickName : @"";
- userInfo.avatar = GetAvatar ? GetAvatar : @"";
- userInfo.agoraId = GetAgoraId ? GetAgoraId : 0;
- userInfo.bubble = GetUserBubbleCode ? GetUserBubbleCode : 0;
- userInfo.headress = @"";//使用了新字段headRes
- userInfo.level = GetUserLevel ? GetUserLevel : 1;
- userInfo.rides = GetUserEnterBar ? GetUserEnterBar : 0;
-
- MORtmDressing *dressing = [MORtmDressing new];
- dressing.bubble = GetUserBubbleCode ? GetUserBubbleCode : 0;
- dressing.entryBar = GetUserEnterBar ? GetUserEnterBar : 0;
- dressing.cardFrame = GetUserCardFrameCode ? GetUserCardFrameCode : 0;
- dressing.enterFloating = GetUserEnterFloatingCode ? GetUserEnterFloatingCode : 0;
- dressing.rewardBanner = GetUserRewardBannerCode ? GetUserRewardBannerCode : 0;
- dressing.linkMicFrame = GetUserLinkMicFrameCode ? GetUserLinkMicFrameCode : 0;
- dressing.liveBarrage = GetUserLiveBarrageCode ? GetUserLiveBarrageCode : 0;
-
- BOOL isMysterious = GetIsMysterious;
- if(isMysterious){
- //神秘人
- userInfo.username = @"Mystery Man";
- userInfo.bubble = 0;
- userInfo.headress = @"";//使用了新字段headRes
- userInfo.level = 1;
- userInfo.rides = 0;
-
- dressing.bubble = 0;
- dressing.entryBar = 0;
- dressing.cardFrame = 0;
- dressing.enterFloating = 0;
- dressing.rewardBanner = 0;
- dressing.linkMicFrame = 0;
- dressing.liveBarrage = 0;
-
- if([MOSvgaSourceManage shareManager].theManAvatarUrl.length > 0){
- userInfo.avatar = [MOSvgaSourceManage shareManager].theManAvatarUrl;
- }
- else{
- userInfo.avatar = @"";
- }
- }
-
- userInfo.dressing = dressing;//装饰类赋值
-
- //vip
- MORtmVipBean *vipInfo = [MORtmVipBean new];
- NSInteger vipType = GetUserVipType ? GetUserVipType : 0;
- if(vipType != 0){
- NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000;
- NSInteger vipExpirTime = GetUserVipExpirTime ? GetUserVipExpirTime : 0;
-
- if(currentTime > vipExpirTime){
- vipType = 0;
- }
-
- vipInfo.type = vipType;
- if(isMysterious){
- vipInfo.type = 0;
- }
-
- userInfo.vip = vipInfo;
- }
-
- //粉丝团
- MORtmFanBean *fanInfo = [MORtmFanBean new];
- MOFanClubData *fanClubData = [MOSvgaSourceManage shareManager].myDataInfo.fanClubData;
- if(fanClubData.id.length > 0){
- fanInfo.level = fanClubData.level;
- fanInfo.name = fanClubData.nameplate;
- if(isMysterious){
- fanInfo.level = 0;
- fanInfo.name = @"";
- }
- userInfo.fans = fanInfo;
- }
-
- //勋章Code数组
- NSArray *medalArr = [MOSvgaSourceManage shareManager].myDataInfo.userProfile.medalList;
- if(medalArr.count > 0){
- NSMutableArray *medalMuArr = [NSMutableArray array];
- for (MOMedalResources *object in medalArr) {
- NSInteger codeNum = (NSInteger)object.code;
- [medalMuArr addObject:@(codeNum)];
- }
- if(isMysterious){
- userInfo.medalCodeList = [NSMutableArray array];
- }
- else{
- userInfo.medalCodeList = [medalMuArr copy];
- }
-
- }
-
- //MORtmHeaddress 头像对象
- MORtmHeaddress *headdress = [MORtmHeaddress new];
- headdress.type = GetUserHeaddressType ? GetUserHeaddressType : 0;
- headdress.res = GetUserHeaddress ? GetUserHeaddress : @"";
- if(isMysterious){
- headdress.type = 0;
- headdress.res = @"";
- }
-
- userInfo.headressObject = headdress;
-
- return userInfo;
- }
- + (MORtmEntity *)prepareRtmApplyLianMaiMessageWithType:(MORtmContentType )type AndLinkMicType:(NSInteger)linkMicType AndRoomId:(NSString *)roomId{
-
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断)
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = linkMicType ? linkMicType : 1;
- jsonEntity.status = 0;
- jsonEntity.roomId = roomId ? roomId : @"";
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmLink;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmManageLianMaiMessageWithType:(MORtmContentType )type AndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndAgoraId:(NSInteger)agoraId AndRoomId:(NSString *)roomId {
-
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断)
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = linkMicType ? linkMicType : 1;
- jsonEntity.status = status;
- jsonEntity.agoraId = agoraId;
- jsonEntity.roomId = roomId ? roomId : @"";
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = type;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmManageAgreeLianMaiMessageAndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndAgoraId:(NSInteger)agoraId AndUserId:(NSString *)userId AndUserName:(NSString *)userName AndAvatar:(NSString *)avatar AndRoomId:(NSString *)roomId AndVipType:(NSInteger)vipType{
-
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断)
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = linkMicType ? linkMicType : 1;
- jsonEntity.status = status;
- jsonEntity.agoraId = agoraId;
- jsonEntity.userId = userId ? userId : @"";
- jsonEntity.userName = userName ? userName : @"";
- jsonEntity.avatar = avatar ? avatar : @"";
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.vipType = vipType ? vipType : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmLink;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmManageAgreeLianMaiMessageAndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndRoomId:(NSString *)roomId AndMOLinkMic:(MOLinkMic *)linkMic AndSeatNum:(NSInteger)seatNum{
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断) 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意
- //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = linkMicType ? linkMicType : 1;
- jsonEntity.status = status;
- jsonEntity.agoraId = linkMic.profile.agoraId ? linkMic.profile.agoraId : 0;
- jsonEntity.userId = linkMic.profile.id ? linkMic.profile.id : @"";
- jsonEntity.userName = linkMic.profile.nickname ? linkMic.profile.nickname : @"";
- jsonEntity.avatar = linkMic.profile.avatar ? linkMic.profile.avatar : @"";
- jsonEntity.vipType = linkMic.profile.vipType ? linkMic.profile.vipType : 0;
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.seatNum = seatNum ? seatNum : 0;
- jsonEntity.video1 = linkMic.video1;
- jsonEntity.video2 = linkMic.video2;
- jsonEntity.audio1 = linkMic.audio1;
- jsonEntity.audio2 = linkMic.audio2;
- jsonEntity.admin = linkMic.admin;
-
-
- NSDictionary *dressing = [linkMic.dressing modelToJSONObject];
- jsonEntity.dressing = [MORtmDressing modelWithJSON:dressing];
-
- if(status == 6){
- jsonEntity.invite = linkMic.invite ? linkMic.invite : @"";
- jsonEntity.camera = linkMic.camera;
- }
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmLink;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmActiveLianMaiMessageWithType:(MORtmContentType)type AndLinkMicType:(NSInteger)linkMicType AndRoomId:(NSString *)roomId{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = linkMicType ? linkMicType : 1;
- jsonEntity.roomId = roomId ? roomId : @"";
-
- NSInteger agoraId = GetAgoraId;
- jsonEntity.agoraId = agoraId ? agoraId : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = type;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmPeerPkMessageWithStatus:(NSInteger)status PkSecretStr:(NSString *)pkSecretStr AndRoomId:(NSString *)roomId{
-
- //状态, 0:待处理 1:取消 2:同意 3:拒绝 4:投降或退出
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.status = status;
- jsonEntity.pkSecret = pkSecretStr;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = PeerPK;
- entity.roomId = roomId ? roomId : @"";
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmPeerPkQuitMessageWith:(BOOL)isSurrender AndRoomId:(NSString *)roomId{
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = PeerPKQuit;
- entity.data = @(isSurrender);
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
- entity.roomId = roomId ? roomId : @"";
-
- return entity;
- }
- //根据消息类型枚举 创建一条对应Rtm消息
- + (MORtmEntity *)prepareRtmMessageWithType:(MORtmContentType )type AndRoomId:(NSString *)roomId{
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = type;
- entity.data = nil;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
- entity.roomId = roomId ? roomId : @"";
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmMessageWithEnterWith:(MOLiveDetail *)liveDetail{
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmEnter;
- entity.roomId = liveDetail.currentRoom.id ? liveDetail.currentRoom.id : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- userInfo.enterBarPlayType = liveDetail.enterBarPlayType ? liveDetail.enterBarPlayType : 0;
- userInfo.enterFloatingSkinType = liveDetail.enterFloatingSkinType ? liveDetail.enterFloatingSkinType : 0;
- userInfo.enterFloatingAvatar = liveDetail.enterFloatingAvatar;
- entity.user = userInfo;
-
- return entity;
- }
- //准备一条 礼物 Rtm
- + (MORtmEntity *)prepareRtmGiftMessageWithCode:(NSInteger)code NameStr:(NSString *)nameStr Count:(NSInteger)count AndRoomId:(NSString *)roomId{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.code = code ? code : 1;
- jsonEntity.name = nameStr;
- jsonEntity.count = count ? count : 1;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmGift;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- //准备一条 礼物 Rtm
- + (MORtmEntity *)prepareRtmGiftMessageWith:(MOGiftInfo *)giftInfo AndRoomId:(NSString *)roomId{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.code = giftInfo.giftCode ? giftInfo.giftCode : 1;
- jsonEntity.name = giftInfo.giftName;
- jsonEntity.count = giftInfo.num ? giftInfo.num : 1;
- jsonEntity.rebateMultiple = giftInfo.rebateMultiple ? giftInfo.rebateMultiple : 0;
- jsonEntity.rebateDiamond = giftInfo.rebateDiamond ? giftInfo.rebateDiamond : 0;
- jsonEntity.multipleUserList = (giftInfo.multipleUserList.count > 0) ? ([giftInfo.multipleUserList copy]) : nil;
- jsonEntity.priceDiamond = giftInfo.diamond ? giftInfo.diamond : 0;
- jsonEntity.hitDiamond = giftInfo.hitDiamond ? giftInfo.hitDiamond : 0;
- jsonEntity.antiDrillCritGift = giftInfo.antiDrillCritGift;
-
- if(giftInfo.selectSkin.id.length > 0){
- jsonEntity.code = giftInfo.selectSkin.code ? giftInfo.selectSkin.code : 1;
- jsonEntity.name = giftInfo.selectSkin.name ? giftInfo.selectSkin.name : @"";
- }
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmGift;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- //准备一条 礼物数量 Rtm
- + (MORtmEntity *)prepareRtmGiftEndNumMessageWith:(MOGiftInfo *)giftInfo AndRoomId:(NSString *)roomId{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.code = giftInfo.giftCode ? giftInfo.giftCode : 1;
- jsonEntity.name = giftInfo.giftName;
- jsonEntity.count = giftInfo.num ? giftInfo.num : 1;
- jsonEntity.rebateMultiple = giftInfo.rebateMultiple ? giftInfo.rebateMultiple : 0;
- jsonEntity.rebateDiamond = giftInfo.rebateDiamond ? giftInfo.rebateDiamond : 0;
-
- jsonEntity.multipleUserList = (giftInfo.multipleUserList.count > 0) ? ([giftInfo.multipleUserList copy]) : nil;
- jsonEntity.effectType = giftInfo.effectType ? giftInfo.effectType : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmGiftEndNum;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- /// 准备一条PK 房间状态信息
- /// - Parameters:
- /// - pkModel: PK状态对象
- /// - status: PK状态 0:就绪 1:PK中 2:惩罚 3:结束
- /// - quitStatus: 中途结束信息 1:对方退出 2:对方投降 3:我方退出 4:我方投降, 5:正常结束 0:单纯状态信息更新
- + (MORtmEntity *)prepareRtmAboutPkStatusWith:(MOLiveList *)pkModel AndStatus:(NSInteger)status AndQuitStatus:(NSInteger)quitStatus AndRoomId:(NSString *)roomId{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.status = status ? status : 0;
- jsonEntity.selfScore = pkModel.weScore ? pkModel.weScore : 0;
- jsonEntity.oppScore = pkModel.oppScore ? pkModel.oppScore : 0;
- jsonEntity.quitInfo = quitStatus ? quitStatus : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MOPKStatus;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)preparePkRtmWith:(MOLinePKViewModel *)pkViewModel AndStatus:(NSInteger)status AndQuitStatus:(NSInteger)quitStatus AndRoomId:(NSString *)roomId{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.status = status ? status : 0;
- jsonEntity.selfScore = pkViewModel.curOwnerCampInfo.pkValue ?: 0;
- jsonEntity.oppScore = pkViewModel.curPeerCampInfo.pkValue ?: 0;
- jsonEntity.quitInfo = quitStatus ? quitStatus : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MOPKStatus;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmAboutKickSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.userId = userId;
- jsonEntity.roomId = roomId;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmKick;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmAboutSilenceSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId And:(BOOL)isSilence{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.userId = userId;
- jsonEntity.roomId = roomId;
- jsonEntity.silence = isSilence;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmChatSilence;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- /// 准备一条管理员信息
- /// - Parameters:
- /// - userId: 用户ID
- /// - roomId: 房间ID
- + (MORtmEntity *)prepareRtmAboutManageSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId And:(BOOL)isManager{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.userId = userId;
- jsonEntity.roomId = roomId;
- jsonEntity.manager = isManager;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmChatManage;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- /// 准备一条提示信息
- /// - Parameters:
- /// - roomId: 房间ID
- /// - type: // 1: 关注 2: PK 3:禁言
- /// - status: // 1: 关注 (1关注 0取关) 2: PK(0:失败 1: 胜利 2: 自己投降3:对方投降) 3:(0解除禁言 1禁言)
- /// - content: //提示内容, 有些类型需要 (非必传)
- + (MORtmEntity *)prePareRtmAboutRoomTipWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndStatus:(NSInteger)status AndTipContent:(NSString *)content AndUserName:(NSString *)userName{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.type = type ? type : 0;
- jsonEntity.status = status ? status : 0;
- jsonEntity.tipContent = content ? content : @"";
- jsonEntity.userName = userName ? userName : @"";
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmRoomTip;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- //PK 兼容安卓
- if(userName.length == 0){
- jsonEntity.userName = entity.user.username;
- }
-
- return entity;
- }
- // 准备一条 房间挂起的Rtm
- + (MORtmEntity *)prePareRtmAboutRoomTipWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndStatus:(NSInteger)status AndTipContent:(NSString *)content AndUserName:(NSString *)userName AndSuspend:(double)suspend{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.type = type ? type : 0;
- jsonEntity.status = status ? status : 0;
- jsonEntity.tipContent = content ? content : @"";
- jsonEntity.userName = userName ? userName : @"";
- jsonEntity.suspendExpire = suspend;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORtmRoomTip;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prePareRtmAboutLikeComboWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndLikeNum:(NSInteger)likeNum{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.type = type ? type : 0;
- jsonEntity.likeCombo = likeNum ? likeNum : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MOLikeComboTip;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prePareRtmAboutWishListWithRoomId:(NSString *)roomId AndWishList:(NSArray *)wishList{
-
- NSMutableArray *needWishArr = [NSMutableArray array];
- for (MOWishStatusList *object in wishList) {
- MORtmWishList *tipObject = [[MORtmWishList alloc] init];
- tipObject.giftCode = object.giftCode;
- tipObject.complete = (NSInteger)object.complete;
- tipObject.num = (NSInteger)object.num;
- tipObject.done = object.done;
- [needWishArr addObject:tipObject];
- }
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MOWishListTip;
- entity.data = needWishArr;
- entity.roomId = roomId ? roomId : @"";
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- /// 准备一条语言翻译的Rtm
- /// - Parameters:
- /// - roomId: 房间ID
- /// - wishList: 接口数组
- + (MORtmEntity *)prePareRtmAboutTranslateArrWithRoomId:(NSString *)roomId AndTranslateArr:(NSArray *)translateArr{
-
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.translateArr = translateArr;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MORoomVoiceTranslate;
- entity.data = jsonEntity;
- entity.roomId = roomId ? roomId : @"";
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (MORtmEntity *)prepareRtmAboutGetRedTipWithSendUserName:(NSString *)sendUserName RedId:(NSString *)redEId{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.redSendName = sendUserName;
- jsonEntity.redEId = redEId;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = SystemTipGetRed;
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- /// 准备一条房间转换Rtm
- + (MORtmEntity *)prepareRtmAboutChangeRoomTypeWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndPlanConvertTime:(double)planConvertTime AndDiamond:(double)diamond{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = type;
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.planConvertTime = planConvertTime;
- jsonEntity.diamond = diamond;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.type = MOChangeRoomType;
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
-
- return entity;
- }
- + (NSString *)insertString:(NSString *)insertText intoString:(NSString *)original {
- if (original.length == 0) return insertText;
- NSRange atRange = [original rangeOfString:@"@"];
- NSMutableString *result = [NSMutableString stringWithString:original];
-
- if (atRange.location != NSNotFound) {// @ 存在,插入到它后面
- [result insertString:insertText atIndex:(atRange.location + 1)];
- } else {// @ 不存在,插入到开头
- [result insertString:[NSString stringWithFormat:@"@%@", insertText] atIndex:0];
- }
-
- return [result copy];
- }
- /// 打招呼需求本地构造一条被房主艾特的消息
- + (MORtmEntity *)prepareLocalChatMessage:(MOUserBase *)userModel content:(NSString *)content {
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- NSString *contentResult = [self insertString:GetNickName intoString:content];
- jsonEntity.content = contentResult;
- jsonEntity.danmu = NO;
- jsonEntity.atList = GetUserId;
- jsonEntity.atNameList = GetNickName;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity createSender:userModel];
- entity.user = userInfo;
- entity.type = MORtmChat;
-
-
- return entity;
- }
- /// 准备一条通用提示消息RoomTipTwo
- + (MORtmEntity *)prepareRoomTipTwoMessage:(NSInteger)type AndUserName:(NSString *)userName AndRoomId:(NSString *)roomId AndTipNormalNum:(NSInteger)tipNormalNum{
- MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new];
- jsonEntity.type = type;
- jsonEntity.userName = userName ? userName : @"";
- jsonEntity.roomId = roomId ? roomId : @"";
- jsonEntity.tipNormalNum = tipNormalNum ? tipNormalNum : 0;
-
- MORtmEntity *entity = [MORtmEntity new];
- entity.data = jsonEntity;
-
- MORtmUser *userInfo = [MORtmEntity prepareBaseUser];
- entity.user = userInfo;
- entity.type = MORoomTipTwo;
-
- return entity;
- }
- /// 自己构造发送人的信息
- + (MORtmUser *)createSender:(MOUserBase *)userModel {
- MORtmUser *userInfo = [MORtmUser new];
- userInfo.userId = userModel.userProfile.id;
- userInfo.username = userModel.userProfile.nickname;
- userInfo.avatar = userModel.userProfile.avatar;
- userInfo.agoraId = userModel.userProfile.agoraId;
- userInfo.bubble = userModel.userProfile.adornment.bubbleCode;
- userInfo.headress = @"";//使用了新字段headRes
- userInfo.level = userModel.level;
- userInfo.rides = 0;
-
- //vip
- MORtmVipBean *vipInfo = [MORtmVipBean new];
- vipInfo.type = userModel.vipType;
- userInfo.vip = vipInfo;
-
- //粉丝团
- MORtmFanBean *fanInfo = [MORtmFanBean new];
- MOUserAnchorClub *fanClubData = userModel.userAnchorClub;
- if(fanClubData.id.length > 0){
- fanInfo.level = fanClubData.level;
- fanInfo.name = fanClubData.nameplate;
- userInfo.fans = fanInfo;
- }
- //勋章Code数组
- NSArray *medalArr = [userModel.userProfile.medalList valueForKey:@"code"];
- if(medalArr.count > 0){
- userInfo.medalCodeList = medalArr;
- }
-
- //MORtmHeaddress 头像对象
- MORtmHeaddress *headdress = [MORtmHeaddress new];
- headdress.type = userModel.userProfile.adornment.headgearType;
- headdress.res = userModel.userProfile.adornment.headgearRes;
- userInfo.headressObject = headdress;
-
- return userInfo;
- }
- #pragma mark - ChangeObject
- + (MOUserProfile *)toCreateUserProfileWith:(MORtmUser *)user{
- MOUserProfile *result = [[MOUserProfile alloc] init];
-
- if(user){
- result.id = user.id;
- if(result.id.length == 0){
- result.id = user.userId;
- }
-
- result.nickname = user.nickname;
- if(result.nickname.length == 0){
- result.nickname = user.username;
- }
-
- result.agoraId = user.agoraId;
- result.avatar = user.avatar;
-
- MOAdornment *adorment = [[MOAdornment alloc] init];
- adorment.enterBar = user.rides;
- adorment.headgearType = user.headdress.type;
- adorment.headgearRes = user.headdress.res;
- result.adornment = adorment;
-
- MOHeaddress *headdress = [[MOHeaddress alloc] init];
- headdress.headgearType = user.headdress.type;
- headdress.headgearRes = user.headdress.res;
- result.headdress = headdress;
-
- result.vipType = user.vip.type;
-
- MODressing *dressing = [MORtmEntity toCreateUserProfileDressingWith:user];
- result.dressing = dressing;
- }
- return result;
- }
- + (MODressing *)toCreateUserProfileDressingWith:(MORtmUser *)user{
- MODressing *dressing = [[MODressing alloc] init];
- dressing.rewardBanner = user.dressing.rewardBanner;
- dressing.bubble = user.dressing.bubble;
- dressing.enterFloating = user.dressing.enterFloating;
- dressing.linkMicFrame = user.dressing.linkMicFrame;
- dressing.entryBar = user.dressing.entryBar;
- dressing.cardFrame = user.dressing.cardFrame;
- dressing.liveBarrage = user.dressing.liveBarrage;
- return dressing;
- }
- + (MOLinkMic *)toCreateLinkMicObjectWith:(MORTMLinkMic *)inObject{
- MOLinkMic *result = [[MOLinkMic alloc] init];
- result.profile = [MORtmEntity toCreateUserProfileWith:inObject.user];
- result.lock = inObject.lock;
- result.video1 = inObject.video1;
- result.video2 = inObject.video2;
- result.audio1 = inObject.audio1;
- result.audio2 = inObject.audio2;
- result.admin = inObject.admin;
- result.goldenBean = inObject.goldenBean;
-
- NSDictionary *dressing = [inObject.user.dressing modelToJSONObject];
- result.dressing = [MODressing modelWithJSON:dressing];
-
- return result;
- }
- + (MOLinkMic *)toCreateLinkMicObjectWithEntity:(MORtmEntity *)entity{
- MORtmJosnEntity *jsonEntity = (MORtmJosnEntity *)entity.data;
-
- MOUserProfile *userProfile = [MOUserProfile new];
- userProfile.id = jsonEntity.userId;
- userProfile.avatar = jsonEntity.avatar;
- userProfile.agoraId = jsonEntity.agoraId;
- userProfile.nickname = jsonEntity.userName;
-
- MOLinkMic *linkMic = [MOLinkMic new];
- linkMic.video = (jsonEntity.type == 1) ? YES : NO;
- linkMic.profile = userProfile;
- linkMic.video1 = jsonEntity.video1;
- linkMic.video2 = jsonEntity.video2;
- linkMic.audio1 = jsonEntity.audio1;
- linkMic.audio2 = jsonEntity.audio2;
- linkMic.admin = jsonEntity.admin;
-
- return linkMic;
- }
- @end
|