调整逻辑

This commit is contained in:
renhaoting 2025-12-11 17:32:26 +08:00
parent 5e86192b93
commit da01786fd0
7 changed files with 124 additions and 47 deletions

View File

@ -72,9 +72,8 @@ data class PayoutData(
data class PayoutReply ( data class PayoutReply (
var id: String? = null, var id: String? = null,
var record_no: String? = null, var record_no: String = "",
var error: Int = 0, var error: Int = 0,
var hasCheckedResult: Boolean = false,
) )
@ -88,4 +87,14 @@ data class PayoutCheckData(var data: PayoutCheck? = null) : BaseReply()
data class PayoutCheck( data class PayoutCheck(
var status: Int = 0, // 提现状态 1:提现中,2:提现成功,3:提现失败 var status: Int = 0, // 提现状态 1:提现中,2:提现成功,3:提现失败
var error: Int = 0, // 错误码0成功1失败2签名验证失败3客户端版本过低4 ts长度错误 var error: Int = 0, // 错误码0成功1失败2签名验证失败3客户端版本过低4 ts长度错误
)
data class WithdrawRecord (
var id: String = "",
var recordNo: String = "",
var cashNum: Float = 0F,
var operateMs: Long = 0L,
var state: Int = 1, // 提现状态 1:提现中,2:提现成功,3:提现失败
var failReason: Int = 0, // TODO - define various fail reasons
) )

View File

@ -14,9 +14,12 @@ import com.ama.core.architecture.util.setOnClickBatch
import com.gamedog.vididin.VidiConst import com.gamedog.vididin.VidiConst
import com.vididin.real.money.game.R import com.vididin.real.money.game.R
import com.gamedog.vididin.VididinEvents import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.resp.PayoutCheck
import com.gamedog.vididin.beans.resp.PayoutReply import com.gamedog.vididin.beans.resp.PayoutReply
import com.gamedog.vididin.beans.resp.WithdrawRecord
import com.gamedog.vididin.core.login.login.AccountManager import com.gamedog.vididin.core.login.login.AccountManager
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawFailDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawSuccessDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawSuccessDialog
import com.gamedog.vididin.features.withdraw.widget.WithDrawItemView import com.gamedog.vididin.features.withdraw.widget.WithDrawItemView
@ -36,11 +39,9 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
private val viewModel: WithdrawViewModel by viewModels() private val viewModel: WithdrawViewModel by viewModels()
private val mItemViewList: MutableList<WithDrawItemView> = mutableListOf() private val mItemViewList: MutableList<WithDrawItemView> = mutableListOf()
private var mCurSelectedIndex: Int = 0 private var mCurSelectedIndex: Int = 0
private val mRecordList: MutableList<WithdrawRecord> by lazy {
SpUtil.instance().getList<WithdrawRecord>(SpUtil.KEY_WITHDRAW_HISTORY_LIST).toMutableList()
}
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater) override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
@ -138,11 +139,14 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW -> { VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW -> {
var withdrawNum: Float = (data.mData as Double).toFloat() var withdrawNum: Float = (data.mData as Double).toFloat()
tryWithdraw(withdrawNum) requestInit(withdrawNum)
} }
} }
}, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW) }, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW)
checkTransactionState()
} }
@ -154,12 +158,8 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
//TODO("Not yet implemented") //TODO("Not yet implemented")
} }
private fun tryWithdraw(withdrawNum: Float) {
// withdrawInit(withdrawNum)
withdrawCheck("PGS53c1b0079fad5bf5dc71d4d6b5dfc22e")
}
private fun withdrawInit(withdrawNum: Float) { private fun requestInit(withdrawNum: Float) {
lifecycleScope.launch { lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) { repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.InitData.collect { result -> viewModel.InitData.collect { result ->
@ -171,27 +171,32 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
val reqInitBean = result.data.data val reqInitBean = result.data.data
reqInitBean?.let { reqInitBean?.let {
var errorHintRes = 0
if (it.error == 0 && !it.uuid.isNullOrEmpty() && !it.items.isNullOrEmpty()) { if (it.error == 0 && !it.uuid.isNullOrEmpty() && !it.items.isNullOrEmpty()) {
val itemId = if (withdrawNum <= VidiConst.WITHDRAW_SMALL_NUM) 0 else 1 val itemId = if (withdrawNum <= VidiConst.WITHDRAW_SMALL_NUM) 0 else 1
val withDrawItem = it.items?.get(itemId)!! val withDrawItem = it.items?.get(itemId)!!
if (withDrawItem.status == ACTIVE) { if (withDrawItem.status == INIT_ACTIVE) {
withdrawPayout(it.uuid!!, withDrawItem.id, withdrawNum) requestPayout(it.uuid!!, withDrawItem.id, withdrawNum)
} else { } else {
AndroidUtil.showToast(R.string.withdraw_fail_status_is_unavailable) errorHintRes = R.string.withdraw_fail_reach_day_limit
} }
} else { } else {
var errorHint = R.string.withdraw_fail_init_fail
// 0成功1失败2签名验证失败3客户端版本过低4 ts长度错误 // 0成功1失败2签名验证失败3客户端版本过低4 ts长度错误
when (it.error) { when (it.error) {
3-> R.string.withdraw_fail_version_toolow 3-> errorHintRes = R.string.withdraw_fail_version_toolow
} }
AndroidUtil.showToast(errorHint) }
if (errorHintRes > 0) {
showFailDialog(errorHintRes)
} }
} }
} }
is Result.Error -> { is Result.Error -> {
showFailDialog(R.string.withdraw_fail_unkown_error)
} }
} }
} }
@ -201,7 +206,9 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
viewModel.withdrawInit() viewModel.withdrawInit()
} }
private fun withdrawPayout(initUUID: String, payItemId: Int, payCashNum: Float) { private fun requestPayout(initUUID: String, payItemId: Int, payCashNum: Float) {
val currentTimeMs = System.currentTimeMillis()
lifecycleScope.launch { lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) { repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.PayoutResult.collect { result -> viewModel.PayoutResult.collect { result ->
@ -210,6 +217,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
} }
is Result.Success -> { is Result.Success -> {
var errHintRes = 0 var errHintRes = 0
when (result.data?.data?.error) { when (result.data?.data?.error) {
/* 错误码 /* 错误码
0成功1失败2签名验证失败3客户端版本过低4uuid错误5所在地国家或地区不在提现限制内6提现金额不符对应的产品id7提现产品id不对8达到提现金额限制9提现次数超过限制10今日没有提现机会11提现账号达到次数限制12身份审核条件不满足不能提现13巴西提现参数 document_type 错误 0成功1失败2签名验证失败3客户端版本过低4uuid错误5所在地国家或地区不在提现限制内6提现金额不符对应的产品id7提现产品id不对8达到提现金额限制9提现次数超过限制10今日没有提现机会11提现账号达到次数限制12身份审核条件不满足不能提现13巴西提现参数 document_type 错误
@ -217,8 +225,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
21巴西提现参数 document_type 错误22巴西提现参数account_type为CPF时 对应的 document_id 错误23巴西提现参数account_type为CNPJ时 对应的 document_id 错误24 ts长度错误25 没提0.1就提现其它的 21巴西提现参数 document_type 错误22巴西提现参数account_type为CPF时 对应的 document_id 错误23巴西提现参数account_type为CNPJ时 对应的 document_id 错误24 ts长度错误25 没提0.1就提现其它的
*/ */
0 -> { 0 -> {
saveTransactionData(result.data.data!!) saveNewRecord(result.data.data!!, payCashNum, currentTimeMs)
startTimerForCheckPayoutResult(result.data.data!!)
} }
5-> { 5-> {
errHintRes = R.string.withdraw_fail_region_restricit errHintRes = R.string.withdraw_fail_region_restricit
@ -241,10 +248,12 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
} }
} }
} }
viewModel.withdrawPayout(initUUID, payItemId, payCashNum) viewModel.withdrawPayout(initUUID, payItemId, payCashNum)
} }
private fun withdrawCheck(recordNo: String) { private fun requestCheck(recordNo: String, cashNum: Float) {
lifecycleScope.launch { lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) { repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.CheckResult.collect { result -> viewModel.CheckResult.collect { result ->
@ -264,7 +273,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
// try again // try again
} }
2 -> { 2 -> {
showSuccessDialog() showSuccessDialog(cashNum)
} }
3 -> { 3 -> {
errHintRes = R.string.withdraw_normal_fail errHintRes = R.string.withdraw_normal_fail
@ -295,36 +304,76 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
viewModel.withdrawCheck(recordNo) viewModel.withdrawCheck(recordNo)
} }
private fun showSuccessDialog() { private fun showSuccessDialog(cashNum: Float) {
WithdrawSuccessDialog(this).show() WithdrawSuccessDialog(this@WithDrawActivity, cashNum).show()
} }
private fun saveTransactionData(data: PayoutReply) { private fun showFailDialog(errorHintRes: Int) {
val historyList: MutableList<PayoutReply> = SpUtil.instance().getList<PayoutReply>(SpUtil.KEY_WITHDRAW_HISTORY_LIST) as MutableList<PayoutReply> WithdrawFailDialog(this@WithDrawActivity, errorHintRes).show()
}
historyList.forEachIndexed { index, reply ->
var hasExisted = false
if (reply.id == data.id) {
reply.record_no = data.record_no // ------------------------ new added -------------------------//
reply.error = data.error // WithdrawRecord
reply.hasCheckedResult = data.hasCheckedResult
hasExisted = true @Synchronized
private fun saveNewRecord(payoutReply: PayoutReply, payCashNum: Float, timeMs: Long) {
val newRecord = WithdrawRecord().apply {
id = payoutReply.id!!
recordNo = payoutReply.record_no
cashNum = payCashNum
operateMs = timeMs
state = 1
failReason = 0
}
mRecordList.add(newRecord)
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST, mRecordList)
}
@Synchronized
private fun updateRecord(recordNo: String, payCheck: PayoutCheck) {
var needSaveSp = false
mRecordList.forEachIndexed { index, record ->
if (record.recordNo == recordNo) {
if (record.state != payCheck.status) {
needSaveSp =true
record.state = payCheck.status
}
return@forEachIndexed
} }
}
if (!hasExisted) { if (needSaveSp) {
historyList.add(data) SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST, mRecordList)
}
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST, historyList)
} }
} }
private fun startTimerForCheckPayoutResult(data: PayoutReply) { @Synchronized
withdrawCheck(data.record_no!!) private fun checkTransactionState() {
var unCheckCount = 0
mRecordList.forEach { record ->
if (record.state == FINAL_STATE_ONGING) {
unCheckCount++
}
}
if (unCheckCount > 0) {
mRecordList.forEachIndexed { index, record ->
if (record.state == FINAL_STATE_ONGING) {
requestCheck(record.recordNo, record.cashNum)
}
}
}
} }
companion object { companion object {
const val ACTIVE = 1 const val INIT_ACTIVE = 1
const val FINAL_STATE_ONGING = 1
internal fun startActivity(activity: Activity) { internal fun startActivity(activity: Activity) {
activity.startActivity(Intent(activity.applicationContext, WithDrawActivity::class.java)) activity.startActivity(Intent(activity.applicationContext, WithDrawActivity::class.java))

View File

@ -8,7 +8,7 @@ import com.vididin.real.money.game.databinding.DialogWithdrawFailBinding as View
import com.gamedog.vididin.router.Router import com.gamedog.vididin.router.Router
class WithdrawFailDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) { class WithdrawFailDialog(context: Activity, private val errorHintRes: Int) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
init { init {
build() build()
@ -30,6 +30,7 @@ class WithdrawFailDialog(context: Activity) : BindingDialog<ViewBinding>(context
tvActionFeedback -> { tvActionFeedback -> {
gotoFeedback() gotoFeedback()
dismiss()
} }
tvActionConfirm -> { tvActionConfirm -> {
@ -37,6 +38,8 @@ class WithdrawFailDialog(context: Activity) : BindingDialog<ViewBinding>(context
} }
} }
} }
tvReason.setText(errorHintRes)
} }
} }

View File

@ -7,7 +7,7 @@ import com.ama.core.architecture.widget.BindingDialog
import com.vididin.real.money.game.databinding.DialogWithdrawSuccessBinding as ViewBinding import com.vididin.real.money.game.databinding.DialogWithdrawSuccessBinding as ViewBinding
class WithdrawSuccessDialog(context: Activity) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) { class WithdrawSuccessDialog(context: Activity, private val mCashNum: Float) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {
init { init {
build() build()
@ -31,6 +31,8 @@ class WithdrawSuccessDialog(context: Activity) : BindingDialog<ViewBinding>(cont
} }
} }
} }
tvCashNum.text = mCashNum.toString()
} }
} }
} }

