130 lines
5.2 KiB
Objective-C
130 lines
5.2 KiB
Objective-C
//
|
|
// XPNobleCenterPresenter.m
|
|
// xplan-ios
|
|
//
|
|
// Created by GreenLand on 2022/1/3.
|
|
//
|
|
|
|
#import "XPNobleCenterPresenter.h"
|
|
|
|
///Api
|
|
#import "Api+NobleCenter.h"
|
|
#import "Api+Mine.h"
|
|
|
|
///Tool
|
|
#import "AccountInfoStorage.h"
|
|
#import "YYUtility.h"
|
|
///Model
|
|
#import "NobleCenterModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "NobleRechargeModel.h"
|
|
///P
|
|
#import "XPNobleCenterProtocol.h"
|
|
|
|
@implementation XPNobleCenterPresenter
|
|
|
|
/// 获取VIP中心数据
|
|
- (void)getNobleCenterInfo {
|
|
[Api vipCenterLevelList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NobleCenterModel *model = [NobleCenterModel modelWithDictionary:data.data];
|
|
[[self getView] getNobleCenterInfoSuccess:model];
|
|
}]];
|
|
}
|
|
/// 获取VIP中心数据
|
|
- (void)getNobleCenterReturnDiamond:(NSString *)recordId{
|
|
[Api getNobleCenterDiamond:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView]getNobleCenterDiamondSuccess:recordId];
|
|
} showLoading:YES errorToast:YES] returnProfitRecordId:recordId];
|
|
}
|
|
// 获取用户信息
|
|
- (void)getUserInfo {
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetUserInfoSuccess:infoModel];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
}] uid:uid];
|
|
}
|
|
|
|
///获取VIP充值产品列表
|
|
- (void)getNobleChargeProductListWithChannelType:(NSString *)type {
|
|
@kWeakify(self);
|
|
[Api getChargeList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
NSArray *list = [RechargeListModel modelsWithArray:data.data];
|
|
[[self getView] onGetNobleRechargeDataSuccess:list];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
}] type:type];
|
|
}
|
|
|
|
/// 生成VIP充值的订单
|
|
/// @param chargeProdId 苹果服务器的充值 的id
|
|
- (void)requestNobleIAPRechargeOrderWithChargeProdId:(NSString *)chargeProdId roomUid:(NSString *)roomUid {
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
NSString * deviceInfo = [YYUtility deviceID];
|
|
NSString * clientIp= [YYUtility ipAddress];
|
|
[Api requestNobleIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSString *orderId = (NSString *)data.data[@"recordId"];
|
|
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
|
|
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] requestIAPRechargeOrderFail:msg code:code];
|
|
}showLoading:NO errorToast:NO] chargeProdId:chargeProdId uid:uid roomUid:roomUid ticket:ticket deviceInfo:deviceInfo clientIp:clientIp];
|
|
}
|
|
|
|
/// 充值成功二次验证
|
|
|
|
/// @param orderId 订单编号
|
|
/// @param transcationId 商品id
|
|
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
[Api checkReceipt:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] checkReceiptSuccess:transcationId];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView]checkReceiptFailWithCode:code transcationId:transcationId];
|
|
} showLoading:YES errorToast:errorToast] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
|
}
|
|
|
|
/// 批量验证内购掉单
|
|
/// @param transcations 凭据的数组
|
|
- (void)checkTranscationIds:(NSArray *)transcations {
|
|
NSString * transcationIdStr = [transcations toJSONString];
|
|
[Api requestCheckTranscationIds:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] checkTranscationIdsSuccess];
|
|
}] transcationIdStr:transcationIdStr];
|
|
}
|
|
|
|
/// 切换隐身进房
|
|
/// @param enterHide 隐身进房
|
|
- (void)changeEnterHide:(BOOL)enterHide {
|
|
[Api changeEnterHidCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] changeEnterHideSuccess];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] changeEnterHideFail];
|
|
}] open:[NSString stringWithFormat:@"%d", enterHide]];
|
|
}
|
|
/// 使用钻石开通VIP
|
|
|
|
/// @param roomUid 房主的uid
|
|
- (void)openVipWithDiamondRoomUid:(NSString *)roomUid vipLevel:(NSString *)vipLevel{
|
|
[Api openWithDiamond:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] openVipWithDiamondSuccess];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] openVipWithDiamondFail:code];
|
|
}showLoading:YES errorToast:YES] roomUid:roomUid vipLevel:vipLevel];
|
|
}
|
|
//联系客服
|
|
-(void)getContactCustomerService{
|
|
[Api requestContactCustomerServiceCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSString *uid = [NSString stringWithFormat:@"%@",data.data];
|
|
[[self getView]getContactCustomerServiceSuccessWithUid:uid];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
} showLoading:YES errorToast:NO]];
|
|
}
|
|
@end
|