// // InMoneyViewController.swift // MTP2_iOS // // Created by zhongyuan on 2018/3/20. // Copyright © 2018年 zhongyuan.All rights reserved. // import UIKit import NVActivityIndicatorView class InMoneyViewController: BaseViewController { /// 入金金额 @IBOutlet weak var inMoneyAmountTextField: IBTextField! /// 资金账户 @IBOutlet weak var moneyAccountTextField: IBTextField! /// 银行子账户 @IBOutlet weak var bankChildAccountTextField: IBTextField! /// 子账户余额 @IBOutlet weak var childAccountFundTextField: IBTextField! /// 资金密码 @IBOutlet weak var moneyPasswordTextField: IBTextField! /// 入金手续费是否显示 @IBOutlet weak var inMoneyChargeStackView: UIStackView! /// 入金手续费 @IBOutlet weak var inMoneyChargeTextField: IBTextField! /// 账户名称 @IBOutlet weak var accountNameTextField: IBTextField! /// 签约银行 @IBOutlet weak var signingBankTextField: IBTextField! /// 入金渠道 @IBOutlet weak var inMoneyChannelTextField: IBTextField! /// 开户银行 @IBOutlet weak var registerBankTextField: IBTextField! /// 银行账户 @IBOutlet weak var bankAccountTextField: IBTextField! /// 手机号码 @IBOutlet weak var phoneNumberTextField: IBTextField! /// 持卡人姓名 @IBOutlet weak var ownerNameTextField: IBTextField! /// 入金银行卡号 @IBOutlet weak var inMoneyBankCardStackView: UIStackView! /// 入金银行卡号 @IBOutlet weak var inMoneyBankCardTextField: IBTextField! /// 备注 @IBOutlet weak var remarkTextField: IBTextField! /// 银行入金提示 @IBOutlet weak var bankInMoneyTipMessage: 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? /// private var cusBankChannel: [MoCusBankChannel]? var currentProvinceID: String? var currentCityID: String? var currentChannelType: 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 static let inMoneyChannel = 900 } 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)) } accountNameTextField.text = accountManager.moAccountBaseInfo?.accountInfo.customerName inMoneyAmountTextField.addTarget(self, action: #selector(calCusBankCharge), for: .editingChanged) bankInMoneyTipMessage.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 currentChannelType == "shyh" { self.showtipMessage() return } if !TradeControlUtils.checkAuthState(navigationController: self.navigationController) { return } if !checkValue() { return } guard let bankManager = MTP2BusinessCore.shared.bankManager, let currentBankSign = currentBankSign else { return } let inMoneyParam = MoInMoneyParam() inMoneyParam.extOperatorID = Int(Date().timeIntervalSince1970) inMoneyParam.cusBankID = currentBankSign.cusBankID inMoneyParam.tradeDate = currentBankSign.cusBankTradeDate inMoneyParam.accountCode = currentMoneyAccount! inMoneyParam.currency = currentBankSign.currency inMoneyParam.oldTaPWD = (moneyPasswordTextField.text?.bytes.sha256().toHexString().lowercased())! inMoneyParam.remark = remarkTextField.text! if (currentBankSign.bankAccountNo.contains(";")) { let array = currentBankSign.bankAccountNo.components(separatedBy: ";") inMoneyParam.bankAccoutNum = array[1] } else { inMoneyParam.bankAccoutNum = currentBankSign.bankAccountNo } inMoneyParam.bankAccoutName = currentBankSign.bankAccountName inMoneyParam.amount = Double(inMoneyAmountTextField.text ?? "0")! inMoneyParam.extend_info = getJSONExtendInfo() /// 开启Loading NVActivityIndicatorPresenter.sharedInstance.startAnimating(ActivityData(message: "正在入金...", color: UIColor.loding()), NVActivityIndicatorView.DEFAULT_FADE_IN_ANIMATION) bankManager.inMoney(param: inMoneyParam) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { NVActivityIndicatorPresenter.sharedInstance.stopAnimating(NVActivityIndicatorView.DEFAULT_FADE_OUT_ANIMATION) if isSuccess { self.showHintController(title: "提示", message: "入金成功",handler: { (_) in /// 重新请求可出资金 MTP2BusinessCore.shared.broadcastManager?.post(action: .FundationInfoReloadData, object: nil) /// 清空数据 self.clearData() }) } else { if let results = results { if results.status == 6092 { let alertController = UIAlertController(title: "请输入短信验证码", message: "验证码已发送到您的手机上,请注意查收", preferredStyle: .alert) alertController.addTextField { textField in textField.keyboardType = UIKeyboardType.numberPad } alertController.addAction(UIAlertAction(title: "提交", style: .destructive) { action in guard let textField = alertController.textFields?[0], let value = textField.text else { self.showHintController(title: "温馨提示", message: "请输入短信验证码") return } let param = MoT2bShortMsgCheckParam() param.cusBankID = currentBankSign.cusBankID param.accountCode = String(currentBankSign.accountCode) param.tradeDate = currentBankSign.cusBankTradeDate param.relatedExchTicket = results.exchTicket param.shortMsgID = value param.extOperatorID = UInt64(Date().timeIntervalSince1970) bankManager.t2bShortMsgCheck(param: param, callback: { (isSuccess, errorInfo) in if isSuccess { self.showHintController(title: "温馨提示", message: "入金成功") } else { if let errorInfo = errorInfo { let error = "\("银行信息返回")\(errorInfo.retCode):\(String(describing: errorInfo.retMsg))" self.showHintController(title: "提示", message: error) } } }) }) alertController.addAction(UIAlertAction(title: "取消", style: .cancel)) self.present(alertController, animated: true, completion: nil) } else { if results.netAddr == "" { /// 不需要跳转网页 let decp = results.centerErrMsg var error = ErrorUtils.getDesc(errorCode: results.status) ?? "未知错误类型" if decp != "" { error = "银行信息返回" + ":" + decp self.showHintController(title: "提示", message: error) } else { self.showHintController(title: "提示", message: error) } } else { /// 需要跳转网页 if let url = URL(string: results.netAddr) { UIApplication.shared.open(url) } } } } } } } } /// 清空列表数据 func clearData() { inMoneyAmountTextField.text = "" moneyPasswordTextField.text = "" bankPasswordTextField.text = "" checkCodeTextField.text = "" remarkTextField.text = "" } /// 校验数据 func checkValue() -> Bool { /// 入金金额 if let inMoneyAmount = self.inMoneyAmountTextField.text { if inMoneyAmount.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入入金金额") return false } } /// 资金密码 if let moneyPassword = self.moneyPasswordTextField.text { if moneyPassword.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入资金密码") return false } } /// 开户省份 if (regiesterProvinceTextField.superview?.isHidden)! == false { if let regiesterProvince = self.regiesterProvinceTextField.text { if regiesterProvince.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请选择开户省份") return false } } } /// 开户城市 if (regiesterCityTextField.superview?.isHidden)! == false { if let regiesterCity = self.regiesterCityTextField.text { if regiesterCity.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请选择开户城市") return false } } } /// 开户行支行号 if (regiesterBranchBankNumberTextField.superview?.isHidden)! == false { if let regiesterBranchBankNumber = self.regiesterBranchBankNumberTextField.text { if regiesterBranchBankNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入开户行支行号") return false } } } /// 开户行支行名称 if (regiesterBranchBankNameTextField.superview?.isHidden)! == false { if let regiesterBranchBankName = self.regiesterBranchBankNameTextField.text { if regiesterBranchBankName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入开户行支行名称") return false } } } /// 银行密码 if (bankPasswordTextField.superview?.isHidden)! == false { if let bankPassword = self.bankPasswordTextField.text { if bankPassword.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入银行密码") return false } } } /// 原手机号码 if (oldPhoneNumberTextField.superview?.isHidden)! == false { if let oldPhoneNumber = self.oldPhoneNumberTextField.text { if oldPhoneNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", 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: "提示", message: "请输入验证码") return false } } } /// 男性 if (checkMenButton.superview?.superview?.isHidden)! == false { if !self.checkMenButton.isSelected && !self.checkWomenButton.isSelected{ self.showHintController(title: "提示", message: "请选择性别") return false } } /// 法人姓名 if (legalPersonNameTextField.superview?.isHidden)! == false { if let legalPersonName = self.legalPersonNameTextField.text { if legalPersonName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入法人姓名") return false } } } /// 法人证件类型 if (legalPersonalIDcardTypeTextField.superview?.isHidden)! == false { if let legalPersonalIDcardType = self.legalPersonalIDcardTypeTextField.text { if legalPersonalIDcardType.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请选择法人证件类型") return false } } } /// 法人证件号码 if (legalPersonalIDcardNumberField.superview?.isHidden)! == false { if let legalPersonalIDcardNumber = self.legalPersonalIDcardNumberField.text { if legalPersonalIDcardNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入法人证件号码") return false } } } /// 经办人姓名 if (agentNameTextField.superview?.isHidden)! == false { if let agentName = self.agentNameTextField.text { if agentName.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入经办人姓名") return false } } } /// 经办人证件类型 if (agentIDcardTypeTextField.superview?.isHidden)! == false { if let agentIDcardType = self.agentIDcardTypeTextField.text { if agentIDcardType.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请选择经办人证件类型") return false } } } /// 经办人证件号码 if (agentIDcardNumberTextField.superview?.isHidden)! == false { if let agentIDcardNumber = self.agentIDcardNumberTextField.text { if agentIDcardNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入经办人证件号码") return false } } } /// 所属会员代码 if (itsMemberCodeTextField.superview?.isHidden)! == false { if let itsMemberCode = self.itsMemberCodeTextField.text { if itsMemberCode.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入所属会员代码") return false } } } /// 法人联系号码 if (legalContactNumberTextField.superview?.isHidden)! == false { if let legalContactNumber = self.legalContactNumberTextField.text { if legalContactNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入法人联系号码") return false } } } /// 经办人联系号码 if (agentContactNumberTextField.superview?.isHidden)! == false { if let agentContactNumber = self.agentContactNumberTextField.text { if agentContactNumber.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { self.showHintController(title: "提示", message: "请输入经办人联系号码") return false } } } return true } /// 组装扩展信息 /// /// - 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 if currentChannelType == "tlzf" { dict["channel_type"] = "tlzf" dict["mobile_tel"] = phoneNumberTextField.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 } } // MARK: - UITextFieldDelegate extension InMoneyViewController: 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) accountManager.setCurrentTAAccountInfo(moTaacount: accountManager.getTaAccountInfo(accountId: Int(value)!)!) } } } else { self.showHintController(title: "提示", 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: "提示", message: "没有可选的签约银行") } return false case TAG.inMoneyChannel: if self.signingBankTextField.text == "" { self.showHintController(title: "温馨提示", message: "请先选择签约银行") return false } var titleArray = [String]() if let cusBankChannel = self.cusBankChannel { titleArray = cusBankChannel.compactMap({ $0.channelName }) } if titleArray.count > 0 { self.showPopupsController(title: "请选择", message: nil, titleArray: titleArray) { (value: String, selectedRow: Int, _) in self.inMoneyChannelTextField.text = value self.currentChannelType = self.cusBankChannel?[selectedRow].channelType if let cusBankChannel = self.cusBankChannel, cusBankChannel[selectedRow].channelType == "shyh" { self.showtipMessage() self.phoneNumberTextField.isEnabled = false } else { self.phoneNumberTextField.isEnabled = true } } } else { self.showHintController(title: "提示", 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 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 { self.showErrorMessgae(error: errorInfo) } } } } /// 查询扩展信息 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 model.bankchildaccount == "" { bankChildAccountTextField.superview?.isHidden = true childAccountFundTextField.superview?.isHidden = true } else { bankChildAccountTextField.text = model.bankchildaccount _anim?.startAnimating() bankManager.queryAccInfos(cusBankid: model.cusBankID, tradeDate: model.cusBankTradeDate, accountCode: String(model.accountCode), bankChildAccount: model.bankchildaccount, bankChildAccountName: "", queryType: "2") { (isSuccess, errorInfo, bankAccountData) in DispatchQueue.main.async { self._anim?.stopAnimating() if isSuccess { self.childAccountFundTextField.text = String(bankAccountData?.canUseAmount ?? 0) } } } } if let cusbankParam = bankManager.cusbankInfos?.first(where: { $0.cusbankid == model.cusBankID }) { if cusbankParam.caninamount != 1 { submitButton.isHidden = true } } _anim?.startAnimating() let group = DispatchGroup() group.enter() let userType = accountInfo.userInfoType == 1 ? EBank_BankAccountType.BANK_BANKACCOUNTTYPE_PRIVATE.rawValue : EBank_BankAccountType.BANK_BANKACCOUNTTYPE_PUBLIC.rawValue /// 查询 bankManager.queryQueryBank_CusBankCharge(cusBankID: model.cusBankID, outOrIn: 2, userType: userType) { (isSuccess, errorInfo, results) in DispatchQueue.main.async { group.leave() if isSuccess { if let currentCusBankCharge = results?.first { self.currentCusBankCharge = currentCusBankCharge self.calCusBankCharge() } } else { self.showErrorMessgae(error: errorInfo) } } } // group.enter() // bankManager.queryCusBankChannel(cusBankID: model.cusBankID, outOrIn: 2) { (isSuccess, errorInfo, results) in // DispatchQueue.main.async { // group.leave() // if isSuccess { // self.cusBankChannel = results // } else { // self.showErrorMessgae(error: errorInfo) // } // } // } group.notify(queue: DispatchQueue.main) { self._anim?.stopAnimating() } } } /// 计算入金手续费 /** 统一: 1.比例:1.手续费=出入金金额*收费值 2.手续费<单笔最小,手续费=单笔最小,3.手续费>单笔最大,手续费=单笔最大 2.固定:1.手续费=收费值 区间: 1.比例:ps:首先判断出入金金额在哪个区间范围内,取区间内收费值计算,若无则不收取服务费。 1.手续费=出入金金额*收费值 2.手续费<单笔最小,手续费=单笔最小,3.手续费>单笔最大,手续费=单笔最大 2.固定:ps:首先判断出入金金额在哪个区间范围内,取区间内收费值值计算,若无则不收取服务费。 1.手续费=收费值 */ @objc func calCusBankCharge() { /// 没有就不用算了 guard let cusBankCharge = currentCusBankCharge else { return } /// 入金金额 let inMoney = Double(inMoneyAmountTextField.text!) ?? 0.0 var tempCharge = 0.0 if cusBankCharge.ChargeType == 1 { /// 手续费收取类型 - 1:统一 2:区间 if cusBankCharge.ChargeAlgorithm == 1 { /// 手续费收取方式 - 1:比率 2:固定 [统一 ] tempCharge = cusBankCharge.ChargeValue * inMoney if tempCharge > cusBankCharge.SingleMax { tempCharge = cusBankCharge.SingleMax } else if tempCharge < cusBankCharge.SingleMin { tempCharge = cusBankCharge.SingleMin } } else if cusBankCharge.ChargeAlgorithm == 2 { tempCharge = inMoney > 0 ? cusBankCharge.ChargeValue : 0.0 } } else if cusBankCharge.ChargeType == 2 { if let moCusBankChargeDetails = cusBankCharge.CusBankChargeDetail.first(where: { $0.RangeMax >= inMoney && $0.RangeMin <= inMoney }) { if moCusBankChargeDetails.ChargeAlgorithm == 1 { /// 手续费收取方式 - 1:比率 2:固定 [统一 ] tempCharge = moCusBankChargeDetails.ChargeValue * inMoney if tempCharge > cusBankCharge.SingleMax { tempCharge = cusBankCharge.SingleMax } else if tempCharge < cusBankCharge.SingleMin { tempCharge = cusBankCharge.SingleMin } } else if moCusBankChargeDetails.ChargeAlgorithm == 2 { tempCharge = inMoney > 0 ? cusBankCharge.ChargeValue : 0.0 } } } inMoneyChargeTextField.text = String(format: "%.2f", tempCharge) } func showtipMessage() { if let config = MTP2BusinessCore.shared.accountManager?.configInfo, let tipMessage = config["302"]?.paramValue { let regex = try! NSRegularExpression(pattern: "#[\\w]+#", options: []) let results = regex.stringByReplacingMatches(in: tipMessage, options: [], range: NSMakeRange(0, tipMessage.count), withTemplate: MTP2BusinessCore.shared.bankManager?.moBankSign?.bankSign.first?.bankchildaccount ?? "--") self.showHintController(title: "上海银行入金提示", message: results) } } } // MARK: - PageChangeDelegate extension InMoneyViewController: PageChangeDelegate { func didShow() { moveView(views: [inMoneyAmountTextField, moneyPasswordTextField, phoneNumberTextField, remarkTextField, regiesterBranchBankNumberTextField, regiesterBranchBankNameTextField, bankPasswordTextField, oldPhoneNumberTextField, checkCodeTextField, legalPersonNameTextField, legalPersonalIDcardNumberField, itsMemberCodeTextField, legalContactNumberTextField, agentContactNumberTextField]) } func didHide() { //do something } }