| | |
| | | |
| | | |
| | | @IBAction func couponAction(_ sender: TapBtn) { |
| | | CouponChooseView.show(couponModels,defaultModel: selectCouponModel) { m in |
| | | self.selectCouponModel = m |
| | | CouponChooseView.show(couponModels,defaultModel: selectCouponModel) {[weak self] m in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.selectCouponModel = m |
| | | guard m != nil else { |
| | | self.btn_couponInfo.setTitle("去选择", for: .normal);return |
| | | weakSelf.btn_couponInfo.setTitle("去选择", for: .normal);return |
| | | } |
| | | self.btn_couponInfo.setTitle("-\(m!.favorable)", for: .normal) |
| | | weakSelf.btn_couponInfo.setTitle("-\(m!.favorable)", for: .normal) |
| | | weakSelf.changePrice(weakSelf.selectClassIndex) |
| | | } |
| | | } |
| | | |
| | |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | if let model = weakSelf.detailModel?.list[weakSelf.selectClassIndex]{ |
| | | let price = model.vipPrice == nil ? model.originalPrice : model.vipPrice |
| | | let coin = model.playPaiCoin |
| | | PaymentView.show(money: (ali:price,wx:price,coin:coin,course:nil)) { [weak self] payType in |
| | | let price = (model.vipPrice == nil ? (model.originalPrice ?? 0) : model.vipPrice!) * Double(weakSelf.studentModels.count) |
| | | let discountPrice = price - (weakSelf.selectCouponModel?.favorable ?? 0) |
| | | let coin = (model.playPaiCoin ?? 0) * weakSelf.studentModels.count |
| | | |
| | | PaymentView.show(money: (ali:discountPrice,wx:discountPrice,coin:coin,course:nil)) { [weak self] payType in |
| | | guard let weakSelf = self else { return } |
| | | Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: model.paymentPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in |
| | | |
| | | var paymentPrice:Double = 0 |
| | | switch payType { |
| | | case .aliPay,.wechat: |
| | | paymentPrice = price |
| | | case .coin: |
| | | paymentPrice = Double(coin) |
| | | case .courseNum:break |
| | | } |
| | | |
| | | Services.courcePayment(conponId: weakSelf.selectCouponModel?.id, courseConfigId: model.id, id: weakSelf.detailModel!.id, price: paymentPrice, payType: payType, stuId: weakSelf.studentModels.map({$0.id})).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | switch payType { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { [weak self] result in |
| | | switch result { |
| | | case .success: |
| | | self?.navigationController?.popViewController(animated: false) |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | self?.present(vc, animated: true) |
| | | case .cancel: |
| | | alert(msg: "已取消") |
| | |
| | | self?.present(vc, animated: true) |
| | | } |
| | | } |
| | | case .wechat:break |
| | | case .coin:break |
| | | case .wechat: |
| | | self?.navigationController?.popViewController(animated: false) |
| | | break |
| | | case .coin: |
| | | self?.navigationController?.popViewController(animated: false) |
| | | let vc = PaymentResultVC(result: .success, objType: .courseApply) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | self?.present(vc, animated: true) |
| | | case .courseNum:break |
| | | } |
| | | }else{ |
| | |
| | | |
| | | private func changePrice(_ index:Int){ |
| | | if let subM = detailModel?.list[index]{ |
| | | label_price.text = (subM.paymentPrice * Double(studentModels.count)).currency() |
| | | label_price.text = (subM.paymentPrice * Double(studentModels.count) - (selectCouponModel?.favorable ?? 0)).currency() |
| | | label_originPrice.isHidden = subM.originalPrice == nil || subM.originalPrice == 0 |
| | | label_coin.isHidden = subM.playPaiCoin == nil || subM.playPaiCoin == 0 |
| | | label_vipPrice.isHidden = subM.vipPrice == nil || subM.vipPrice == 0 |