红包逻辑

This commit is contained in:
liyuhua
2023-10-25 19:26:20 +08:00
parent cf17b5e30c
commit 6754f38c52
28 changed files with 636 additions and 194 deletions

View File

@@ -597,37 +597,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
if (broadcastMessage.content) {
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) {
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
//
__block BOOL isInRoom;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
XPRoomViewController<RoomHostDelegate> * roomVC = obj;
RoomInfoModel *roomInfo = [roomVC getRoomInfo];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
if (roomInfo.uid == data.roomUid.integerValue) {
view.inAllPacketRoom = YES;
} else {
view.inAllPacketRoom = NO;
}
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[roomVC.view addSubview:view];
[roomVC.view bringSubviewToFront:view];
*stop = YES;
isInRoom = YES;
}
}];
if (!isInRoom) {
UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
view.inAllPacketRoom = NO;
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[currentVc.view addSubview:view];
[currentVc.view bringSubviewToFront:view];
}
if (attachment.first == CustomMessageType_RedPacket) {
[self receiveRedPacketDealWithData:attachment];
} else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广
[self receiveBroadcastGift:attachment];
}else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){
@@ -664,7 +635,44 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
}
}
///
-(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
if(attachment.second == Custom_Message_Sub_AllDiamandRedPacket ){
data.validityType = 0;
data.kind = 1;
}
//
__block BOOL isInRoom;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
XPRoomViewController<RoomHostDelegate> * roomVC = obj;
RoomInfoModel *roomInfo = [roomVC getRoomInfo];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
if (roomInfo.uid == data.roomUid.integerValue) {
view.inAllPacketRoom = YES;
} else {
view.inAllPacketRoom = NO;
}
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[roomVC.view addSubview:view];
[roomVC.view bringSubviewToFront:view];
*stop = YES;
isInRoom = YES;
}
}];
if (!isInRoom) {
UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
view.inAllPacketRoom = NO;
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[currentVc.view addSubview:view];
[currentVc.view bringSubviewToFront:view];
}
}
///
-(BOOL)isInRoomWithData{
//