无故事王国
2023-11-08 5f9cd3ae516f510a9475fd11f440fedf027aa4df
WanPai/Root/Activity/VC/ActivityDetailApplyVC.swift
@@ -128,38 +128,69 @@
    @IBAction func applyAction(_ sender: UIButton) {
        guard students.count != 0 else {
            alertError(msg: "请至少选择一位参赛人员");return
            alertError(msg: "请至少选择一位活动人员");return
        }
      StoresInfoView.show(activityDetailModel.storeInfos.first!) { [weak self] status in
            guard let weakSelf = self else { return }
            let price = weakSelf.activityDetailModel.cashPrice * Double(weakSelf.students.count)
            let coin = weakSelf.activityDetailModel.playPaiCoin * weakSelf.students.count
            let course = weakSelf.activityDetailModel.classPrice * weakSelf.students.count
      if activityDetailModel.storeInfos.count > 1{
         let a = activityDetailModel.storeInfos.map({$0.name})
         StoresInfo_2_View.show(a) {[weak self] status in
            guard let weakSelf = self else { return }
            if status{
            let isStudent = weakSelf.students.filter({$0.isStudent == 0}).count > 0 ? true:false
            PaymentView.show(money: (ali:price,wx:price,coin:coin,course:course,integral:nil),hasNotStudent: isStudent) { [weak self] type in
                    guard let weakSelf = self else { return }
               if type == .courseNum{
                  PaymentCourseView.show(id: weakSelf.activityDetailModel.id,number:course) { id in
                     weakSelf.payment(type: type,paymentId: id)
            let price = weakSelf.activityDetailModel.cashPrice * Double(weakSelf.students.count)
            let coin = weakSelf.activityDetailModel.playPaiCoin * weakSelf.students.count
            let course = weakSelf.activityDetailModel.classPrice * weakSelf.students.count
            if status{
               let isStudent = weakSelf.students.filter({$0.isStudent == 0}).count > 0 ? true:false
               PaymentView.show(money: (ali:price,wx:price,coin:coin,course:course,integral:nil),hasNotStudent: isStudent) { [weak self] type in
                  guard let weakSelf = self else { return }
                  if type == .courseNum{
                     PaymentCourseView.show(id: weakSelf.activityDetailModel.id,number:course) { id in
                        weakSelf.payment(type: type,paymentId: id)
                     }
                  }else{
                     weakSelf.payment(type: type)
                  }
               }else{
                  weakSelf.payment(type: type)
               }
                }
         }else{
            NotificationCenter.default.post(name: ChooseHomeStore_Noti, object: nil)
            }else{
               weakSelf.navigationController?.qmui_popToRootViewController(animated: true, completion: {
                  NotificationCenter.default.post(name: ChooseHomeStore_Noti, object: nil)
               })
            }
         }
        }
      }else{
         StoresInfoView.show(activityDetailModel.storeInfos.first!) { [weak self] status in
            guard let weakSelf = self else { return }
            let price = weakSelf.activityDetailModel.cashPrice * Double(weakSelf.students.count)
            let coin = weakSelf.activityDetailModel.playPaiCoin * weakSelf.students.count
            let course = weakSelf.activityDetailModel.classPrice * weakSelf.students.count
            if status{
               let isStudent = weakSelf.students.filter({$0.isStudent == 0}).count > 0 ? true:false
               PaymentView.show(money: (ali:price,wx:price,coin:coin,course:course,integral:nil),hasNotStudent: isStudent) { [weak self] type in
                  guard let weakSelf = self else { return }
                  if type == .courseNum{
                     PaymentCourseView.show(id: weakSelf.activityDetailModel.id,number:course) { id in
                        weakSelf.payment(type: type,paymentId: id)
                     }
                  }else{
                     weakSelf.payment(type: type)
                  }
               }
            }else{
               weakSelf.navigationController?.qmui_popToRootViewController(animated: true, completion: {
                  NotificationCenter.default.post(name: ChooseHomeStore_Noti, object: nil)
               })
            }
         }
      }
    }
   private func payment(type:PayType,paymentId:Int? = nil){
      let ids = students.map({"\($0.id)"}).joined(separator: ",")
      Services.paymentCompetition(id: activityDetailModel.id, userIds: ids, payType: type,coursePaymentId: paymentId).subscribe(onNext: {[weak self] data in
         guard let weakSelf = self else { return }
         if let m = data.data{
            switch type {
               case .aliPay: