Files
peko-ios/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.m
2024-09-18 10:31:21 +08:00

112 lines
4.2 KiB
Objective-C

//
// 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];
@kWeakify(self);
[Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
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) {
@kStrongify(self);
if(code != 50000){
[[self getView]showErrorToast:msg];
}
[[self getView] requestIAPRechargeOrderFailWithCode:code];
}errorToast:NO] chargeProdId:chargeProdId uid:uid 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;
@kWeakify(self);
[Api checkReceipt:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
[[self getView] checkReceiptSuccess:transcationId];
}fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[[self getView]checkReceiptFailWithCode:code transcationId:transcationId];
} showLoading:NO 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];
}
//充值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