// // YMMineRechargePresenter.m // YUMI // // Created by YUMI on 2021/9/24. // #import "XPMineRechargePresenter.h" ///Api #import "Api+Mine.h" ///Tool #import "AccountInfoStorage.h" #import "YYUtility.h" #import "NSObject+MJExtension.h" ///P #import "XPMineRechargeProtocol.h" ///Model #import "RechargeListModel.h" #import "WalletInfoModel.h" @implementation XPMineRechargePresenter /// 获取钱包信息 - (void)getUserWalletInfo { NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; [Api getUserWalletInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data]; [[self getView] getUserWalletInfo:model]; }] uid:uid ticket:ticket]; } /// 请求内购列表 /// @param channel 目前是8 - (void)requestRechargeListWithChannel:(NSString *)channel { [Api getRechargeList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { NSArray * array = [RechargeListModel modelsWithArray:data.data]; [[self getView] requestRechargeListSucccess:array]; }] channelType:channel]; } /// 获取充值的订单编号 /// @param chargeProdId 苹果服务器的充值 的id - (void)requestIAPRechargeOrderWithChargeProdId:(NSString *)chargeProdId { NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; NSString * deviceInfo = [YYUtility deviceID]; NSString * clientIp= [YYUtility ipAddress]; [Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) { NSString *orderId = (NSString *)data.data[@"recordId"]; [[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId]; } fail:^(NSInteger code, NSString * _Nullable msg) { if(code != 50000){ [[self getView]showErrorToast:msg]; } [[self getView] requestIAPRechargeOrderFailWithCode:code]; }errorToast:NO] chargeProdId:chargeProdId uid:uid ticket:ticket deviceInfo:deviceInfo clientIp:clientIp]; } /// 充值成功二次验证 /// @param receipt 凭据 /// @param orderId 订单编号 /// @param transcationId 商品id - (void)checkReceiptWithData:(NSString *)receipt orderId:(NSString *)orderId transcationId:(NSString *)transcationId { 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]hideHUD]; } showLoading:YES] receipt:receipt 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]; } //充值banner位 -(void)getBannerList{ [Api requestBannerListCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) { NSArray * array = [RechargeListModel modelsWithArray:data.data[@"banners"]]; [[self getView]getBannerListSuccessWithList:array]; } fail:^(NSInteger code, NSString * _Nullable msg) { } showLoading:NO errorToast:NO]]; } //联系客服 -(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