View File

@ -68,11 +68,21 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/gray6" android:textColor="@color/gray6"
android:text="@string/withdraw_fail_desc" android:text="@string/withdraw_fail_desc"
/> />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_reason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="@color/black"
android:text=""
/>
</LinearLayout> </LinearLayout>

View File

@ -26,7 +26,7 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical|top" android:gravity="center_vertical"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:orientation="horizontal"> android:orientation="horizontal">
@ -35,9 +35,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="30sp" android:textSize="30sp"
android:textStyle="bold" android:textStyle="bold"
android:gravity="center_vertical"
android:textColor="@color/green_2c" android:textColor="@color/green_2c"
android:text="@string/cash" android:text="@string/cash"
android:drawableStart="@mipmap/icon_cash" android:drawableStart="@mipmap/icon_cash"
android:drawablePadding="3dp"
/> />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView

View File

@ -135,5 +135,7 @@
<string name="withdraw_fail_region_restricit">Regision restriction</string> <string name="withdraw_fail_region_restricit">Regision restriction</string>
<string name="withdraw_fail_amount_limit">Amount limit</string> <string name="withdraw_fail_amount_limit">Amount limit</string>
<string name="withdraw_normal_fail">0utros Erro</string> <string name="withdraw_normal_fail">0utros Erro</string>
<string name="withdraw_fail_reach_day_limit">Your have reached the times limit.</string>
<string name="withdraw_fail_unkown_error">0utros Erro</string>
</resources> </resources>