只有自己看得懂的乱代码

可充值金额和不同费率,升级金额算法的需求,来回改,参照了微信,然后参考支付宝,由于都是临时想法和时间的关系,连人和代码呗折腾成这样了:

离开键盘的事件

- (void)textFieldDidEndEditing:(UITextField *)textField{

    if(textField.text.length>0 ){

        [self checkAmtValidV];

    }

    

}

//确定的事件

- (IBAction)confirmAction:(id)sender {

    

  

   [self checkAmtValidV];

}

 

//乱的不想看的事件

-(void)checkAmtValidV{

    

    

    NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:1];

    YFRegisterNormalCell *cell = (YFRegisterNormalCell *)[_mTableView cellForRowAtIndexPath:index];

    strAmt=cell.mTextField.text;

    if (strAmt.length <= 0) {

        [self alert:@"请输入金额"];

        return;

    }

    if([strAmt doubleValue]==0){

        [self alert:@"请输入大于0的金额"];

        return;

    }

    if (![YFValidateUtils validateAmount:strAmt]) {

        [self alert:@"您输入的金额有误"];

        return;

    }

   

   

//    double d=money+serviceCharge;

    

//     YFElectronicCardListModel *model=_dataArray[indexMerge];

    //交易限额

    NSDictionary *para = @{@"application":@"QueryFukaLimitQuota.Req",

                           @"userId":[USER_DEFAULT objectForKey:kUserId],

                           @"transType":@"1",

                           @"cardType":@"14",

                           

                           };

    

    [self.request requestWithDictionary:para completion:^(BOOL success, id responseData) {

        if (success) {

            double money=[strAmt doubleValue];

            int i=[responseData[@"need"] intValue];

            if(i ==1){

                

                if(availableBlanceStr.length>0){

                    

                    

                    

                    feeRate=responseData[@"feeRate"];

                    rateLeft.text = [NSString stringWithFormat:@"服务费(%@%@)",feeRate,@"%"];

                    //计算服务费

                    double serviceCharge=money*([feeRate doubleValue]/100);

                    NSString *fourPointStr=[self formatStringAfterPoint:[NSString stringWithFormat:@"%.4f",serviceCharge]];

                     serviceCharge=[fourPointStr doubleValue];

                    if(serviceCharge<=0.1){

                        

                        

                        serviceCharge=0.1;

                        if (([availableBlanceStr doubleValue]/100-serviceCharge)<=0) {

                            [self showHud:@"福卡可用余额不足"];

                            return;

                        }

                        

                    }

                   

                    if (money>[responseData[@"singleTransQuota"] doubleValue]/100) {

                        [self showHud:@"输入单笔金额超限"];

                        return ;

                    }

                    

                    if (isAllMoeny) {

                        //总金额有变化

                        YFElectronicCardListModel *modelAllMoeny=_dataArray[indexMerge];

                        money=[modelAllMoeny.balance doubleValue]/100;

                        

                        serviceCharge=money*([feeRate doubleValue]/100);

                        NSString *fourPointStr=[self formatStringAfterPoint:[NSString stringWithFormat:@"%.4f",serviceCharge]];

                        serviceCharge=[fourPointStr doubleValue];

                        //总金额

                        twoDownLab.text=[NSString stringWithFormat:@"¥%.2f",money];

                        

                        rechargeAmountRight.text = twoDownLab.text;

                        

                        //                    cell.mTextField.text= [NSString stringWithFormat:@"%.2f",(money-serviceCharge)];

                        

                        //显示出来

                        oneUpLab.text=[NSString stringWithFormat:@"服务费(%@%@)",feeRate,@"%"];

                        oneDownLab.text=@"总金额";

                       

                        

                        

                        if(serviceCharge<=0.1){

                            //服务费

                            serviceCharge=0.1;

                            twoUpLab.text=@"¥0.1";

                            //升级金额

                            upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",(money-serviceCharge)];

                        }

                        else{

                            

                            //服务费

                            twoUpLab.text=[NSString stringWithFormat:@"¥%@",fourPointStr];

                            //升级金额

                            upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",(money-serviceCharge)];

                        }

                        

                        //服务费显示

                        rateRight.text = twoUpLab.text;

                        _viewAlpha.hidden=NO;

                        _whiteView.hidden=NO;

                        [_mTableView reloadData];

                        

                    }

                    else{

                        if(money<=([availableBlanceStr doubleValue]/100-serviceCharge)){

                            [cell.mTextField resignFirstResponder];

                            

                            if (_VipArray.count>0) {

                                YFElectronicCardListModel *modelVip=_VipArray[indexVip];

                                if((money+[modelVip.balance doubleValue]/100)>5000){

                                    [self alert:@"升级后福卡VIP金额超限,不可大于5000元"];

                                    return;

                                }

                            }

                            

                            

                            

                            //显示出来

                            oneUpLab.text=[NSString stringWithFormat:@"服务费(%@%@)",feeRate,@"%"];

                            oneDownLab.text=@"总金额";

                            

                            if(serviceCharge<=0.1){

                                //服务费

                                serviceCharge=0.1;

                                twoUpLab.text=@"¥0.1";

                                //升级金额

                                //                            upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",money-serviceCharge];

                                upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",money];

                                //总金额

                                twoDownLab.text=[NSString stringWithFormat:@"¥%.2f",(money+serviceCharge)];

                            }

                            else{

                                //服务费

                                

                                twoUpLab.text=[NSString stringWithFormat:@"¥%@",fourPointStr];

                                //升级金额

                                upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",money];

                                //总金额

                                twoDownLab.text=[NSString stringWithFormat:@"¥%.2f",(money+serviceCharge)];

                            }

                            

                            

                            

                            rechargeAmountRight.text = twoDownLab.text;

                            

                            //服务费显示

                            rateRight.text = twoUpLab.text;

                            _viewAlpha.hidden=NO;

                            _whiteView.hidden=NO;

                            [_mTableView reloadData];

                        }

                        else if(([availableBlanceStr doubleValue]/100-serviceCharge)<money&&money<=([availableBlanceStr doubleValue]/100)){

                            

                            //中间的金额按照全部流程去算

                            serviceCharge=money*([feeRate doubleValue]/100);

                            NSString *fourPointStr=[self formatStringAfterPoint:[NSString stringWithFormat:@"%.4f",serviceCharge]];

                            serviceCharge=[fourPointStr doubleValue];

                            //总金额有变化

                            YFElectronicCardListModel *modelAllMoeny=_dataArray[indexMerge];

                            money=[modelAllMoeny.balance doubleValue]/100;

                            

                            

                            //总金额

                            twoDownLab.text=[NSString stringWithFormat:@"¥%.2f",money];

                            

                            rechargeAmountRight.text = twoDownLab.text;

                            

                            //                    cell.mTextField.text= [NSString stringWithFormat:@"%.2f",(money-serviceCharge)];

                            

                            //显示出来

                            oneUpLab.text=[NSString stringWithFormat:@"服务费(%@%@)",feeRate,@"%"];

                            oneDownLab.text=@"总金额";

                           

                            

                            

                            if(serviceCharge<=0.1){

                                //服务费

                                serviceCharge=0.1;

                                twoUpLab.text=@"¥0.1";

                                //升级金额

                                upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",(money-serviceCharge)];

                            }

                            else{

                                

                                //服务费

                                twoUpLab.text=[NSString stringWithFormat:@"¥%@",fourPointStr];

                                //升级金额

                                upgradeRight.text = [NSString stringWithFormat:@"¥%.2f",(money-serviceCharge)];

                            }

                            

                            //服务费显示

                            rateRight.text = twoUpLab.text;

                            _viewAlpha.hidden=NO;

                            _whiteView.hidden=NO;

                            [_mTableView reloadData];

                            

                        }

                        else if(money>[availableBlanceStr doubleValue]/100){

                            [self showHud:@"输入金额超过福卡可用余额"];

                            return;

                        }

                }

                

               

                }

              

                

            }

            

            

            

        }

    }];

    

    

   

 

    

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值