扣减,回复 cash

This commit is contained in:
renhaoting 2025-12-15 17:30:16 +08:00
parent 5487b28be4
commit 9059a5a415
3 changed files with 24 additions and 6 deletions

View File

@ -72,10 +72,18 @@ object AccountManager {
} }
@Synchronized @Synchronized
fun addCash(newCash: Float) { fun adjustAccountCash(newCash: Float): Boolean {
mAccount?.cashCount += newCash val result = false
mAccount?.let {
val newCashTotal = it.cashCount + newCash
if (newCashTotal >= 0F) {
it.cashCount = newCashTotal
saveAccountInfo() saveAccountInfo()
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Cash_Changed, null) NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Cash_Changed, null)
return true
}
}
return result
} }
fun getBankInfo(): BankInfo? { fun getBankInfo(): BankInfo? {
@ -109,7 +117,7 @@ object AccountManager {
mAccount?.goldCount?.let { mAccount?.goldCount?.let {
if (it > costGoldNum) { if (it > costGoldNum) {
addGold(-1 * costGoldNum.toInt()) addGold(-1 * costGoldNum.toInt())
addCash(couldCovertCashTotal.toFloat()) adjustAccountCash(couldCovertCashTotal.toFloat())
AndroidUtil.showToast("Has convert $costGoldNum gold to $couldCovertCashTotal cash.") AndroidUtil.showToast("Has convert $costGoldNum gold to $couldCovertCashTotal cash.")
return true return true
} }

View File

@ -12,6 +12,7 @@ import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.req.PayInitReq import com.gamedog.vididin.beans.req.PayInitReq
import com.gamedog.vididin.beans.req.PayoutCheckReq import com.gamedog.vididin.beans.req.PayoutCheckReq
import com.gamedog.vididin.beans.resp.WithdrawRecord import com.gamedog.vididin.beans.resp.WithdrawRecord
import com.gamedog.vididin.core.login.login.AccountManager
import com.gamedog.vididin.features.withdraw.WithDrawActivity.Companion.FINAL_STATE_ONGING import com.gamedog.vididin.features.withdraw.WithDrawActivity.Companion.FINAL_STATE_ONGING
import com.gamedog.vididin.manager.WithdrawManager.Companion.STATE_NEED_WATCH_AD import com.gamedog.vididin.manager.WithdrawManager.Companion.STATE_NEED_WATCH_AD
import com.gamedog.vididin.netbase.NetworkUtil import com.gamedog.vididin.netbase.NetworkUtil
@ -182,9 +183,14 @@ class WithdrawManager private constructor() {
mRecordLocker.unlock() mRecordLocker.unlock()
} }
saveRecords2Sp() saveRecords2Sp()
adjustAccountCash(newRecord.cashNum * -1)
loopCheckTransactionState() loopCheckTransactionState()
} }
private fun adjustAccountCash(cashNum: Float) {
AccountManager.adjustAccountCash(cashNum)
}
private fun saveRecords2Sp() { private fun saveRecords2Sp() {
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST,getClonedRecordList()) SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST,getClonedRecordList())
} }
@ -336,6 +342,10 @@ class WithdrawManager private constructor() {
private fun handleTransactionFailed(recordNo: String, failedType: Int) { private fun handleTransactionFailed(recordNo: String, failedType: Int) {
updateRecord(recordNo, TRANSACTION_STATE_FAIL, failedType) updateRecord(recordNo, TRANSACTION_STATE_FAIL, failedType)
val recordBean = WithdrawManager.instance?.getRecord(recordNo)
recordBean?.let {
adjustAccountCash(it.cashNum)
}
notifyWithdrawCheckResult(recordNo) notifyWithdrawCheckResult(recordNo)
} }

View File

@ -268,7 +268,7 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
try { try {
val couldClaimCashNum = getCouldClaimCashNum() val couldClaimCashNum = getCouldClaimCashNum()
if (couldClaimCashNum > 0F) { if (couldClaimCashNum > 0F) {
AccountManager.addCash(couldClaimCashNum) AccountManager.adjustAccountCash(couldClaimCashNum)
mStateBean.tasks.forEachIndexed { index, box -> mStateBean.tasks.forEachIndexed { index, box ->
if (getBoxStateEnum(index) == STATE_FINISH) { if (getBoxStateEnum(index) == STATE_FINISH) {
box.hasClaimedReward = true box.hasClaimedReward = true