| | |
| | | package com.driver.igotrip.ui.mine.money_bag |
| | | |
| | | import android.annotation.SuppressLint |
| | | import android.content.Intent |
| | | import android.text.InputFilter |
| | | import android.text.Spanned |
| | | import android.widget.EditText |
| | | import android.widget.LinearLayout |
| | | import android.widget.RadioGroup |
| | | import android.widget.TextView |
| | | import androidx.core.view.isVisible |
| | | import cn.sinata.xldutils.utils.doubleTwo |
| | | import cn.sinata.xldutils.utils.getContent |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.bean.CardListBean |
| | | import com.driver.igotrip.bean.UserBean |
| | | import com.driver.igotrip.bean.WaveBean |
| | | import com.driver.igotrip.netUtls.Api |
| | | import com.driver.igotrip.netUtls.callNet |
| | | import com.driver.igotrip.netUtls.getMapByAny |
| | | import com.driver.igotrip.ui.DialogUtil |
| | | import com.driver.igotrip.ui.card.CardListActivity |
| | | import com.driver.igotrip.ui.wave.WaveAccountActivity |
| | | import com.driver.igotrip.utils.Cache.CacheKey |
| | | import com.driver.igotrip.utils.view.NumberInputFilter |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivityForResult |
| | | import org.jetbrains.anko.toast |
| | | import kotlin.getValue |
| | | |
| | | class ApplyMoneyActivity : MyBaseActivity() { |
| | | |
| | | var maxMoney = 0.0 |
| | | |
| | | var card: CardListBean.DataBean? = null |
| | | var wave: WaveBean.DataBean? = null |
| | | var withdrawCashType: Int? = null // 提现方式(1=银行卡,2=WAVE) |
| | | |
| | | val type by lazy { |
| | | intent.getStringExtra("type") |
| | |
| | | private val tv_type by lazy { find<TextView>(R.id.tv_type) } |
| | | private val tv_action by lazy { find<TextView>(R.id.tv_action) } |
| | | |
| | | private val rgPay by lazy { find<RadioGroup>(R.id.rg_pay) } |
| | | private val ll_card by lazy { find<LinearLayout>(R.id.ll_card) } |
| | | private val tv_card by lazy { find<TextView>(R.id.tv_card) } |
| | | private val ll_wave by lazy { find<LinearLayout>(R.id.ll_wave) } |
| | | private val tv_wave by lazy { find<TextView>(R.id.tv_wave) } |
| | | |
| | | override fun initView() { |
| | | setTitleText(getString(R.string.申请提现)) |
| | | maxMoney = if (type == "2"){ |
| | | maxMoney = if (type == "2") { |
| | | CacheKey.getUserInfo().laveBusinessMoney |
| | | }else{ |
| | | } else { |
| | | CacheKey.getUserInfo().balance |
| | | } |
| | | et_money.hint = getString(R.string.填写提现金额最多可提).replace("%s", doubleTwo(maxMoney)) |
| | |
| | | |
| | | override fun setOnclick() { |
| | | tv_action.setOnClickListener { |
| | | if (maxMoney <= 0){ |
| | | if (maxMoney <= 0) { |
| | | toast(getString(R.string.没有余额)) |
| | | return@setOnClickListener |
| | | } |
| | | if (et_money.getContent().isEmpty()){ |
| | | if (et_money.getContent().isEmpty()) { |
| | | toast(getString(R.string.请输入提现金额)) |
| | | return@setOnClickListener |
| | | } |
| | | if (et_money.getContent().toDouble() == 0.0){ |
| | | if (et_money.getContent().toDouble() == 0.0) { |
| | | toast(getString(R.string.请输入提现金额)) |
| | | return@setOnClickListener |
| | | } |
| | | if (withdrawCashType == null) { |
| | | toast(getString(R.string.请选择提现方式)) |
| | | return@setOnClickListener |
| | | } |
| | | if (wave == null && card == null) { |
| | | toast(getString(R.string.请选择提现账号)) |
| | | return@setOnClickListener |
| | | } |
| | | tv_action.isEnabled = false |
| | | var map = getMapByAny() |
| | | val map = getMapByAny() |
| | | if(withdrawCashType == 1){ |
| | | map["bankId"] = card!!.id |
| | | } |
| | | map["money"] = et_money.getContent().toDouble() |
| | | map["type"] = type |
| | | map["type"] = withdrawCashType |
| | | map["remark"] = et_remark.getContent() |
| | | callNet(Api.withdrawal,map,{ |
| | | callNet(Api.withdrawal1, map, { |
| | | tv_action.isEnabled = true |
| | | DialogUtil.getOnlySureDialog(this, getString(R.string.我们将尽快为您处理)) { |
| | | onBackPressed() |
| | | } |
| | | callNet(Api.queryInfo, getMapByAny()){ |
| | | callNet(Api.queryInfo, getMapByAny()) { |
| | | var user = gson.fromJson<UserBean>(it, UserBean::class.java) |
| | | CacheKey.saveUserInfo(user.data) |
| | | maxMoney = if (type == "2"){ |
| | | maxMoney = if (type == "2") { |
| | | CacheKey.getUserInfo().laveBusinessMoney |
| | | }else{ |
| | | } else { |
| | | CacheKey.getUserInfo().balance |
| | | } |
| | | et_money.hint = getString(R.string.填写提现金额最多可提).replace("%s", doubleTwo(maxMoney)) |
| | | et_money.hint = |
| | | getString(R.string.填写提现金额最多可提).replace("%s", doubleTwo(maxMoney)) |
| | | } |
| | | },{ |
| | | }, { |
| | | tv_action.isEnabled = true |
| | | }) |
| | | } |
| | | rgPay.setOnCheckedChangeListener { _, checkedId -> |
| | | when (checkedId) { |
| | | R.id.rbpaytype1 -> { |
| | | // 选中“银行卡” |
| | | ll_card.isVisible = true |
| | | ll_wave.isVisible = false |
| | | withdrawCashType = 1 |
| | | } |
| | | |
| | | R.id.rbpaytype2 -> { |
| | | // 选中“WAVE” |
| | | ll_card.isVisible = false |
| | | ll_wave.isVisible = true |
| | | withdrawCashType = 2 |
| | | } |
| | | } |
| | | } |
| | | |
| | | ll_card.setOnClickListener { |
| | | startActivityForResult<CardListActivity>(110, Pair("needBack", true)) |
| | | } |
| | | ll_wave.setOnClickListener { |
| | | startActivityForResult<WaveAccountActivity>(119, Pair("needBack", true)) |
| | | } |
| | | } |
| | | |
| | | @SuppressLint("SetTextI18n") |
| | | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
| | | super.onActivityResult(requestCode, resultCode, data) |
| | | if (resultCode == RESULT_OK) { |
| | | when (requestCode) { |
| | | 110 -> { |
| | | card = data?.getSerializableExtra("data") as? CardListBean.DataBean |
| | | tv_card.text = card?.bank |
| | | } |
| | | |
| | | 119 -> { |
| | | wave = data?.getSerializableExtra("data") as? WaveBean.DataBean |
| | | tv_wave.text = "${wave?.name}(${wave?.phone})" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |