diff --git a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawActivity.kt b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawActivity.kt index 85f0b46..3ae2d5c 100644 --- a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawActivity.kt +++ b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawActivity.kt @@ -6,9 +6,7 @@ import android.view.LayoutInflater import androidx.activity.viewModels import androidx.core.graphics.toColorInt import androidx.core.view.isVisible -import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope -import androidx.lifecycle.repeatOnLifecycle import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity import com.ama.core.architecture.highlightpro.HighlightPro import com.ama.core.architecture.highlightpro.parameter.Constraints @@ -268,39 +266,37 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity() { val currentTimeMs = System.currentTimeMillis() lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - viewModel.PayoutResult.collect { result -> - when (result) { - is Result.Loading -> { - } - is Result.Success -> { - var failType: Int? = 0 + viewModel.PayoutResult.collect { result -> + when (result) { + is Result.Loading -> { + } + is Result.Success -> { + var failType: Int? = 0 - if (result.data?.data?.error == 0) { - saveNewRecord(result.data.data!!, payCashNum, currentTimeMs) - } else { - /* 错误码, - 0成功,1失败,2签名验证失败,3客户端版本过低,4uuid错误,5所在地国家或地区不在提现限制内,6提现金额不符对应的产品id,7提现产品id不对,8达到提现金额限制,9提现次数超过限制,10今日没有提现机会,11提现账号达到次数限制,12身份审核条件不满足,不能提现,13巴西提现参数 document_type 错误, - 14巴西提现参数 document_id 错误,15 巴西提现参数 AccountType 错误,16 巴西提现参数 Name 错误,17巴西提现参数 Account 和 DocumentId 不同,18巴西提现参数account_type为CPF时 对应的 account 错误,19巴西提现参数account_type为CNPJ时 对应的 account 错误,20巴西提现参数 account_type 错误, - 21巴西提现参数 document_type 错误,22巴西提现参数account_type为CPF时 对应的 document_id 错误,23巴西提现参数account_type为CNPJ时 对应的 document_id 错误,24 ts长度错误,25 没提0.1就提现其它的 - */ - failType = result.data?.data?.error - if (failType != null && failType > 0) { - failType += 20 - showFailDialog(WithdrawManager.instance().getFailHintStrRes(failType)) + if (result.data?.data?.error == 0) { + saveNewRecord(result.data.data!!, payCashNum, currentTimeMs) + } else { + /* 错误码, + 0成功,1失败,2签名验证失败,3客户端版本过低,4uuid错误,5所在地国家或地区不在提现限制内,6提现金额不符对应的产品id,7提现产品id不对,8达到提现金额限制,9提现次数超过限制,10今日没有提现机会,11提现账号达到次数限制,12身份审核条件不满足,不能提现,13巴西提现参数 document_type 错误, + 14巴西提现参数 document_id 错误,15 巴西提现参数 AccountType 错误,16 巴西提现参数 Name 错误,17巴西提现参数 Account 和 DocumentId 不同,18巴西提现参数account_type为CPF时 对应的 account 错误,19巴西提现参数account_type为CNPJ时 对应的 account 错误,20巴西提现参数 account_type 错误, + 21巴西提现参数 document_type 错误,22巴西提现参数account_type为CPF时 对应的 document_id 错误,23巴西提现参数account_type为CNPJ时 对应的 document_id 错误,24 ts长度错误,25 没提0.1就提现其它的 + */ + failType = result.data?.data?.error + if (failType != null && failType > 0) { + failType += 20 + showFailDialog(WithdrawManager.instance().getFailHintStrRes(failType)) - StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, mapOf( - "Reason_Type" to "Fail", - "Fail_Reason" to failType, - "Withdrawal_Position" to payCashNum, - "Withdrawal_Day" to 1, - )) - } + StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, mapOf( + "Reason_Type" to "Fail", + "Fail_Reason" to failType, + "Withdrawal_Position" to payCashNum, + "Withdrawal_Day" to 1, + )) } } - is Result.Error -> { - showFailDialog(R.string.withdraw_fail_unkown_error) - } + } + is Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) } } } diff --git a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt index 1967609..f1f4971 100644 --- a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt +++ b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt @@ -8,13 +8,11 @@ import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope -import androidx.lifecycle.repeatOnLifecycle import androidx.recyclerview.widget.LinearLayoutManager import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity import com.ama.core.architecture.util.AndroidUtil import com.ama.core.architecture.util.CommonItemDecoration import com.ama.core.architecture.util.DateUtil -import com.ama.core.architecture.util.ResUtil.dp import com.ama.core.architecture.util.setOnClickBatch import com.gamedog.statisticreporter.StatisticUtil import com.gamedog.vididin.VidiConst @@ -116,43 +114,41 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity() { private fun requestInit(withdrawNum: Double) { lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - viewModel.InitData.collect { result -> - when (result) { - is com.gamedog.vididin.netbase.Result.Loading -> { + viewModel.InitData.collect { result -> + when (result) { + is com.gamedog.vididin.netbase.Result.Loading -> { - } - is com.gamedog.vididin.netbase.Result.Success -> { - val reqInitBean = result.data.data + } + is com.gamedog.vididin.netbase.Result.Success -> { + val reqInitBean = result.data.data - reqInitBean?.let { - var errorHintRes = 0 - - if (it.error == 0 && !it.uuid.isNullOrEmpty() && !it.items.isNullOrEmpty()) { - val itemId = if (withdrawNum <= VidiConst.WITHDRAW_SMALL_NUM) 0 else 1 - val withDrawItem = it.items?.get(itemId)!! - if (withDrawItem.status == INIT_OK) { - requestPayout(it.uuid!!, withDrawItem.id, withdrawNum) - } else { - errorHintRes = R.string.withdraw_fail_reach_day_limit - } + reqInitBean?.let { + var errorHintRes = 0 + if (it.error == 0 && !it.uuid.isNullOrEmpty() && !it.items.isNullOrEmpty()) { + val itemId = if (withdrawNum <= VidiConst.WITHDRAW_SMALL_NUM) 0 else 1 + val withDrawItem = it.items?.get(itemId)!! + if (withDrawItem.status == INIT_OK) { + requestPayout(it.uuid!!, withDrawItem.id, withdrawNum) } else { - // 0成功,1失败,2签名验证失败,3客户端版本过低,4 ts长度错误 - when (it.error) { - 3-> errorHintRes = R.string.withdraw_fail_version_toolow - } + errorHintRes = R.string.withdraw_fail_reach_day_limit } - if (errorHintRes > 0) { - showFailDialog(errorHintRes) + } else { + // 0成功,1失败,2签名验证失败,3客户端版本过低,4 ts长度错误 + when (it.error) { + 3-> errorHintRes = R.string.withdraw_fail_version_toolow } } + if (errorHintRes > 0) { + showFailDialog(errorHintRes) + } } - is com.gamedog.vididin.netbase.Result.Error -> { - showFailDialog(R.string.withdraw_fail_unkown_error) - } + + } + is com.gamedog.vididin.netbase.Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) } } } @@ -165,42 +161,40 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity() { val currentTimeMs = System.currentTimeMillis() lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - viewModel.PayoutResult.collect { result -> - when (result) { - is com.gamedog.vididin.netbase.Result.Loading -> { - } - is com.gamedog.vididin.netbase.Result.Success -> { - var errHintRes = 0 + viewModel.PayoutResult.collect { result -> + when (result) { + is com.gamedog.vididin.netbase.Result.Loading -> { + } + is com.gamedog.vididin.netbase.Result.Success -> { + var errHintRes = 0 - when (result.data?.data?.error) { - /* 错误码, - 0成功,1失败,2签名验证失败,3客户端版本过低,4uuid错误,5所在地国家或地区不在提现限制内,6提现金额不符对应的产品id,7提现产品id不对,8达到提现金额限制,9提现次数超过限制,10今日没有提现机会,11提现账号达到次数限制,12身份审核条件不满足,不能提现,13巴西提现参数 document_type 错误, - 14巴西提现参数 document_id 错误,15 巴西提现参数 AccountType 错误,16 巴西提现参数 Name 错误,17巴西提现参数 Account 和 DocumentId 不同,18巴西提现参数account_type为CPF时 对应的 account 错误,19巴西提现参数account_type为CNPJ时 对应的 account 错误,20巴西提现参数 account_type 错误, - 21巴西提现参数 document_type 错误,22巴西提现参数account_type为CPF时 对应的 document_id 错误,23巴西提现参数account_type为CNPJ时 对应的 document_id 错误,24 ts长度错误,25 没提0.1就提现其它的 - */ - 0 -> { - saveNewRecord(result.data.data!!, payCashNum, currentTimeMs) - } - 5-> { - errHintRes = R.string.withdraw_fail_region_restricit - } - 8-> { - errHintRes = R.string.withdraw_fail_amount_limit - } - 9-> { - errHintRes = R.string.withdraw_fail_amount_limit - } + when (result.data?.data?.error) { + /* 错误码, + 0成功,1失败,2签名验证失败,3客户端版本过低,4uuid错误,5所在地国家或地区不在提现限制内,6提现金额不符对应的产品id,7提现产品id不对,8达到提现金额限制,9提现次数超过限制,10今日没有提现机会,11提现账号达到次数限制,12身份审核条件不满足,不能提现,13巴西提现参数 document_type 错误, + 14巴西提现参数 document_id 错误,15 巴西提现参数 AccountType 错误,16 巴西提现参数 Name 错误,17巴西提现参数 Account 和 DocumentId 不同,18巴西提现参数account_type为CPF时 对应的 account 错误,19巴西提现参数account_type为CNPJ时 对应的 account 错误,20巴西提现参数 account_type 错误, + 21巴西提现参数 document_type 错误,22巴西提现参数account_type为CPF时 对应的 document_id 错误,23巴西提现参数account_type为CNPJ时 对应的 document_id 错误,24 ts长度错误,25 没提0.1就提现其它的 + */ + 0 -> { + saveNewRecord(result.data.data!!, payCashNum, currentTimeMs) } - - if (errHintRes > 0) { - showFailDialog(errHintRes) + 5-> { + errHintRes = R.string.withdraw_fail_region_restricit + } + 8-> { + errHintRes = R.string.withdraw_fail_amount_limit + } + 9-> { + errHintRes = R.string.withdraw_fail_amount_limit } } - is com.gamedog.vididin.netbase.Result.Error -> { - showFailDialog(R.string.withdraw_fail_unkown_error) + + if (errHintRes > 0) { + showFailDialog(errHintRes) } } + is com.gamedog.vididin.netbase.Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) + } } } }