|
@ -89,7 +89,6 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
private let bankModel = BehaviorSubject<[Account]>(value: []) |
|
|
private let bankModel = BehaviorSubject<[Account]>(value: []) |
|
|
private let fixedModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let fixedModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let dataOnlyModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let dataOnlyModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private var accountType: String? |
|
|
|
|
|
private var accounts: Account? |
|
|
private var accounts: Account? |
|
|
|
|
|
|
|
|
func transform(input: Input) -> Output { |
|
|
func transform(input: Input) -> Output { |
|
@ -111,7 +110,6 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
.drive(onNext: { |
|
|
.drive(onNext: { |
|
|
let fintechUseNumber = $0?.fintechUseNumber ?? "" |
|
|
let fintechUseNumber = $0?.fintechUseNumber ?? "" |
|
|
let type = $0?.type ?? "autodebit" |
|
|
let type = $0?.type ?? "autodebit" |
|
|
self.accountType = type |
|
|
|
|
|
self.progressLinker.onNext(true) |
|
|
self.progressLinker.onNext(true) |
|
|
self.interactor?.fetchBalanceForPowerCall(type: type, fintechUseNumber: fintechUseNumber) |
|
|
self.interactor?.fetchBalanceForPowerCall(type: type, fintechUseNumber: fintechUseNumber) |
|
|
}).disposed(by: disposeBag) |
|
|
}).disposed(by: disposeBag) |
|
@ -131,20 +129,20 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
guard let index = tag, model.count > 0 else { return nil } |
|
|
guard let index = tag, model.count > 0 else { return nil } |
|
|
return model[index] |
|
|
return model[index] |
|
|
}, |
|
|
}, |
|
|
input.selectedCarrierType.asObservable(), |
|
|
|
|
|
input.selectedCarrierPlan.asObservable(), |
|
|
input.selectedCarrierPlan.asObservable(), |
|
|
input.selectedDataOnlyType.asObservable(), |
|
|
input.selectedDataOnlyType.asObservable(), |
|
|
selectedPaymentMode.asObservable() |
|
|
|
|
|
|
|
|
selectedPaymentMode.asObservable(), |
|
|
|
|
|
getBalanceLinker.asObservable() |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
let carrierPlanModel = input.selectedCarrierType.map { $0?.subCardInfo ?? [] } |
|
|
let carrierPlanModel = input.selectedCarrierType.map { $0?.subCardInfo ?? [] } |
|
|
let detailCarrierPlanModel = input.selectedCarrierPlan.map { $0?.planInfo } |
|
|
let detailCarrierPlanModel = input.selectedCarrierPlan.map { $0?.planInfo } |
|
|
|
|
|
|
|
|
let isEnableNext = combinedInput |
|
|
let isEnableNext = combinedInput |
|
|
.map { balance, _, type, priceModel, _, carrierPlan, dataOnlyType, selectPaymentType -> Status in |
|
|
|
|
|
|
|
|
.map { balance, _, type, priceModel, carrierPlan, dataOnlyType, selectedPaymentType, autoDebitBalance -> Status in |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if selectPaymentType?.type == "wallet" { |
|
|
|
|
|
|
|
|
if selectedPaymentType?.type == "wallet" { |
|
|
|
|
|
|
|
|
switch type { |
|
|
switch type { |
|
|
case .regular: |
|
|
case .regular: |
|
@ -169,12 +167,45 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
return (true, amount <= balance) |
|
|
return (true, amount <= balance) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if selectedPaymentType?.type == "autodebit", |
|
|
|
|
|
autoDebitBalance?.balance != nil |
|
|
|
|
|
{ |
|
|
|
|
|
switch type { |
|
|
|
|
|
case .regular: |
|
|
|
|
|
guard |
|
|
|
|
|
let paymentAmount = priceModel?.price, |
|
|
|
|
|
let amount = Int(paymentAmount), |
|
|
|
|
|
let setAutoDebitBalance = autoDebitBalance?.balance, |
|
|
|
|
|
let autoDebitAmount = Int(setAutoDebitBalance) else { return (false, false) } |
|
|
|
|
|
|
|
|
|
|
|
return (true, amount <= autoDebitAmount) |
|
|
|
|
|
|
|
|
|
|
|
case .fixed: |
|
|
|
|
|
guard |
|
|
|
|
|
let paymentAmount = carrierPlan?.facePrice, |
|
|
|
|
|
let amount = Int(paymentAmount), |
|
|
|
|
|
let setAutoDebitBalance = autoDebitBalance?.balance, |
|
|
|
|
|
let autoDebitAmount = Int(setAutoDebitBalance) else { return (false, false) } |
|
|
|
|
|
|
|
|
|
|
|
return (true, amount <= autoDebitAmount) |
|
|
|
|
|
|
|
|
|
|
|
case .dataOnly: |
|
|
|
|
|
guard |
|
|
|
|
|
let paymentAmount = dataOnlyType?.facePrice, |
|
|
|
|
|
let amount = Int(paymentAmount), |
|
|
|
|
|
let setAutoDebitBalance = autoDebitBalance?.balance, |
|
|
|
|
|
let autoDebitAmount = Int(setAutoDebitBalance) else { return (false, false) } |
|
|
|
|
|
|
|
|
|
|
|
return (true, amount <= autoDebitAmount) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return (true, true) |
|
|
return (true, true) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
input.nextTap |
|
|
input.nextTap |
|
|
.withLatestFrom(combinedInput.asDriverOnErrorJustComplete()) {$1} |
|
|
.withLatestFrom(combinedInput.asDriverOnErrorJustComplete()) {$1} |
|
|
.map { ( _, mobile, type, priceModel, _, carrierPlan, dataOnlyType, _) -> RechargeModel? in |
|
|
|
|
|
|
|
|
.map { ( _, mobile, type, priceModel, carrierPlan, dataOnlyType, selectPaymentType, _) -> RechargeModel? in |
|
|
|
|
|
|
|
|
switch type { |
|
|
switch type { |
|
|
|
|
|
|
|
|