123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- //
- // YMAccountBalanceViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/27.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAccountBalanceViewModel.h"
- #import "YMAccountBalanceModel.h"
- #import "YMAccountBalancePayInfoModel.h"
- #import <WechatOpenSDK/WXApi.h>
- #import <AlipaySDK/AlipaySDK.h>
- //#import <SDPTLib/SDPTFramework.h>
- #import <SandPayGate/SandPayGate.h>
- @interface YMAccountBalanceViewModel ()
- /// 用户剩余余额
- @property (nonatomic, strong, readwrite) NSString *userRemainingBalance;
- /// 充值项目数据
- @property (nonatomic, strong, readwrite) NSArray <YMAccountBalanceRechargeItemCellViewModel*>*rechargeItemDataArray;
- /// 充值说明
- @property (nonatomic, strong, readwrite) NSAttributedString *rechargeNotes;
- /// 选中充值项目
- @property (nonatomic, strong, readwrite) RACSubject *selectedRechargeItemSubject;
- /// 选中支付方式
- @property (nonatomic, strong, readwrite) RACSubject *selectedPayMethodTypeSubject;
- /// 充值项目Id
- @property (nonatomic, assign) NSInteger rechargeItemId;
- /// 支付方式代码
- @property (nonatomic, copy) NSString *payMethodCode;
- @property (nonatomic, copy, readwrite) NSString *diamondStr;
- @end
- @implementation YMAccountBalanceViewModel
- - (void)ym_initialize{
- [super ym_initialize];
-
- self.customNavTitle = @"充值中心";
- self.diamondStr = @"";
-
-
- NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
- NSString *rechargeProtocolsStr = stringFormat(@"《%@充值服务协议》",appName);
- NSString *minorProtectionProgramStr = stringFormat(@"《%@未成年人保护计划》",appName);
- NSString *rechargeNotesStr = stringFormat(@"1、充值即代表已阅读并同意%@\n2、前往收支记录,可查询充值订单详情和消费详情\n3、禁止未成年人进行充值,点击详见%@\n4、在充值过程中如遇任何问题,可联系官方客服",rechargeProtocolsStr,minorProtectionProgramStr);
- NSMutableAttributedString *rechargeNotesAttributed = [[NSMutableAttributedString alloc]initWithString:rechargeNotesStr];
- rechargeNotesAttributed.yy_font = LCFont(11);
- rechargeNotesAttributed.yy_color = HexColorFromRGB(0x9c9c9c);
- rechargeNotesAttributed.yy_alignment = NSTextAlignmentLeft;
- rechargeNotesAttributed.yy_lineSpacing = 5;
-
- [rechargeNotesAttributed yy_setTextHighlightRange:[rechargeNotesStr rangeOfString:rechargeProtocolsStr] color:HexColorFromRGB(0x4e5889) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
- YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
- ParamsUrl:[YMGlobalUtils shared].rechargeAgreementUrl
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
- RouterViewModel:webArticleVM
- } completion:nil];
- }];
-
- [rechargeNotesAttributed yy_setTextHighlightRange:[rechargeNotesStr rangeOfString:minorProtectionProgramStr] color:HexColorFromRGB(0x4e5889) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
- YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
- ParamsUrl:[YMGlobalUtils shared].minorProtectionProgramUrl
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
- RouterViewModel:webArticleVM
- } completion:nil];
- }];
-
- self.rechargeNotes = rechargeNotesAttributed;
-
- @weakify(self)
- [[self.selectedRechargeItemSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * _Nullable value) {
- @strongify(self)
- YMAccountBalanceRechargeItemCellViewModel *viewModel = (YMAccountBalanceRechargeItemCellViewModel*)self.rechargeItemDataArray[[value intValue]];
- self.rechargeItemId = viewModel.rechargeItemId;
- }];
-
- [[self.selectedPayMethodTypeSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * _Nullable value) {
- @strongify(self)
- self.payMethodCode = value;
- }];
-
- }
- - (void)getAccountShowData{
- BOOL isRequestData = [OCUserDefaults boolForKey:kIS_FirstRechargeDialog];
- if (!isRequestData) {
- @weakify(self)
- [LCHttpHelper requestWithURLString:WalletShowDialog parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- NSDictionary *dataDic = [dict objectForKey:@"data"];
- if (code == 0) {
-
- BOOL isShow = [[dataDic objectForKey:@"is_activity"] boolValue];
- NSArray *listArray = [dataDic objectForKey:@"list"];
- NSString *str = @"";
-
- if(listArray.count > 0){
- str = [NSString stringWithFormat:@"%@%@",listArray[0][@"name"],listArray[0][@"number"]];
- }
- self.diamondStr = str;
- if(!isShow){
- [OCUserDefaults setBool:YES forKey:kIS_FirstRechargeDialog];
- [self showRechagreDialog:str];
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- }
- - (void)clickRechargeImageView{
- if([self.diamondStr isEqualToString:@""]){
- @weakify(self)
- [LCHttpHelper requestWithURLString:WalletShowDialog parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- NSDictionary *dataDic = [dict objectForKey:@"data"];
- if (code == 0) {
- BOOL isShow = [[dataDic objectForKey:@"is_activity"] boolValue];
- NSArray *listArray = [dataDic objectForKey:@"list"];
- NSString *str = @"";
- if(listArray.count > 0){
- str = [NSString stringWithFormat:@"%@%@",listArray[0][@"name"],listArray[0][@"number"]];
- }
- self.diamondStr = str;
- [self showRechagreDialog:str];
- }
- } failure:^(NSError *error) {
-
- }];
- }else{
- [self showRechagreDialog:self.diamondStr];
- }
- }
- - (void)showRechagreDialog:(NSString*)moneyStr{
- return;
-
- UIView *customView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, adapt(310), adapt(366))];
- UIImageView *imgV = [[UIImageView alloc] init];
- imgV.image = ImageByName(@"ym_balance_show_bg");
- imgV.userInteractionEnabled = true;
- [customView addSubview:imgV];
- [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(customView);
- make.centerX.equalTo(customView);
- make.width.mas_equalTo(adapt(310));
- make.height.mas_equalTo(adapt(366));
- }];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setImage:ImageByName(@"ym_balance_recharge_btn") forState:UIControlStateNormal];
-
- [customView addSubview:btn];
- [btn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(imgV.mas_bottom).offset(adapt(-8));
- make.centerX.equalTo(customView);
- make.width.mas_equalTo(adapt(222));
- make.height.mas_equalTo(adapt(78));
- }];
-
- UIImageView *closeImgv = [[UIImageView alloc] init];
- closeImgv.image = ImageByName(@"ym_common_close_white_icon");
- closeImgv.userInteractionEnabled = false;
- [customView addSubview:closeImgv];
- [closeImgv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(customView.mas_bottom).offset(adapt(10));
- make.centerX.equalTo(customView);
- make.width.height.mas_equalTo(adapt(32));
- }];
-
- // UIImageView *bgV = [[UIImageView alloc] init];
- // bgV.image = ImageByName(@"ym_balance_diomand_bg");
- // bgV.userInteractionEnabled = true;
- // [customView addSubview:bgV];
- // [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.bottom.equalTo(btn.mas_top).offset(adapt(-7));
- // make.centerX.equalTo(customView);
- // make.width.mas_equalTo(adapt(132));
- // make.height.mas_equalTo(adapt(31));
- // }];
- //
- // UIImageView *leftV = [[UIImageView alloc] init];
- // [bgV addSubview:leftV];
- // leftV.image = ImageByName(@"ym_account_balance_recharge_item_diamond_icon");
- // [leftV mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(bgV).offset(adapt(13));
- // make.centerY.equalTo(bgV);
- // make.width.mas_equalTo(adapt(18));
- // make.height.mas_equalTo(adapt(14));
- // }];
- //
- // UILabel *label = [[UILabel alloc] init];
- // [bgV addSubview:label];
- // label.text = moneyStr;
- // label.font = LCFont(15);
- // label.textColor = HexColorFromRGB(0xFF126B);
- // [label mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(leftV.mas_right).offset(adapt(5));
- // make.centerY.equalTo(bgV);
- // }];
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
- popupView.priority = 999;
- popupView.backgroundColor = UIColor.clearColor;
- popupView.positionStyle = YMPositionStyleCenter;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.7;
- @weakify(popupView)
- popupView.bgClickBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- [[[btn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- }];
- [popupView pop];
- }
- - (void)getAccountBalanceInfoData{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"加载中..."];
- [LCHttpHelper requestWithURLString:WalletGoodList parameters:@{
- @"type":@(2)
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- YMAccountBalanceModel *model = [YMAccountBalanceModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
-
- self.userRemainingBalance = model.coin;
-
- self.rechargeItemDataArray = [model.list.rac_sequence map:^id _Nullable(YMAccountBalanceRechargeItemModel * _Nullable model) {
- YMAccountBalanceRechargeItemCellViewModel *viewModel = [[YMAccountBalanceRechargeItemCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)detectionAccountBalanceRechargeInfoData{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"请求中..."];
- [LCHttpHelper requestWithURLString:DetectionAccountBalanceRechargeInfo parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
- BOOL isPop = [data boolValueForKey:@"is_pop" defaultValue:NO];
- if (isPop) {
- YMTipsPopupView *customView = [[YMTipsPopupView alloc]init];
- [customView configutationWithTips:[data stringValueForKey:@"msg" defaultValue:@""] TipsAlignment:NSTextAlignmentCenter IsHideTitle:YES IsHideSingleButton:YES];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerAllCorners;
- popupView.positionStyle = YMPositionStyleCenter;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.3;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm) {
- @strongify(popupView)
- if (isConfirm) {
- [self submitAccountBalanceRechargeInfoData];
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- [popupView pop];
- } else {
- [self submitAccountBalanceRechargeInfoData];
- }
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)submitAccountBalanceRechargeInfoData{
- if ([self.payMethodCode containsString:@"wechat"]) {
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"请求中..."];
- [LCHttpHelper requestWithURLString:AccountBalanceRechargeWeChatPay parameters:@{
- @"device":@(1),
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
- NSString *pay_channel = [data stringValueForKey:@"pay_channel" defaultValue:@""];
- //NSInteger polling = [data integerValueForKey:@"polling" defaultValue:0];
- [self payOrderWithChannel:pay_channel polling:-1];
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- } else if ([self.payMethodCode containsString:@"alipay"]) {
- [self payOrderWithChannel:self.payMethodCode polling:-1];
- }
- }
- - (void)payOrderWithChannel:(NSString*)channel polling:(NSInteger)polling{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"请求中..."];
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
- if (![channel isEqual:@"alipay"]) {
- channel = @"wechat";
- }
- [params setObject:channel forKey:@"channel"];
- [params setObject:@(self.rechargeItemId) forKey:@"goods_id"];
- [params setObject:@(polling) forKey:@"polling"];
-
- NSLog(@"输出🍀\n%@",params);
-
- [LCHttpHelper requestWithURLString:WalletRecharge parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
-
- NSLog(@"输出🍀\n%@",dict);
-
- if (code == 0) {
- [ZCHUDHelper dismiss];
- YMAccountBalancePayInfoModel *model = [YMAccountBalancePayInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
- NSLog(@"当前支付类型---:%@",self.payMethodCode);
- if ([self.payMethodCode containsString:@"wechat"]) {
- if(![WXApi isWXAppInstalled]){
- [ZCHUDHelper showTitle:@"未安装微信或版本过低"];
- return;
- }
- if (model.pay_obj.type == YMAccountBalabcePayType_H5) {
- NSDictionary*dic =model.pay_obj.data;
- NSURL *url = [NSURL URLWithString:dic[@"pay_info"]];
- // 检查是否可以打开URL
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- // 打开URL
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- }
- }else if (model.pay_obj.type == YMAccountBalabcePayTypeAlipay_H5) {
- NSLog(@"当前支付类型3---:%@",model.pay_obj.data);
- NSURL *url = [NSURL URLWithString:model.pay_obj.data];
- // 检查是否可以打开URL
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- // 打开URL
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- }
- }else if(model.pay_obj.type == YMAccountBalabcePayTypeWeChat_pay) {
- NSDictionary *result_dict = [dict objectForKey:@"data"];
- NSDictionary *pay_obj_dict = [result_dict objectForKey:@"pay_obj"];
- NSDictionary *pay_obj_data = [pay_obj_dict objectForKey:@"data"];
- YMAccountBalanceWeChatInfoModel *wechatpayinfo = [YMAccountBalanceWeChatInfoModel yy_modelWithJSON:pay_obj_data];
-
- PayReq *request = [[PayReq alloc] init];
- request.partnerId = wechatpayinfo.mch_id;
- request.prepayId = wechatpayinfo.prepay_id;
- request.package = @"Sign=WXPay";
- request.nonceStr = wechatpayinfo.nonce_str;
- request.timeStamp = (uint32_t)[wechatpayinfo.timestamp intValue];
- request.sign = wechatpayinfo.paySign;
-
- NSString *partnerId = request.partnerId;
- NSString *prepayId = request.prepayId;
- NSString *package = request.package;
- NSString *nonceStr = request.nonceStr;
- NSInteger timeStamp = request.timeStamp;
- NSString *sign = request.sign;
- NSLog(@"输出🍀\n%@",@{
- @"partnerId":partnerId,
- @"prepayId":prepayId,
- @"package":package,
- @"nonceStr":nonceStr,
- @"timeStamp":@(timeStamp),
- @"sign":sign
- });
-
-
- [WXApi sendReq:request completion:^(BOOL success) {
- }];
- } else {
- NSString *token = model.pay_obj.data;
- NSLog(@"%@",token);
- if (!token || token.length == 0) {
- [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败,请联系技术人员"]];
- return;
- }
-
- [SandPayGateService.shared queryTradeRecordInfoWith:token];
- SandPayGateService.shared.sandpayGateResultBlock = ^(NSString* status, NSDictionary* dataDic) {
- NSLog(@"输出🍀\n%@ \n%@",status, dataDic);
- if ([status isEqualToString:@"success"]) {
- NSString *funcCode = dataDic[@"funcCode"];
- NSString *ghOriId = dataDic[@"ghOriId"];
- NSString *miniProgramType = dataDic[@"miniProgramType"];
- NSString *pathUrl = dataDic[@"pathUrl"];
- NSString *subAppId = dataDic[@"subAppId"];
- NSString *tokenId = dataDic[@"tokenId"];
-
- //跳转微信小程序
- NSString *allPath = [NSString stringWithFormat:@"%@token_id=%@&funcCode=%@", pathUrl, tokenId, funcCode];
-
- NSLog(@"输出🍀\n%@", allPath);
- WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
- launchMiniProgramReq.userName = ghOriId;
- launchMiniProgramReq.path = allPath;
- launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; // 使用适当的类型,例如WXMiniProgramTypeRelease
-
- [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
- if (success) {
- NSLog(@"跳转微信成功");
- } else {
- NSLog(@"跳转微信异常");
- }
- }];
- } else {
- //[ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败:%@",errorMsg]];
- [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败"]];
- }
- };
- //
- //
- // XHPayParameterModel *payParameter = [XHPayParameterModel yy_modelWithJSON:model.pay_obj.data];
- // [SDPTController shared].paySucTypeBlock = ^(ProductPyType type, id _Nonnull responseObj) {
- // NSLog(@"测试打印:%@",responseObj);
- // //跳转微信小程序
- // NSDictionary *pay_extra = [payParameter.pay_extra mj_JSONObject];
- // NSString * allPath = [NSString stringWithFormat:@"%@token_id=%@",pay_extra[@"path_url"],responseObj];
- // WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
- //
- // launchMiniProgramReq.userName = pay_extra[@"gh_ori_id"];
- // launchMiniProgramReq.path = allPath;
- // /// 0 正式版
- // launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease;
- // [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
- // if (success) {
- // NSLog(@"跳转微信成功");
- // } else {
- // NSLog(@"跳转微信异常");
- // }
- // }];
- //
- // };
- // [SDPTController shared].payFailureBlock = ^(ProductPyType type, NSString * _Nonnull errorMsg) {
- // [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败:%@",errorMsg]];
- // };
- //
- // if(payParameter){
- // [[SDPTController shared] singletonPaymentMethodWith:payParameter];
- // }else{
- // [ZCHUDHelper showTitle:@"支付数据错误"];
- // }
-
- }
-
-
- } else if ([self.payMethodCode containsString:@"alipay"]) {
- if(model.pay_obj.type == YMAccountBalabcePayTypeAliSdk_pay){
- NSString *appScheme = @"msyoupaipay";
- [[AlipaySDK defaultService] payOrder:model.payinfo fromScheme:appScheme callback:^(NSDictionary *resultDic) {
- NSLog(@"reslut ====== %@",resultDic);
- if ([resultDic[@"resultStatus"] isEqualToString:@"9000"] || [resultDic[@"resultStatus"] isEqualToString:@"8000"] || [resultDic[@"resultStatus"] isEqualToString:@"6004"]) {
- [ZCHUDHelper showTitle:@"支付成功"];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [OCNotificationCenter postNotificationName:ALIPAY_SUCCESS_NOTIFICATION object:nil];
- });
- } else if ([resultDic[@"resultStatus"] isEqualToString:@"6001"]) {
- }else {
- [ZCHUDHelper showTitle:@"支付失败"];
- }
- }];
- }else{
- NSLog(@"当前支付类型2-$$$--:%ld",model.pay_obj.type);
- if (model.pay_obj.type == YMAccountBalabcePayType_H5) {
- NSDictionary*dic =model.pay_obj.data;
- NSURL *url = [NSURL URLWithString:dic[@"pay_info"]];
- // 检查是否可以打开URL
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- // 打开URL
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- }
- }else if (model.pay_obj.type == YMAccountBalabcePayTypeAlipay_H5) {
- NSLog(@"当前支付类型3---:%@",model.pay_obj.data);
- NSURL *url = [NSURL URLWithString:model.pay_obj.data];
- // 检查是否可以打开URL
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- // 打开URL
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- }
- }else {
- NSString *token = model.pay_obj.data;
- NSLog(@"%@",token);
- if (!token || token.length == 0) {
- [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败,请联系技术人员"]];
- return;
- }
-
- [SandPayGateService.shared queryTradeRecordInfoWith:token];
- SandPayGateService.shared.sandpayGateResultBlock = ^(NSString* status, NSDictionary* dataDic) {
- NSLog(@"输出🍀\n%@ \n%@",status, dataDic);
- if ([status isEqualToString:@"success"]) {
-
-
- } else {
- //[ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败:%@",errorMsg]];
- [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败"]];
- }
- };
- }
-
-
- // [SDPTController shared].paySucTypeBlock = ^(ProductPyType type, id _Nonnull responseObj) {
- // NSLog(@"支付数据匹配成功");
- //
- // };
- // [SDPTController shared].payFailureBlock = ^(ProductPyType type, NSString * _Nonnull errorMsg) {
- // [ZCHUDHelper showTitle:[NSString stringWithFormat:@"支付失败:%@",errorMsg]];
- // };
- //
- // XHPayParameterModel *data = [XHPayParameterModel mj_objectWithKeyValues:responseObject[@"data"][@"pay_obj"][@"data"]];
- // [[SDPTController shared] singletonPaymentMethodWith:data];
- }
-
-
- }
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)gotoIncomeBreakdown{
- YMIncomeBreakdownViewModel *incomeBreakdownVM = [[YMIncomeBreakdownViewModel alloc]initWithParams:@{}];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_INCOME_BREAKDOWN) withUserInfo:@{
- RouterViewModel:incomeBreakdownVM
- } completion:nil];
- }
- - (RACSubject *)selectedRechargeItemSubject{
- if (!_selectedRechargeItemSubject) {
- _selectedRechargeItemSubject = [RACSubject subject];
- }
- return _selectedRechargeItemSubject;
- }
- - (RACSubject *)selectedPayMethodTypeSubject{
- if (!_selectedPayMethodTypeSubject) {
- _selectedPayMethodTypeSubject = [RACSubject subject];
- }
- return _selectedPayMethodTypeSubject;
- }
- @end
|