From a98ece29f64aebd490d2aaccba2a38195f093a7d Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Tue, 19 Sep 2023 16:00:06 +0800 Subject: [PATCH] =?UTF-8?q?v2=E6=94=AF=E4=BB=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presenter/XPMineRechargePresenter.h | 2 +- .../Presenter/XPMineRechargePresenter.m | 4 +- .../Noble/Presenter/XPNobleCenterPresenter.h | 2 +- .../Noble/Presenter/XPNobleCenterPresenter.m | 4 +- .../Noble/View/XPNobleCenterViewController.m | 16 ++++- .../Recharge/XPIAPRechargeViewController.m | 10 ++- .../View/AnimationView/XPRoomAnimationView.h | 2 + .../View/AnimationView/XPRoomAnimationView.m | 4 +- .../FirstRecharge/View/XPFirstRechargeView.m | 24 +++++-- .../YMRoom/View/XPRoomViewController.m | 1 + .../YMTabbar/Presenter/MainPresenter.m | 6 +- YuMi/Tools/PIIAPTool/PIIAPPayment.swift | 72 +++++++++---------- 12 files changed, 90 insertions(+), 57 deletions(-) diff --git a/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.h b/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.h index 8240cbda..d24371a0 100644 --- a/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.h +++ b/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN /// 充值成功二次验证 /// @param orderId 订单编号 /// @param transcationId 商品id -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId; +- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast; /// 批量验证内购掉单 /// @param transcations 凭据的数组 diff --git a/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.m b/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.m index 6fcfd23b..5dee2499 100644 --- a/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.m +++ b/YuMi/Modules/YMMine/Presenter/XPMineRechargePresenter.m @@ -61,14 +61,14 @@ /// 充值成功二次验证 /// @param orderId 订单编号 /// @param transcationId 商品id -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId { +- (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:NO errorToast:NO] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; + } showLoading:NO errorToast:errorToast] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; } diff --git a/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.h b/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.h index 387891fd..1729c346 100644 --- a/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.h +++ b/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN /// 充值成功二次验证 /// @param orderId 订单编号 /// @param transcationId 商品id -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId; +- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast; /// 批量验证内购掉单 /// @param transcations 凭据的数组 diff --git a/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.m b/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.m index cc1f6d54..bba4ac83 100644 --- a/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.m +++ b/YuMi/Modules/YMMine/View/Noble/Presenter/XPNobleCenterPresenter.m @@ -69,14 +69,14 @@ /// @param orderId 订单编号 /// @param transcationId 商品id -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId { +- (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]hideHUD]; - } showLoading:YES] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; + } showLoading:YES errorToast:errorToast] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; } /// 批量验证内购掉单 diff --git a/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m b/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m index 90a1f6ca..d9bd3651 100644 --- a/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m +++ b/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m @@ -242,7 +242,7 @@ NSString *orderId = transcation[@"orderId"]; NSString *transcationId = transcation[@"transcationId"]; ///二次验证 - [self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId]; + [self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO]; } } @@ -340,6 +340,12 @@ ///二次校验成功 - (void)checkReceiptSuccess:(NSString *)transcationId { [self hideHUD]; + if (@available(iOS 15.0, *)) { + PIIAPPayment *iap = [PIIAPPayment shared]; + [iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ + + }]; + } [self deleteRechageReciptWithTransactionIdentifier:transcationId]; self.orderId = nil; //5秒之后如果没有收到开通成功的云信消息,则请求一次用户信息 @@ -353,6 +359,12 @@ - (void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{ [self hideHUD]; if(code == 1444){ + if (@available(iOS 15.0, *)) { + PIIAPPayment *iap = [PIIAPPayment shared]; + [iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ + + }]; + } [self deleteRechageReciptWithTransactionIdentifier:transcationId]; } } @@ -394,7 +406,7 @@ [self saveRechageReciptWithTransactionIdentifier:transactionIdentifier]; [self showLoading]; ///二次验证 - [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier]; + [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES]; } ///充值成功之后保存订单到钥匙串 diff --git a/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m b/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m index 202fa5c5..5ff8bda0 100644 --- a/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m +++ b/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m @@ -224,7 +224,7 @@ NSString *orderId = transcation[@"orderId"]; NSString *transcationId = transcation[@"transcationId"]; ///二次验证 - [self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId]; + [self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO]; } } @@ -279,7 +279,7 @@ [self saveRechageReciptWithTransactionIdentifier:transactionIdentifier]; [self showLoading]; ///二次验证 - [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier]; + [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES]; } @@ -364,6 +364,12 @@ -(void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{ [self hideHUD]; if(code == 1444){ + if (@available(iOS 15.0, *)) { + PIIAPPayment *iap = [PIIAPPayment shared]; + [iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ + + }]; + } [self deleteRechageReciptWithTransactionIdentifier:transcationId]; } } diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.h b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.h index c3dc29d7..faca4829 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.h +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomAnimationView : XPRoomAnimationHitView + +-(void)resumeTimer; - (instancetype)initWithDelegate:(id)delegate; @end diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index 0d89ed27..8c5ba99d 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -153,6 +153,9 @@ - (void)dealloc { [NSObject cancelPreviousPerformRequestsWithTarget:self]; [[NIMSDK sharedSDK].broadcastManager removeDelegate:self]; + +} +-(void)resumeTimer{ if(self.giftEffectTimer != nil){ dispatch_resume(self.giftEffectTimer); self.giftEffectTimer = nil; @@ -163,7 +166,6 @@ self.giftTimer = nil; } } - - (instancetype)initWithDelegate:(id)delegate { self = [super init]; if (self) { diff --git a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m index 13170d11..e334bbdf 100644 --- a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m +++ b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m @@ -346,7 +346,7 @@ ///保存唯一凭证 [self saveRechageReciptWithTransactionIdentifier:transactionIdentifier]; ///二次验证 - [self checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier]; + [self checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES]; } ///充值成功之后保存订单到钥匙串 @@ -400,11 +400,11 @@ NSString *orderId = transcation[@"orderId"]; NSString *transcationId = transcation[@"transcationId"]; ///二次验证 - [self checkReceiptWithOrderId:orderId transcationId:transcationId]; + [self checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO] ; } } -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId { +- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{ NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; @@ -414,9 +414,18 @@ [self checkReceiptSuccess:transcationId]; } else { if(code == 1444){ + if (@available(iOS 15.0, *)) { + PIIAPPayment *iap = [PIIAPPayment shared]; + [iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ + + }]; + } [self deleteRechageReciptWithTransactionIdentifier:transcationId]; } - [XNDJTDDLoadingTool showErrorWithMessage:msg]; + if(errorToast == YES){ + [XNDJTDDLoadingTool showErrorWithMessage:msg]; + } + } [XNDJTDDLoadingTool hideHUD]; } chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; @@ -425,7 +434,12 @@ ///二次验证成功 - (void)checkReceiptSuccess:(NSString *)transcationId { - + if (@available(iOS 15.0, *)) { + PIIAPPayment *iap = [PIIAPPayment shared]; + [iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ + + }]; + } [self deleteRechageReciptWithTransactionIdentifier:transcationId]; self.orderId = nil; } diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 9bc3bff0..dd1abd8c 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -1433,6 +1433,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 - (void)exitRoom { [self.menuContainerView menuResignFirstResponder]; + [self.animationView resumeTimer]; if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) { NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; NSString * uid = [AccountInfoStorage instance].getUid; diff --git a/YuMi/Modules/YMTabbar/Presenter/MainPresenter.m b/YuMi/Modules/YMTabbar/Presenter/MainPresenter.m index 55632740..b0bb98e7 100644 --- a/YuMi/Modules/YMTabbar/Presenter/MainPresenter.m +++ b/YuMi/Modules/YMTabbar/Presenter/MainPresenter.m @@ -79,11 +79,9 @@ static NSString * kUpdateVersionNum = @"kUpdateVersionNum"; [Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { NSString * uid = [AccountInfoStorage instance].getUid; - [RechargeStorage delegateAllTranscationIdsWithUid:uid]; - } else { - [XNDJTDDLoadingTool showErrorWithMessage:msg]; + [RechargeStorage delegateTranscationId:transcationId uid:uid]; } - [XNDJTDDLoadingTool hideHUD]; + } chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; } diff --git a/YuMi/Tools/PIIAPTool/PIIAPPayment.swift b/YuMi/Tools/PIIAPTool/PIIAPPayment.swift index 68a334d5..c0ad9d21 100644 --- a/YuMi/Tools/PIIAPTool/PIIAPPayment.swift +++ b/YuMi/Tools/PIIAPTool/PIIAPPayment.swift @@ -78,39 +78,8 @@ public class PIIAPPayment: NSObject { print("iap error") } } - /*All transactions:全部的购买交易订单 - Latest transactions:最新的购买交易订单。(分为订阅品项和除订阅品项外的所有类型二种) - Current entitlements:当前用户有购买的权限。(全部的订阅品项、和非消耗品项) - */ - @objc public func allTransaction(list:[NSString]) async { -// var getList:[String] = []; -// for i in 0.. 0 { try await purchase(storeProducts[0],uuid) }else { @@ -143,7 +115,7 @@ public class PIIAPPayment: NSObject { if(stateBlock != nil ){ stateBlock(StoreState.pay,nil) } - + guard let curUUID = UUID.init(uuidString: uuid) else{ if(stateBlock != nil ){ @@ -207,11 +179,37 @@ public class PIIAPPayment: NSObject { await uploadServer(for: transactionId) // 这里不触发完成,等服务器验证再触发完成逻辑 -// await transaction.finish() + await transaction.finish() + print("iap: finish") return transaction } - + /*All transactions:全部的购买交易订单 + Latest transactions:最新的购买交易订单。(分为订阅品项和除订阅品项外的所有类型二种) + Current entitlements:当前用户有购买的权限。(全部的订阅品项、和非消耗品项) + */ + func allTransaction(transactionId:String) async { + + let transactionIntId = UInt64(transactionId) + for await result in Transaction.all { + do { + let tran = try checkVerified(result) + let resultId = try result.payloadValue.id + if transactionIntId == resultId { + await tran.finish() + break + } + } catch let error { + + print("error:----\(error)") + } + + } + + + //Transaction.latest(for: "pid") + + } // 事件完成处理 @objc public func transactionFinish(transaction:String) async{ @@ -220,7 +218,7 @@ public class PIIAPPayment: NSObject { transactionMap.removeValue(forKey: transaction) print("transactionFinish end") }else { - print("transaction不存在,参数不正确,Id=\(transaction)") + await allTransaction(transactionId: transaction) } }