From 968c5354a1a8737a1eb311e537beb39b1b8aae7c Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Thu, 11 Dec 2025 18:44:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=20=E5=8F=96=E7=8E=B0sub?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 + .../features/withdraw/WithDrawSubActivity.kt | 395 ++++++++++++++++++ app/src/main/res/drawable/bg_round_eee_25.xml | 6 + .../res/drawable/bg_round_white_25_top.xml | 6 + .../main/res/layout/activity_withdraw_sub.xml | 187 +++++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 5 + 7 files changed, 602 insertions(+) create mode 100644 app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt create mode 100644 app/src/main/res/drawable/bg_round_eee_25.xml create mode 100644 app/src/main/res/drawable/bg_round_white_25_top.xml create mode 100644 app/src/main/res/layout/activity_withdraw_sub.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 435d8d7..a4b5b9e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -41,6 +41,7 @@ + @@ -50,6 +51,7 @@ + (), OnTabStyleListener { + + private val viewModel: WithdrawViewModel by viewModels() + private val mItemViewList: MutableList = mutableListOf() + private var mCurSelectedIndex: Int = 0 + private val mRecordList: MutableList by lazy { + SpUtil.instance().getList(SpUtil.KEY_WITHDRAW_HISTORY_LIST).toMutableList() + } + + + override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater) + + override fun ViewBinding.initWindowInsets() { + setImmerseRootView(contentRoot) + } + + override fun ViewBinding.initViews() { + titlebar.setTitleText(R.string.sacar) + + mItemViewList.add(withdraw01) + mItemViewList.add(withdraw10) + mItemViewList.add(withdraw20) + mItemViewList.add(withdraw50) + mItemViewList.add(withdraw100) + mItemViewList.add(withdraw300) + + withdraw01.setNumAndAction(0, 0.1F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdraw10.setNumAndAction(1, 10F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdraw20.setNumAndAction(2, 20F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdraw50.setNumAndAction(3, 50F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdraw100.setNumAndAction(4, 100F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdraw300.setNumAndAction(5, 300F, + { itemIndex-> + updateUIItemSelectStates(itemIndex) + }) + + withdrawPix2.setIconAndText(R.mipmap.pix2_big, R.string.pix2, { + + }) + + + withdrawPix2.setSelectedState(true) + updateUIItemSelectStates(0) + + setOnClickBatch(tvSacar, withdrawRecord) { + when(this) { + tvSacar -> { + val hasBindBank = AccountManager.hasValidBankInfo() + val cashNum = mItemViewList.get(mCurSelectedIndex).getCashNum() + if (!hasBindBank) { + WithdrawBindBankDialog(this@WithDrawSubActivity).setWithDrawCashNum(cashNum).show() + } else { + WithdrawInfoConfirmDialog(this@WithDrawSubActivity).setWithDrawCashNum(cashNum).show() + } + } + + withdrawRecord -> { + Router.WithdrawRecord.startActivity(this@WithDrawSubActivity) + } + } + } + + updateUICashTotal() + } + + private fun updateUIItemSelectStates(itemIndex: Int) { + mCurSelectedIndex = itemIndex + mItemViewList.forEachIndexed { index, view -> + view.setSelectedState(index == mCurSelectedIndex) + } + } + + private fun updateUICashTotal() { + binding.tvCashTotal.text = AccountManager.getCash().toString() + } + + override fun ViewBinding.initListeners() { + registerEvents({ data-> + when (data?.mEventType) { + VididinEvents.Event_Account_Cash_Changed -> { + updateUICashTotal() + } + + VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW -> { + var withdrawNum: Float = (data.mData as Double).toFloat() + requestInit(withdrawNum) + } + } + + }, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW) + + + checkTransactionState() + } + + + override fun ViewBinding.initObservers() { + //TODO("Not yet implemented") + } + + override fun onTabIsDarkFont(isDarkFont: Boolean) { + //TODO("Not yet implemented") + } + + + private fun requestInit(withdrawNum: Float) { + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.InitData.collect { result -> + when (result) { + is Result.Loading -> { + + } + is 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_ACTIVE) { + requestPayout(it.uuid!!, withDrawItem.id, withdrawNum) + } else { + errorHintRes = R.string.withdraw_fail_reach_day_limit + } + + } else { + // 0成功,1失败,2签名验证失败,3客户端版本过低,4 ts长度错误 + when (it.error) { + 3-> errorHintRes = R.string.withdraw_fail_version_toolow + } + } + + if (errorHintRes > 0) { + showFailDialog(errorHintRes) + } + } + + } + is Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) + } + } + } + } + } + + viewModel.withdrawInit() + } + + private fun requestPayout(initUUID: String, payItemId: Int, payCashNum: Float) { + val currentTimeMs = System.currentTimeMillis() + + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.PayoutResult.collect { result -> + when (result) { + is Result.Loading -> { + } + is 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 + } + } + + if (errHintRes > 0) { + showFailDialog(errHintRes) + } + } + is Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) + } + } + } + } + } + + + viewModel.withdrawPayout(initUUID, payItemId, payCashNum) + } + + private fun requestCheck(recordNo: String, cashNum: Float) { + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.CheckResult.collect { result -> + when (result) { + is Result.Loading -> { + + } + is Result.Success -> { + val checkResult = result.data?.data + var errHintRes = 0 + + when (checkResult?.error) { + 0 -> { + when (checkResult.status) { + // 提现状态 1:提现中,2:提现成功,3:提现失败 + 1 -> { + + } + 2 -> { + showSuccessDialog(cashNum) + updateRecord(recordNo, checkResult) + } + 3 -> { + errHintRes = R.string.withdraw_normal_fail + updateRecord(recordNo, checkResult) + } + } + } + + 1 -> { + errHintRes = R.string.withdraw_normal_fail + } + + 2 -> { + errHintRes = R.string.withdraw_fail_version_toolow + } + } + + if (errHintRes > 0) { + showFailDialog(errHintRes) + } + } + is Result.Error -> { + showFailDialog(R.string.withdraw_fail_unkown_error) + } + } + } + } + } + + viewModel.withdrawCheck(recordNo) + } + + private fun showSuccessDialog(cashNum: Float) { + WithdrawSuccessDialog(this@WithDrawSubActivity, cashNum).show() + } + + private fun showFailDialog(errorHintRes: Int) { + WithdrawFailDialog(this@WithDrawSubActivity, errorHintRes).show() + } + + + + + // ------------------------ new added -------------------------// + // WithdrawRecord + + @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) + + checkTransactionState() + } + + @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 (needSaveSp) { + SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST, mRecordList) + } + } + + @Synchronized + 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) + } + } + + binding.root.postDelayed(object : Runnable { + override fun run() { + checkTransactionState() + } + }, CHECK_DURATION) + } + } + + + + companion object { + const val INIT_ACTIVE = 1 + const val FINAL_STATE_ONGING = 1 + const val CHECK_DURATION = 10*1000L + + internal fun startActivity(activity: Activity) { + activity.startActivity(Intent(activity.applicationContext, WithDrawSubActivity::class.java)) + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_round_eee_25.xml b/app/src/main/res/drawable/bg_round_eee_25.xml new file mode 100644 index 0000000..631fb71 --- /dev/null +++ b/app/src/main/res/drawable/bg_round_eee_25.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_round_white_25_top.xml b/app/src/main/res/drawable/bg_round_white_25_top.xml new file mode 100644 index 0000000..c82bf09 --- /dev/null +++ b/app/src/main/res/drawable/bg_round_white_25_top.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/layout/activity_withdraw_sub.xml b/app/src/main/res/layout/activity_withdraw_sub.xml new file mode 100644 index 0000000..fdbfd9a --- /dev/null +++ b/app/src/main/res/layout/activity_withdraw_sub.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6d2e926..c52aefd 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -98,5 +98,6 @@ #FFFF740B #ffffe9e0 #FFFF7F00 + #FFFEE000 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08f0e1d..b6515d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -137,5 +137,10 @@ 0utros Erro Your have reached the times limit. 0utros Erro + Valor do saque + Saque Já + 100%! Pix lmediato na Sua Contal! + Regras + 1. Grandes quantias em dinheiro sro distribuidas em vários dias;todas asrecompensas sao reais e válidas.\n2. Assistir a videos na p¡gina atual pode aumentar o progresso datarefa. Quando oprogresso atingir 100%, a recompensa diária emdinheiro pode ser reivindicada.\n3. Após reivindicar uma recompensa com sucesso, vocé podereceber a proximarecompensa em dinheiro no dia sequinte.4. Se a reivindicacao falhar, verifique se as informac\'es da contaestaopreenchidas corretamente e tente reivindicar a recompensaem dinheironovamente.\n5.Se houver comportamento de fraude, o sistema banirá a contae a colocara na \ No newline at end of file