123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- //
- // SPSBPurchaserOrderListPayViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/6/21.
- //
- #import "SPSBPurchaserOrderListPayViewController.h"
- #import "SPSBTransferOrderListModel.h"
- #import "SPSBPurchaseOrderListModel.h"
- #import "UIViewController+SPSBNetworkManager.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBConstantProfile.h"
- #import "SPSBAppDifferenceProfile.h"
- #import "SPSBQueryListViewController.h"
- #import "SPSBPurchasersModel.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBGeneralManager.h"
- #import <JXHGeneralTools.h>
- @interface SPSBPurchaserOrderListPayViewController () {
- bool _canShowAnimation;
- bool _isHaveCardCharge;
- }
- @end
- @implementation SPSBPurchaserOrderListPayViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self judgeData];
- }
- #pragma mark - Action
- - (void)showAnimation {
- if (_canShowAnimation) {
- [super showAnimation];
- }
- }
- - (void)judgeData {
- _canShowAnimation = true;
- switch (_spsb_type) {
- case SPSBPurchaserOrderListPayTypePay: {
- if (_spsb_data.spsba_orderListModelType == SPSBOrderListModelTypePurchase) {
- [self setOrderBaseWithOrderType:SPSBOrderTypePurchase totalFee:((SPSBPurchaseOrderListModel *)_spsb_data).spsb_total_fee.floatValue discountCount:_spsb_discountCount orderNumber:((SPSBPurchaseOrderListModel *)_spsb_data).spsb_nums.integerValue showData:nil buttonType:SPSBOrderListPayButtonTypePay];
- } else {
- [self setOrderBaseWithOrderType:SPSBOrderTypeTransfer totalFee:((SPSBTransferOrderListModel *)_spsb_data).spsb_charge.floatValue discountCount:_spsb_discountCount orderNumber:1 showData:nil buttonType:SPSBOrderListPayButtonTypePay];
- }
- [self createPayView];
- }
- break;
- case SPSBPurchaserOrderListPayTypeDetails: {
- if (_spsb_data.spsba_orderListModelType == SPSBOrderListModelTypePurchase) {
- if (_spsb_data.spsba_status.integerValue == 1) {
- _canShowAnimation = false;
- [self payPurchaseOrderWithshowDetails:true];
- } else {
- [self setOrderBaseWithOrderType:SPSBOrderTypePurchase totalFee:((SPSBPurchaseOrderListModel *)_spsb_data).spsb_total_fee.floatValue discountCount:_spsb_discountCount orderNumber:((SPSBPurchaseOrderListModel *)_spsb_data).spsb_nums.integerValue showData:_spsb_data.spsba_detailsData buttonType:SPSBOrderListPayButtonTypeQuery];
- [self createPayView];
- }
-
- } else {
- if (_spsb_data.spsba_status.integerValue == 1) {
- [self setOrderBaseWithOrderType:SPSBOrderTypeTransfer totalFee:((SPSBTransferOrderListModel *)_spsb_data).spsb_charge.floatValue discountCount:_spsb_discountCount orderNumber:1 showData:_spsb_data.spsba_detailsData buttonType:SPSBOrderListPayButtonTypePay];
- } else {
- [self setOrderBaseWithOrderType:SPSBOrderTypeTransfer totalFee:((SPSBTransferOrderListModel *)_spsb_data).spsb_charge.floatValue discountCount:_spsb_discountCount orderNumber:1 showData:_spsb_data.spsba_detailsData buttonType:SPSBOrderListPayButtonTypeNone];
- }
- [self createPayView];
- }
- }
- break;
-
- default:
- break;
- }
- }
- - (void)payAction {
- switch (_spsb_type) {
- case SPSBPurchaserOrderListPayTypePay: {
- if (_spsb_data.spsba_orderListModelType == SPSBOrderListModelTypePurchase) {
- [self payPurchaseOrderWithshowDetails:false];
- } else {
- [self payTransferOrder];
- }
- }
- break;
- case SPSBPurchaserOrderListPayTypeDetails: {
- if (_spsb_data.spsba_orderListModelType == SPSBOrderListModelTypePurchase) {
- [self purchasePay];
- } else {
- [self payTransferOrder];
- }
- }
- break;
-
- default:
- break;
- }
- }
- - (void)queryAction {
- @weakify(self)
- [self dismissContentViewCompletion:^{
- @strongify(self)
- [self toQueryListView];
- }];
- }
- - (void)toQueryListView {
- SPSBPurchaseOrderListModel *model = (SPSBPurchaseOrderListModel *)_spsb_data;
- SPSBQueryListViewController *vc = SPSBQueryListViewController.new;
- if ([model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeSocialInsurance] || [model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeSocialInsurancePack]) {
- vc.spsb_isQueryAccumulationFund = false;
- } else {
- vc.spsb_isQueryAccumulationFund = true;
- }
- SPSBPurchasersModel *purchasers = SPSBPurchasersModel.new;
- purchasers.spsb_id = model.spsb_sbuId;
- purchasers.spsb_user_name = model.spsb_u_name;
- purchasers.spsb_id_card = model.spsb_id_card;
- vc.spsb_purchasers = purchasers;
- vc.spsb_year = [model.spsb_start_month substringWithRange:NSMakeRange(0, 4)];
- UIViewController *v = jxh_findPresentedViewControllerStartingFrom(spsb_keyWindow().rootViewController);
- if (v.navigationController) {
- [v.navigationController pushViewController:vc animated:true];
- }
- }
- #pragma mark - Network Action
- - (void)payPurchaseOrderWithshowDetails:(bool)showDetails {
- SPSBPurchaseOrderListModel *model = (SPSBPurchaseOrderListModel *)_spsb_data;
- NSString *path = [model.SPSBPurchaseOrderListModel_isSupplementaryPay isEqualToString:@"1"] ? spsb_appUrl(SPSBUrlGetTotalSupplementaryPayFee) : spsb_appUrl(SPSBUrlGetTotalFee);
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:showDetails ? @"正在加载" : @"正在支付" isLogin:true url:path urlParameters:nil parameters:^NSDictionary * _Nonnull{
- return @{@"sbuId" : model.spsb_sbuId,
- @"cid" : model.spsb_cid,
- @"shebao_card" : model.spsb_new_card,
- @"hukou_type" : model.spsb_hukou_type,
- @"month" : spsb_changeTimeToNumber(model.spsb_start_month),
- @"fund" : [NSString stringWithFormat:@"%.2f", [model.spsb_fund floatValue] / [model.SPSBPurchaseOrderListModel_numOfMonth integerValue]],
- @"nums" : model.SPSBPurchaseOrderListModel_numOfMonth,
- @"pay_for" : model.spsb_pay_for,
- @"flow_force": model.spsb_flow_force.length == 0 ? @0 : model.spsb_flow_force,
- @"sb_wage": model.spsb_sb_wage
- };
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self getPurchaseBuyTotalFeeNetworkGetData:data showDetails:showDetails];
- return showDetails ? @"" : nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- if (showDetails) {
- [self dismissContentViewCompletion:nil];
- return @"加载失败";
- } else {
- if (self.spsb_orderBase.spsb_payFailure) {
- self.spsb_orderBase.spsb_payFailure(error);
- }
- return nil;
- }
- }];
- }
- - (void)getPurchaseBuyTotalFeeNetworkGetData:(id)data showDetails:(bool)showDetails {
- _isHaveCardCharge = [data[@"data"][@"card_charge"] floatValue] > 0;
- if (showDetails) {
- SPSBPurchaseOrderListModel *model = (SPSBPurchaseOrderListModel *)_spsb_data;
- NSMutableString *titles = [@"" mutableCopy];
- NSMutableString *contents = [@"" mutableCopy];
- NSInteger lines = 0;
- if (![model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeAccumulationFund]) {
- [titles appendString:@"\n社保"];
- [contents appendFormat:@"\n¥%.2f", [data[@"data"][@"shebao"] floatValue]];
- lines ++;
- }
- if (![model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeSocialInsurance]) {
- [titles appendString:@"\n公积金"];
- [contents appendFormat:@"\n¥%.2f", [data[@"data"][@"fund"] floatValue]];
- lines ++;
- }
- if (model.spsb_flow_force.boolValue) {
- [titles appendString:@"\n社保流水"];
- [contents appendFormat:@"\n¥%.2f", [data[@"data"][@"flow"] floatValue]];
- lines ++;
- }
- if ([model.spsb_new_card boolValue]) {
- [titles appendString:@"\n社保卡"];
- [contents appendFormat:@"\n¥%.2f", [data[@"data"][@"card_charge"] floatValue]];
- lines ++;
- }
-
- [titles appendString:@"\n服务费"];
- [contents appendFormat:@"\n¥%.2f", [data[@"data"][@"s_charge"] floatValue] + [data[@"data"][@"f_charge"] floatValue] + [data[@"data"][@"flow_charge"] floatValue]];
- lines ++;
-
- if (![titles isEqualToString:@""]) {
- [titles deleteCharactersInRange:NSMakeRange(0, 1)];
- }
- if (![contents isEqualToString:@""]) {
- [contents deleteCharactersInRange:NSMakeRange(0, 1)];
- }
- model.spsba_detailsData.spsb_title = titles;
- model.spsba_detailsData.spsb_content = contents;
- model.spsba_detailsData.spsb_lines = lines;
- model.spsba_detailsData.spsb_amount = [NSString stringWithFormat:@"%.2f元", [data[@"data"][@"total_fee"] floatValue]];
- _canShowAnimation = true;
- [self setOrderBaseWithOrderType:SPSBOrderTypePurchase totalFee:[data[@"data"][@"total_fee"] floatValue] discountCount:_spsb_discountCount orderNumber:model.spsb_nums.integerValue showData:model.spsba_detailsData buttonType:SPSBOrderListPayButtonTypePay];
- [self createPayView];
- [self showAnimation];
- return;
- }
- [self purchasePay];
-
- }
- - (void)purchasePay {
- if (_spsb_data.spsba_orderListBusinessType == SPSBOrderListBusinessTypeSB) {
- [self createPurchaseSocialInsuranceOrderWithModel:(SPSBPurchaseOrderListModel *)_spsb_data];
- } else if (_spsb_data.spsba_orderListBusinessType == SPSBOrderListBusinessTypeAF) {
- [self createPurchaseAccumulationFundOrderWithModel:(SPSBPurchaseOrderListModel *)_spsb_data];
- }
- }
- - (void)createPurchaseSocialInsuranceOrderWithModel:(SPSBPurchaseOrderListModel *)model {
- NSString *path = [model.SPSBPurchaseOrderListModel_isSupplementaryPay isEqualToString:@"1"] ? spsb_appUrl(SPSBUrlCreateShebaoSupplementaryPayOrder) : spsb_appUrl(SPSBUrlCreateShebaoOrder);
- bool isPack = [model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeSocialInsurance] || [model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeAccumulationFund] ? false : true;
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在支付" isLogin:true url:path urlParameters:nil parameters:^NSDictionary * _Nonnull{
-
- NSString *fund = [NSString stringWithFormat:@"%.2f", [model.spsb_fund floatValue] / [model.SPSBPurchaseOrderListModel_numOfMonth integerValue]];
- return [self getParametersWithParameters:@{@"fund" : isPack == true ? fund : @"0"} model:model];
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- SPSBResultServeyType type;
- if (isPack) {
- type = SPSBResultServeyTypePack;
- } else {
- type = SPSBResultServeyTypeSB;
- }
- if (model.spsb_sb_wage.integerValue > 0) {
- self.spsb_isNeedSalary = true;
- }
- [self payActionWithOrderType:self->_isHaveCardCharge ? SPSBOrderTypePurchaseWithSSCard : SPSBOrderTypePurchase serveyType:type payData:data[@"data"] argumentData:nil];
- return nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- if (self.spsb_orderBase.spsb_payFailure) {
- self.spsb_orderBase.spsb_payFailure(error);
- }
- return nil;
- }];
- }
- - (void)createPurchaseAccumulationFundOrderWithModel:(SPSBPurchaseOrderListModel *)model {
- bool isPack = [model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeSocialInsurance] || [model.spsb_pay_for isEqualToString:SPSBBuyBusinessTypeAccumulationFund] ? false : true;
- NSString *path = [model.SPSBPurchaseOrderListModel_isSupplementaryPay isEqualToString:@"1"] ? spsb_appUrl(SPSBUrlCreateFundSupplementaryPayOrder) : spsb_appUrl(SPSBUrlCreateFundOrder);
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在支付" isLogin:true url:path urlParameters:nil parameters:^NSDictionary * _Nonnull{
- NSString *fund = [NSString stringWithFormat:@"%.2f", [model.spsb_fund floatValue] / [model.SPSBPurchaseOrderListModel_numOfMonth integerValue]];
- return [self getParametersWithParameters:@{@"buyShebao" : isPack == true ? @"1" : @"0", @"fund" : fund} model:model];
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- SPSBResultServeyType type;
- if (isPack) {
- type = SPSBResultServeyTypePack;
- } else {
- type = SPSBResultServeyTypeAF;
- }
- if (model.spsb_sb_wage.integerValue > 0) {
- self.spsb_isNeedSalary = true;
- }
- [self payActionWithOrderType:self->_isHaveCardCharge ? SPSBOrderTypePurchaseWithSSCard : SPSBOrderTypePurchase serveyType:type payData:data[@"data"] argumentData:nil];
- return nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- if (self.spsb_orderBase.spsb_payFailure) {
- self.spsb_orderBase.spsb_payFailure(error);
- }
- return nil;
- }];
- }
- - (NSDictionary *)getParametersWithParameters:(NSDictionary *)parameters model:(SPSBPurchaseOrderListModel *)model {
- NSMutableDictionary *narmolParameters = [@{@"sbuId" : model.spsb_sbuId,
- @"sb_wage": model.spsb_sb_wage,
- @"flow_force": model.spsb_flow_force.length == 0 ? @0 : model.spsb_flow_force,
- @"working": model.spsb_working,
- @"cid" : model.spsb_cid,
- @"shebao_card" : model.spsb_new_card,
- @"hukou_type" : model.spsb_hukou_type,
- @"month" : spsb_changeTimeToNumber(model.spsb_start_month),
- @"nums" : model.SPSBPurchaseOrderListModel_numOfMonth,
- @"pay_for" : model.spsb_pay_for,
- @"first_sb" : model.SPSBPurchaseOrderListModel_isFirstPurchaseShebao,
- @"first_fund" : model.SPSBPurchaseOrderListModel_isFirstPurchaseFund,
- @"pay_channel" : self.spsb_orderBase.spsb_chosePay == 0 ? SPSBAlipayChannel : SPSBWeChatPayChannel, @"pay_platform": self.spsb_orderBase.spsb_chosePay == 0 ? SPSBAlipayChannel : SPSBWeChatPayChannel,
- @"couponuser_id" : self.spsb_orderBase.spsb_cashCouponIds} mutableCopy];
- [narmolParameters setValuesForKeysWithDictionary:parameters];
- return narmolParameters;
- }
- - (void)payTransferOrder {
- SPSBTransferOrderListModel *model = (SPSBTransferOrderListModel *)_spsb_data;
-
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在支付" isLogin:true url:spsb_appUrl(SPSBUrlCreateTransferOrder) urlParameters:nil parameters:^NSDictionary * _Nonnull{
- NSMutableDictionary *parameters = [@{@"user_name" : model.spsb_user_name, @"move_type" : model.spsb_move_type, @"pay_channel" : self.spsb_orderBase.spsb_chosePay == 0 ? SPSBAlipayChannel : SPSBWeChatPayChannel, @"couponuser_id" : self.spsb_orderBase.spsb_cashCouponIds} mutableCopy];
- if (![model.spsb_out_city isEqualToString:@""]) {
- [parameters setObject:model.spsb_out_city forKey:@"out_city"];
- }
- if (![model.spsb_into_city isEqualToString:@""]) {
- [parameters setObject:model.spsb_into_city forKey:@"into_city"];
- }
- return parameters;
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self payActionWithOrderType:SPSBOrderTypeTransfer serveyType:SPSBResultServeyTypeNo payData:data[@"data"] argumentData:nil];
- return nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- if (self.spsb_orderBase.spsb_payFailure) {
- self.spsb_orderBase.spsb_payFailure(error);
- }
- return nil;
- }];
- }
- #pragma mark - UI
- @end
|