// // OutMoneyViewController.swift // MTP2_iOS // // Created by zhongyuan on 2018/3/20. // Copyright © 2018年 zhongyuan.All rights reserved. // import UIKit import NVActivityIndicatorView class OutMoneyViewController: BaseViewController { /// 出金金额 @IBOutlet weak var outMoneyAmountTextField: IBTextField! /// 可取资金 @IBOutlet weak var canUseMoneyTextField: IBTextField! /// 资金账户 @IBOutlet weak var moneyAccountTextField: IBTextField! /// 资金密码 @IBOutlet weak var moneyPasswordTextField: IBTextField! /// 出金手续费 @IBOutlet weak var outMoneyChargeTextField: IBTextField! /// 账户名称 @IBOutlet weak var accountNameTextField: IBTextField! /// 签约银行 @IBOutlet weak var signingBankTextField: IBTextField! /// 开户银行 @IBOutlet weak var registerBankTextField: IBTextField! /// 银行账户 @IBOutlet weak var bankAccountTextField: IBTextField! /// 手机号码 @IBOutlet weak var phoneNumberTextField: IBTextField! /// 备注 @IBOutlet weak var remarkTextField: IBTextField! /// 银行出金提示 @IBOutlet weak var bankOutMoneyTipMessage: UILabel! /// 提交按钮 @IBOutlet weak var submitButton: UIButton! //MARK: 扩展信息 @IBOutlet weak var splitView: UIView! /// 开户省份 @IBOutlet weak var regiesterProvinceTextField: IBTextField! /// 开户城市 @IBOutlet weak var regiesterCityTextField: IBTextField! /// 开户行支行号 @IBOutlet weak var regiesterBranchBankNumberTextField: IBTextField! /// 开户行支行名称 @IBOutlet weak var regiesterBranchBankNameTextField: IBTextField! /// 银行密码 @IBOutlet weak var bankPasswordTextField: IBTextField! /// 原手机号码 @IBOutlet weak var oldPhoneNumberTextField: IBTextField! /// 验证码 @IBOutlet weak var checkCodeTextField: IBTextField! /// 男性 @IBOutlet weak var checkMenButton: UIButton! /// 女性 @IBOutlet weak var checkWomenButton: UIButton! /// 法人姓名 @IBOutlet weak var legalPersonNameTextField: IBTextField! /// 法人证件类型 @IBOutlet weak var legalPersonalIDcardTypeTextField: IBTextField! /// 法人证件号码 @IBOutlet weak var legalPersonalIDcardNumberField: IBTextField! /// 经办人姓名 @IBOutlet weak var agentNameTextField: IBTextField! /// 经办人证件类型 @IBOutlet weak var agentIDcardTypeTextField: IBTextField! /// 经办人证件号码 @IBOutlet weak var agentIDcardNumberTextField: IBTextField! /// 所属会员代码 @IBOutlet weak var itsMemberCodeTextField: IBTextField! /// 法人联系号码 @IBOutlet weak var legalContactNumberTextField: IBTextField! /// 经办人联系号码 @IBOutlet weak var agentContactNumberTextField: IBTextField! /// 临时变量,当前资金账号 private var currentMoneyAccount: String? /// 临时变量,当前签约银行 private var currentBankSign: MoBankAccountSign? /// 托管银行手续费配置表 private var currentCusBankCharge: MoCusBankCharge? var currentProvinceID: String? var currentCityID: String? /// 当前页面索引 var pageIndex: Int? struct TAG { static let moneyAccount = 100 static let regiesterProvince = 200 static let regiesterCity = 300 static let legalPersonalIDcardType = 400 static let agentIDcardType = 500 static let men = 600 static let women = 700 static let signingBank = 800 } override func viewDidLoad() { super.viewDidLoad() addLoadingView() initData() } // MARK: - 初始化相关 func initData() { /// 数据异常 guard let accountManager = MTP2BusinessCore.shared.accountManager else { return } if let accountId = accountManager.getTaAccountInfoList()?.first?.accountId { moneyAccountTextField.text = String(accountId) currentMoneyAccount = String(accountId) queryBankSign(accountID: String(accountId)) queryCanUseMoney(accountID: String(accountId)) } accountNameTextField.text = accountManager.moAccountBaseInfo?.accountInfo.customerName outMoneyAmountTextField.addTarget(self, action: #selector(calCusBankCharge), for: .editingChanged) if let configInfo = accountManager.configInfo, let signTime = configInfo["012"]?.paramValue, let outTime = configInfo["013"]?.paramValue { bankOutMoneyTipMessage.text = "银行出金时间段:\(signTime) - \(outTime)" } else { bankOutMoneyTipMessage.isHidden = true } } // MARK: - 交互相关 @IBAction func selectSex(_ sender: UIButton) { if sender.currentTitle == "男" && !sender.isSelected{ sender.isSelected = true checkWomenButton.isSelected = false } if sender.currentTitle == "女" && !sender.isSelected{ sender.isSelected = true checkMenButton.isSelected = false } } /// 忘记密码 @IBAction func forgetPassword(_ sender: UIButton) { let nav = UIStoryboard(name: "ResetPwd", bundle: nil).instantiateViewController(withIdentifier: "ResetPwdNav") UIApplication.shared.keyWindow?.rootViewController?.present(nav, animated: true, completion: nil) } /// 出金提交 @IBAction func onclickSubmitButton(_ sender: UIButton) { if !TradeControlUtils.checkAuthState(navigationController: self.navigationController) { return } if !checkValue() { return } guard let bankManager = MTP2BusinessCore.shared.bankManager, let accountManager = MTP2BusinessCore.shared.accountManager, let currentBankSign = currentBankSign else { return } let outMoneyParam = MoOutMoneyParam() outMoneyParam.extOperatorID = Int(Date().timeIntervalSince1970) outMoneyParam.accountCode = currentMoneyAccount! outMoneyParam.cusBankID = currentBankSign.cusBankID outMoneyParam.currency = currentBankSign.currency if let userType = accountManager.moAccountBaseInfo?.accountInfo.userType { outMoneyParam.accountType = userType } outMoneyParam.bankAccoutName = currentBankSign.bankAccountName outMoneyParam.remark = remarkTextField.text! if (currentBankSign.bankAccountNo.contains(";")) { let array = currentBankSign.bankAccountNo.components(separatedBy: ";") outMoneyParam.bankAccoutNum = array[1] } else { outMoneyParam.bankAccoutNum = currentBankSign.bankAccountNo } outMoneyParam.appDateTime = currentBankSign.cusBankTradeDate outMoneyParam.amount = Double(outMoneyAmountTextField.text!)! outMoneyParam.oldTaPWD = (moneyPasswordTextField.text?.bytes.sha256().toHexString().lowercased())! outMoneyParam.identifyCode = checkCodeTextField.text! outMoneyParam.extend_info = getJSONExtendInfo() // 开启Loading NVActivityIndicatorPresenter.sharedInstance.startAnimating(ActivityData(message: "正在出金...", color: UIColor.loding()), NVActivityIndicatorView.DEFAULT_FADE_IN_ANIMATION) bankManager.outMoney(param: outMoneyParam) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { NVActivityIndicatorPresenter.sharedInstance.stopAnimating(NVActivityIndicatorView.DEFAULT_FADE_OUT_ANIMATION) if isSuccess { self.showHintController(title: "tips".localized, message: "出金成功",handler: { (_) in /// 重新请求可出资金 MTP2BusinessCore.shared.broadcastManager?.post(action: .FundationInfoReloadData, object: nil) /// 更新可出资金 self.queryCanUseMoney(accountID: self.currentMoneyAccount!) /// 清空数据 self.clearData() }) } else { if let results = results { if results.netAddr == "" { /// 不需要跳转网页 let decp = results.centerErrMsg var error = ErrorUtils.getDesc(errorCode: results.status) ?? "未知错误类型" if decp != "" { error = "银行信息返回" + ":" + decp self.showHintController(title: "tips".localized, message: error) } else { self.showHintController(title: "tips".localized, message: error) } } else { /// 需要跳转网页 if let url = URL(string: results.netAddr) { /// 根据iOS系统版本,分别处理 UIApplication.shared.open(url) } } } } } } } /// 组装扩展信息 /// /// - Returns: json串 func getJSONExtendInfo() -> String { var dict: [String: Any] = [:] dict["verify_code"] = checkCodeTextField.text dict["bank_password"] = bankPasswordTextField.text dict["sex"] = getSex() dict["legal_name"] = legalPersonNameTextField.text dict["legal_cert_type"] = legalPersonalIDcardTypeTextField.text dict["legal_cert_code"] = legalPersonalIDcardNumberField.text dict["agent_name"] = agentNameTextField.text dict["agent_cert_type"] = agentIDcardTypeTextField.text dict["agent_cert_code"] = agentIDcardNumberTextField.text dict["org_mobile"] = oldPhoneNumberTextField.text dict["member_code"] = itsMemberCodeTextField.text dict["legal_contact"] = legalContactNumberTextField.text dict["agent_contact"] = agentContactNumberTextField.text dict["bank_branch_name"] = regiesterBranchBankNameTextField.text //json 的可用性判断 if !JSONSerialization.isValidJSONObject(dict) { dPrint("不能转化") return "" } //json 字符串转换为data guard let data = try? JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted) else { return "" } //data 转为字符串 let jsonstr = String(data: data, encoding: .utf8) return jsonstr! } /// 获取选择的性别 /// /// - Returns: 男女 func getSex() -> Int { if checkMenButton.isSelected { return ESex.SEX_MALE.rawValue } return ESex.SEX_FEMALE.rawValue } /// 清空列表数据 func clearData() { outMoneyAmountTextField.text = "" moneyPasswordTextField.text = "" bankPasswordTextField.text = "" checkCodeTextField.text = "" remarkTextField.text = "" } /// 校验数据 func checkValue() -> Bool { /// 出金金额 if let outMoneyAmount = self.outMoneyAmountTextField.text { if outMoneyAmount.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入出金金额", handler: nil) return false } if let outMoneyAmount = Double(outMoneyAmount), let canUserMoney = Double(canUseMoneyTextField.text!) { if outMoneyAmount > canUserMoney { self.showHintController(title: "tips".localized, message: "出金金额不得大于可取资金", handler: nil) return false } } else { self.showHintController(title: "tips".localized, message: "出金金额格式不正确") return false } } /// 资金密码 if let moneyPassword = self.moneyPasswordTextField.text { if moneyPassword.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入资金密码", handler: nil) return false } } /// 开户省份 if (regiesterProvinceTextField.superview?.isHidden)! == false { if let regiesterProvince = self.regiesterProvinceTextField.text { if regiesterProvince.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请选择开户省份") return false } } } /// 开户城市 if (regiesterCityTextField.superview?.isHidden)! == false { if let regiesterCity = self.regiesterCityTextField.text { if regiesterCity.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请选择开户城市") return false } } } /// 开户行支行号 if (regiesterBranchBankNumberTextField.superview?.isHidden)! == false { if let regiesterBranchBankNumber = self.regiesterBranchBankNumberTextField.text { if regiesterBranchBankNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入开户行支行号") return false } } } /// 开户行支行名称 if (regiesterBranchBankNameTextField.superview?.isHidden)! == false { if let regiesterBranchBankName = self.regiesterBranchBankNameTextField.text { if regiesterBranchBankName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入开户行支行名称") return false } } } /// 银行密码 if (bankPasswordTextField.superview?.isHidden)! == false { if let bankPassword = self.bankPasswordTextField.text { if bankPassword.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入银行密码") return false } } } /// 原手机号码 if (oldPhoneNumberTextField.superview?.isHidden)! == false { if let oldPhoneNumber = self.oldPhoneNumberTextField.text { if oldPhoneNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入原手机号码") return false } } } /// 验证码 if (checkCodeTextField.superview?.superview?.isHidden)! == false { if let checkCode = self.checkCodeTextField.text { if checkCode.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入验证码") return false } } } /// 男性 if (checkMenButton.superview?.superview?.isHidden)! == false { if !self.checkMenButton.isSelected && !self.checkWomenButton.isSelected{ self.showHintController(title: "tips".localized, message: "请选择性别") return false } } /// 法人姓名 if (legalPersonNameTextField.superview?.isHidden)! == false { if let legalPersonName = self.legalPersonNameTextField.text { if legalPersonName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入法人姓名") return false } } } /// 法人证件类型 if (legalPersonalIDcardTypeTextField.superview?.isHidden)! == false { if let legalPersonalIDcardType = self.legalPersonalIDcardTypeTextField.text { if legalPersonalIDcardType.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请选择法人证件类型") return false } } } /// 法人证件号码 if (legalPersonalIDcardNumberField.superview?.isHidden)! == false { if let legalPersonalIDcardNumber = self.legalPersonalIDcardNumberField.text { if legalPersonalIDcardNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入法人证件号码") return false } } } /// 经办人姓名 if (agentNameTextField.superview?.isHidden)! == false { if let agentName = self.agentNameTextField.text { if agentName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入经办人姓名") return false } } } /// 经办人证件类型 if (agentIDcardTypeTextField.superview?.isHidden)! == false { if let agentIDcardType = self.agentIDcardTypeTextField.text { if agentIDcardType.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请选择经办人证件类型") return false } } } /// 经办人证件号码 if (agentIDcardNumberTextField.superview?.isHidden)! == false { if let agentIDcardNumber = self.agentIDcardNumberTextField.text { if agentIDcardNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入经办人证件号码") return false } } } /// 所属会员代码 if (itsMemberCodeTextField.superview?.isHidden)! == false { if let itsMemberCode = self.itsMemberCodeTextField.text { if itsMemberCode.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入所属会员代码") return false } } } /// 法人联系号码 if (legalContactNumberTextField.superview?.isHidden)! == false { if let legalContactNumber = self.legalContactNumberTextField.text { if legalContactNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入法人联系号码") return false } } } /// 经办人联系号码 if (agentContactNumberTextField.superview?.isHidden)! == false { if let agentContactNumber = self.agentContactNumberTextField.text { if agentContactNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "tips".localized, message: "请输入经办人联系号码") return false } } } return true } } // MARK: - UITextFieldDelegate extension OutMoneyViewController: UITextFieldDelegate { func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() return true } func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { switch textField.tag { case TAG.moneyAccount: guard let accountManager = MTP2BusinessCore.shared.accountManager else { return true } let titleArray = accountManager.getTaAccountInfoList()?.compactMap({ return String($0.accountId) }) ?? [] if titleArray.count > 0 { self.showPopupsController(title: "选择资金账户", message: nil, titleArray: titleArray) { (value: String, selectedRow: Int, _) in if self.currentMoneyAccount != value { self.currentMoneyAccount = value self.moneyAccountTextField.text = value self.queryBankSign(accountID: value) self.queryCanUseMoney(accountID: value) } } } else { self.showHintController(title: "tips".localized, message: "没有可选的资金账户") } return false case TAG.signingBank: guard let bankManager = MTP2BusinessCore.shared.bankManager else { return true } var titleArray = [String]() if let bankSign = bankManager.moBankSign { titleArray = bankSign.bankSign.map({ (model) -> String in return String(model.cusBankName) }) } if titleArray.count > 0 { self.showPopupsController(title: "选择签约银行", message: nil, titleArray: titleArray) { (value: String, selectedRow: Int, _) in if self.currentBankSign?.cusBankName != value { self.signingBankTextField.text = value self.setupSignBank(bankSign: bankManager.moBankSign?.bankSign[selectedRow]) } } } else { self.showHintController(title: "tips".localized, message: "没有可选的签约银行") } return false case TAG.regiesterProvince: guard let bankManager = MTP2BusinessCore.shared.bankManager else{ return true } let completeBlock = { (results: [MoBankProvince]?) in let titleArray = results?.map({ (model) -> String in return model.bankprovincename }) self.showPopupsController(title: "选择省份", message: nil, titleArray: titleArray!, clickBlock: { (value, rowNum, _) in self.regiesterProvinceTextField.text = value if self.currentProvinceID != results?[rowNum].bankprovinceid { self.currentProvinceID = results?[rowNum].bankprovinceid bankManager.queryBankCity(provinceID: self.currentProvinceID!, callback: { (isSuccess, errorInfo, results) in if isSuccess { } else { self.showErrorMessgae(error: errorInfo) } }) } }) } if let moBankProvice = bankManager.moBankProvice { completeBlock(moBankProvice) } else { _anim?.startAnimating() bankManager.queryBankProvince { (isSuccess, errorInfo, results) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { completeBlock(results) } else { self.showErrorMessgae(error: errorInfo) } } } } return false case TAG.regiesterCity: guard let bankManager = MTP2BusinessCore.shared.bankManager else{ return true } if let moBankCity = bankManager.moBankCity { let titleArray = moBankCity.map({ (model) -> String in return model.bankcityname }) self.showPopupsController(title: "选择市", message: nil, titleArray: titleArray, clickBlock: { (value, rowNum, _) in self.regiesterCityTextField.text = value self.currentCityID = moBankCity[rowNum].bankcityid }) } return false case TAG.legalPersonalIDcardType: var titleArray = [String]() for i in 0...22 { titleArray.append(ECardTypeStringValue(CardType(rawValue: i))) } self.showPopupsController(title: "选择法人证件类型", message: nil, titleArray: titleArray, clickBlock: { (value, _ , _) in self.legalPersonalIDcardTypeTextField.text = value }) return false case TAG.agentIDcardType: var titleArray = [String]() for i in 0...22 { titleArray.append(ECardTypeStringValue(CardType(rawValue: i))) } self.showPopupsController(title: "选择经办人证件类型", message: nil, titleArray: titleArray, clickBlock: { (value, _ , _) in self.agentIDcardTypeTextField.text = value }) return false default: break } return true } /// 查询可取资金 func queryCanUseMoney(accountID: String) { guard let bankManager = MTP2BusinessCore.shared.bankManager, let accountId = UInt64(accountID) else { return } _anim?.startAnimating() bankManager.accountFundInfo(accountID: accountId, queryBitMask: 3) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { guard let results = results else{ return } self.canUseMoneyTextField.text = String(results.availableOutMoney) }else { /// 查询失败 } } } } /// 查询已签约信息 func queryBankSign(accountID: String) { guard let bankManager = MTP2BusinessCore.shared.bankManager, let accountId = UInt64(accountID) else { return } _anim?.startAnimating() bankManager.bankSign(accountId: accountId, cusbankId: "") {(isSuccess, errorInfo, results) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { self.setupSignBank(bankSign: results?.bankSign.first) }else { /// 查询失败 } } } } /// 查询扩展信息 func queryExpandInfo(cusBankId: String) { guard let bankManager = MTP2BusinessCore.shared.bankManager else { return } _anim?.startAnimating() bankManager.queryBankExtendInfo(cusBankId: cusBankId, type: 2) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { if let results = results, results.count > 0 { results.forEach({ (model) in if let tag = Int(model.fieldid), let view = self.view.viewWithTag(tag) { view.isHidden = false } }) self.splitView.isHidden = false } else { self.splitView.isHidden = true } } else { self.showErrorMessgae(error: errorInfo) } } } } /// 选择了签约银行要做的事情 func setupSignBank(bankSign: MoBankAccountSign?) { guard let bankManager = MTP2BusinessCore.shared.bankManager, let accountManager = MTP2BusinessCore.shared.accountManager, let accountInfo = accountManager.moAccountBaseInfo?.accountInfo else { return } if let model = bankSign { signingBankTextField.text = model.cusBankName registerBankTextField.text = model.bankName currentBankSign = model /// 若是加密字符串需要取分号前面的字符 if model.bankAccountNo.contains(";") { let index = model.bankAccountNo.firstIndex(of: ";") let bankAccountNo = model.bankAccountNo.prefix(upTo: index!) bankAccountTextField.text = bankAccountNo.description }else { bankAccountTextField.text = model.bankAccountNo } phoneNumberTextField.text = model.mobilePhoneDisp queryExpandInfo(cusBankId: model.cusBankID) if let cusbankParam = bankManager.cusbankInfos?.first(where: { $0.cusbankid == model.cusBankID }) { if cusbankParam.canoutamount != 1 { submitButton.isHidden = true } } let userType = accountInfo.userInfoType == 1 ? EBank_BankAccountType.BANK_BANKACCOUNTTYPE_PRIVATE.rawValue : EBank_BankAccountType.BANK_BANKACCOUNTTYPE_PUBLIC.rawValue _anim?.startAnimating() // 查询 bankManager.queryQueryBank_CusBankCharge(cusBankID: model.cusBankID, outOrIn: 1, userType: userType) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { if let currentCusBankCharge = results?.first { self.currentCusBankCharge = currentCusBankCharge self.calCusBankCharge() } } else { self.showErrorMessgae(error: errorInfo) } } } } } /// 计算出金手续费 /** 统一: 1.比例:1.手续费=出入金金额*收费值 2.手续费<单笔最小,手续费=单笔最小,3.手续费>单笔最大,手续费=单笔最大 2.固定:1.手续费=收费值 区间: 1.比例:ps:首先判断出入金金额在哪个区间范围内,取区间内收费值计算,若无则不收取服务费。 1.手续费=出入金金额*收费值 2.手续费<单笔最小,手续费=单笔最小,3.手续费>单笔最大,手续费=单笔最大 2.固定:ps:首先判断出入金金额在哪个区间范围内,取区间内收费值值计算,若无则不收取服务费。 1.手续费=收费值 */ @objc func calCusBankCharge() { // 没有就不用算了 guard let cusBankCharge = currentCusBankCharge else { return } // 入金金额 let outMoney = Double(outMoneyAmountTextField.text!) ?? 0.0 var tempCharge = 0.0 if cusBankCharge.ChargeType == 1 { // 手续费收取类型 - 1:统一 2:区间 if cusBankCharge.ChargeAlgorithm == 1 { // 手续费收取方式 - 1:比率 2:固定 [统一 ] tempCharge = cusBankCharge.ChargeValue * outMoney if tempCharge > cusBankCharge.SingleMax { tempCharge = cusBankCharge.SingleMax } else if tempCharge < cusBankCharge.SingleMin { tempCharge = cusBankCharge.SingleMin } } else if cusBankCharge.ChargeAlgorithm == 2 { tempCharge = outMoney > 0 ? cusBankCharge.ChargeValue : 0.0 } } else if cusBankCharge.ChargeType == 2 { if let moCusBankChargeDetails = cusBankCharge.CusBankChargeDetail.first(where: { $0.RangeMax >= outMoney && $0.RangeMin <= outMoney }) { if moCusBankChargeDetails.ChargeAlgorithm == 1 { // 手续费收取方式 - 1:比率 2:固定 [统一 ] tempCharge = moCusBankChargeDetails.ChargeValue * outMoney if tempCharge > cusBankCharge.SingleMax { tempCharge = cusBankCharge.SingleMax } else if tempCharge < cusBankCharge.SingleMin { tempCharge = cusBankCharge.SingleMin } } else if moCusBankChargeDetails.ChargeAlgorithm == 2 { tempCharge = outMoney > 0 ? cusBankCharge.ChargeValue : 0.0 } } } outMoneyChargeTextField.text = String(format: "%.2f", tempCharge) } } // MARK: - PageChangeDelegate extension OutMoneyViewController: PageChangeDelegate { func didShow() { /// 异常 guard let accountManager = MTP2BusinessCore.shared.accountManager, let accountId = accountManager.getCurrentTAAccountInfo()?.accountId else { return } /// queryCanUseMoney queryCanUseMoney(accountID: String(accountId)) /// moveView moveView(views: [outMoneyAmountTextField, moneyPasswordTextField, phoneNumberTextField, remarkTextField, regiesterBranchBankNumberTextField, regiesterBranchBankNameTextField, bankPasswordTextField, oldPhoneNumberTextField, checkCodeTextField, legalPersonNameTextField, legalPersonalIDcardNumberField, itsMemberCodeTextField, legalContactNumberTextField, agentContactNumberTextField]) } func didHide() { //do something } }