Commit 6e5f19b4 by suolong

添加购票的api

parent a0eb657f
...@@ -116,6 +116,22 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -116,6 +116,22 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
#pragma mark - /ticketshow/user/buy(观众端购票)
/// Ticket Show - 功能 - 观众端购票返回
@interface FUSTicketShowUserBuyResultModel : FUSBaseModel
/// 响应码(接口返回)
@property (nonatomic, assign) NSInteger code;
/// 响应描述
@property (nonatomic, copy) NSString *msg;
/// 账户变更信息(字段结构由服务端定义,常用于 diamond 等余额变更)
@property (nonatomic, strong, nullable) NSDictionary *cv;
@end
#pragma mark - /ticketshow/rank/list(票的贡献榜) #pragma mark - /ticketshow/rank/list(票的贡献榜)
/// Ticket Show - 视图 - 票的贡献榜列表返回 /// Ticket Show - 视图 - 票的贡献榜列表返回
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
@end @end
@implementation FUSTicketShowUserBuyResultModel
@end
@implementation FUSTicketShowRankListResultModel @implementation FUSTicketShowRankListResultModel
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass { + (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass {
......
...@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@class FUSTicketShowCollectTicketToggleResultModel; @class FUSTicketShowCollectTicketToggleResultModel;
@class FUSTicketShowRankListResultModel; @class FUSTicketShowRankListResultModel;
@class FUSTicketShowUserBuyResultModel;
@class FUSBarrageCardModel; @class FUSBarrageCardModel;
...@@ -971,6 +972,21 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -971,6 +972,21 @@ NS_ASSUME_NONNULL_BEGIN
succeed:(void (^)(FUSTicketShowCollectTicketToggleResultModel *model))succeed succeed:(void (^)(FUSTicketShowCollectTicketToggleResultModel *model))succeed
failure:(void (^)(NSString *msg, NSInteger code))failure; failure:(void (^)(NSString *msg, NSInteger code))failure;
/// Ticket Show - 功能 - 观众端购买票
/// 接口:POST /ticketshow/user/buy
/// @param roomId 房间ID
/// @param channelId 频道ID
/// @param roundId 回合ID
/// @param num 购买数量
/// @param succeed 成功回调
/// @param failure 失败回调(参数错误 code=-3)
+ (void)fus_ticketShowUserBuyWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
num:(NSInteger)num
succeed:(void (^)(FUSTicketShowUserBuyResultModel *model))succeed
failure:(void (^)(NSString *msg, NSInteger code))failure;
/// Ticket Show - 视图 - 获取票的贡献列表(观众端) /// Ticket Show - 视图 - 获取票的贡献列表(观众端)
/// 接口:POST /ticketshow/rank/list /// 接口:POST /ticketshow/rank/list
/// 说明:用于展示“票的贡献”列表(弹窗内贡献 Tab) /// 说明:用于展示“票的贡献”列表(弹窗内贡献 Tab)
......
...@@ -3152,6 +3152,38 @@ ...@@ -3152,6 +3152,38 @@
}]; }];
} }
+ (void)fus_ticketShowUserBuyWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
num:(NSInteger)num
succeed:(void (^)(FUSTicketShowUserBuyResultModel * _Nonnull))succeed
failure:(void (^)(NSString * _Nonnull, NSInteger))failure {
NSString *uid = FUSCacheDataShare.shareStore.userDetailInfo.uid;
if ([NSString isNull:uid]
|| [NSString isNull:roomId]
|| [NSString isNull:channelId]
|| [NSString isNull:roundId]
|| num <= 0) {
if (failure) failure([NSString fus_localString:@"参数错误"], -3);
return;
}
NSDictionary *params = @{
@"uid": uid,
@"roomId": roomId,
@"channelId": channelId,
@"roundId": roundId,
@"num": @(num)
};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_TicketShow_User_Buy params:params success:^(NSDictionary * _Nullable dataDict, int code) {
FUSTicketShowUserBuyResultModel *model = [FUSTicketShowUserBuyResultModel fus_modelWithDict:dataDict];
if (succeed) succeed(model);
} failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) failure(dataDict[@"msg"], code);
}];
}
+ (void)fus_ticketShowRankListWithRoomId:(NSString *)roomId + (void)fus_ticketShowRankListWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId channelId:(NSString *)channelId
roundId:(NSString *)roundId roundId:(NSString *)roundId
......
...@@ -122,10 +122,6 @@ ...@@ -122,10 +122,6 @@
/// 先用本地缓存数据做首屏展示,避免弹窗出现短暂空白;网络返回后再刷新为最新值 /// 先用本地缓存数据做首屏展示,避免弹窗出现短暂空白;网络返回后再刷新为最新值
[popView fus_updateRemainingTicketCount:remaining mvpNeedTicketCount:self.showTimeMvpNeedTicketCount buyPrice:-1]; [popView fus_updateRemainingTicketCount:remaining mvpNeedTicketCount:self.showTimeMvpNeedTicketCount buyPrice:-1];
popView.confirmHandler = ^(FUSLiveShowTimeTicketPurchaseOption option) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"购票接口未接入"]];
};
FUSRoomInfoModel *roomInfoModel = FUSLiveHelper.shareInstance.roomInfoModel; FUSRoomInfoModel *roomInfoModel = FUSLiveHelper.shareInstance.roomInfoModel;
NSString *roomId = roomInfoModel.roomId; NSString *roomId = roomInfoModel.roomId;
NSString *channelId = roomInfoModel.channelId; NSString *channelId = roomInfoModel.channelId;
...@@ -136,6 +132,38 @@ ...@@ -136,6 +132,38 @@
} }
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
__weak typeof(popView) weakPopView = popView;
popView.confirmHandler = ^(FUSLiveShowTimeTicketPurchaseOption option) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
FUSLiveShowTimeTicketActionPopView *strongPopView = weakPopView;
NSInteger buyNum = (strongPopView ? [strongPopView fus_purchaseTicketCountForOption:option] : -1);
if (buyNum <= 0) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"当前购票数据未就绪"]];
return;
}
[FUSLoadingView fus_showProgressViewWithMessage:@""];
[FUSLiveHttpHelper fus_ticketShowUserBuyWithRoomId:roomId channelId:channelId roundId:roundId num:buyNum succeed:^(FUSTicketShowUserBuyResultModel * _Nonnull model) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
NSDictionary *cv = model.cv;
NSString *diamond = [NSString stringWithObject:cv[@"diamond"]];
if (![NSString isNull:diamond]) {
FUSCacheDataShare.shareStore.userDetailInfo.diamond = diamond;
}
});
} failure:^(NSString * _Nonnull msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
[FUSDialogView fus_showDialog:([NSString isNull:msg] ? [NSString fus_localString:@"购票失败"] : msg)];
});
}];
};
[FUSLiveHttpHelper fus_ticketShowBuyGetDataWithRoomId:roomId channelId:channelId roundId:roundId succeed:^(FUSTicketShowCollectTicketToggleResultModel * _Nonnull model) { [FUSLiveHttpHelper fus_ticketShowBuyGetDataWithRoomId:roomId channelId:channelId roundId:roundId succeed:^(FUSTicketShowCollectTicketToggleResultModel * _Nonnull model) {
/// UI 更新必须回主线程;同时兼容弹窗可能已被用户关闭的场景 /// UI 更新必须回主线程;同时兼容弹窗可能已被用户关闭的场景
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -235,6 +263,12 @@ ...@@ -235,6 +263,12 @@
NSDictionary *payload = jsonDict; NSDictionary *payload = jsonDict;
NSInteger dataType = [payload[@"dataType"] integerValue]; NSInteger dataType = [payload[@"dataType"] integerValue];
if (dataType == 9999) {
dispatch_async(dispatch_get_main_queue(), ^{
[self fus_destroyShowTimeFrostedIfNeeded];
});
return;
}
if (FUSLiveHelper.shareInstance.liveType == FUSLiveTypeAnchor) { if (FUSLiveHelper.shareInstance.liveType == FUSLiveTypeAnchor) {
if (dataType != 4) { if (dataType != 4) {
return; return;
......
...@@ -64,6 +64,11 @@ typedef NS_ENUM(NSInteger, FUSLiveShowTimeTicketPurchaseOption) { ...@@ -64,6 +64,11 @@ typedef NS_ENUM(NSInteger, FUSLiveShowTimeTicketPurchaseOption) {
/// @param option 当前选中的购票选项 /// @param option 当前选中的购票选项
@property (nonatomic, copy, nullable) void (^confirmHandler)(FUSLiveShowTimeTicketPurchaseOption option); @property (nonatomic, copy, nullable) void (^confirmHandler)(FUSLiveShowTimeTicketPurchaseOption option);
/// 根据当前弹窗数据与选项,计算最终购买数量
/// @param option 购票选项
/// @return 购买数量;<=0 表示当前不可购买(例如数据未就绪)
- (NSInteger)fus_purchaseTicketCountForOption:(FUSLiveShowTimeTicketPurchaseOption)option;
/// 更新“补全所有票/抢当MVP所需”的票数显示 /// 更新“补全所有票/抢当MVP所需”的票数显示
/// @param remainingTicketCount 还差多少张票(<0 表示未知,不展示) /// @param remainingTicketCount 还差多少张票(<0 表示未知,不展示)
/// @param mvpNeedTicketCount 抢当MVP需要多少张票(<0 表示未知,不展示) /// @param mvpNeedTicketCount 抢当MVP需要多少张票(<0 表示未知,不展示)
......
...@@ -748,6 +748,27 @@ ...@@ -748,6 +748,27 @@
[self fus_applyOptionSelectedUI]; [self fus_applyOptionSelectedUI];
} }
- (NSInteger)fus_purchaseTicketCountForOption:(FUSLiveShowTimeTicketPurchaseOption)option {
switch (option) {
case FUSLiveShowTimeTicketPurchaseOptionOneTicket: {
return 1;
}
case FUSLiveShowTimeTicketPurchaseOptionFillAllTickets: {
if (self.remainingTicketCount < 0) {
return -1;
}
return (NSInteger)MAX(0, self.remainingTicketCount);
}
case FUSLiveShowTimeTicketPurchaseOptionMVPRequiredTickets: {
if (self.mvpNeedTicketCount < 0) {
return -1;
}
return (NSInteger)MAX(0, self.mvpNeedTicketCount);
}
}
return -1;
}
- (void)fus_updateRemainingTicketCount:(NSInteger)remainingTicketCount - (void)fus_updateRemainingTicketCount:(NSInteger)remainingTicketCount
mvpNeedTicketCount:(NSInteger)mvpNeedTicketCount mvpNeedTicketCount:(NSInteger)mvpNeedTicketCount
buyPrice:(NSInteger)buyPrice { buyPrice:(NSInteger)buyPrice {
......
...@@ -596,6 +596,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -596,6 +596,9 @@ NS_ASSUME_NONNULL_BEGIN
/// Ticket Show - 视图 - 购票弹窗数据(观众端:购票入口弹窗展示前拉取) /// Ticket Show - 视图 - 购票弹窗数据(观众端:购票入口弹窗展示前拉取)
+ (NSString *)fus_URL_TicketShow_Buy_GetData; + (NSString *)fus_URL_TicketShow_Buy_GetData;
/// Ticket Show - 功能 - 观众端购票(观众端:购票弹窗确认购买)
+ (NSString *)fus_URL_TicketShow_User_Buy;
/// Ticket Show - 视图 - 获取票的贡献列表(观众端:购票弹窗/贡献页展示) /// Ticket Show - 视图 - 获取票的贡献列表(观众端:购票弹窗/贡献页展示)
+ (NSString *)fus_URL_TicketShow_Rank_List; + (NSString *)fus_URL_TicketShow_Rank_List;
@end @end
......
...@@ -982,6 +982,12 @@ ...@@ -982,6 +982,12 @@
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/ticketshow/buy/getdata"]; return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/ticketshow/buy/getdata"];
} }
/// Ticket Show - 功能 - 观众端购票(观众端:购票弹窗确认购买)
+ (NSString *)fus_URL_TicketShow_User_Buy
{
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/ticketshow/user/buy"];
}
/// Ticket Show - 视图 - 获取票的贡献列表(观众端:购票弹窗/贡献页展示) /// Ticket Show - 视图 - 获取票的贡献列表(观众端:购票弹窗/贡献页展示)
+ (NSString *)fus_URL_TicketShow_Rank_List + (NSString *)fus_URL_TicketShow_Rank_List
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment