扣减,回复 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
fun addCash(newCash: Float) {
mAccount?.cashCount += newCash
fun adjustAccountCash(newCash: Float): Boolean {
val result = false
mAccount?.let {
val newCashTotal = it.cashCount + newCash
if (newCashTotal >= 0F) {
it.cashCount = newCashTotal
saveAccountInfo()
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Cash_Changed, null)
return true
}
}
return result
}
fun getBankInfo(): BankInfo? {
@ -109,7 +117,7 @@ object AccountManager {
mAccount?.goldCount?.let {
if (it > costGoldNum) {
addGold(-1 * costGoldNum.toInt())
addCash(couldCovertCashTotal.toFloat())
adjustAccountCash(couldCovertCashTotal.toFloat())
AndroidUtil.showToast("Has convert $costGoldNum gold to $couldCovertCashTotal cash.")
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.PayoutCheckReq
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.manager.WithdrawManager.Companion.STATE_NEED_WATCH_AD
import com.gamedog.vididin.netbase.NetworkUtil
@ -182,9 +183,14 @@ class WithdrawManager private constructor() {
mRecordLocker.unlock()
}
saveRecords2Sp()
adjustAccountCash(newRecord.cashNum * -1)
loopCheckTransactionState()
}
private fun adjustAccountCash(cashNum: Float) {
AccountManager.adjustAccountCash(cashNum)
}
private fun saveRecords2Sp() {
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST,getClonedRecordList())
}
@ -336,6 +342,10 @@ class WithdrawManager private constructor() {
private fun handleTransactionFailed(recordNo: String, failedType: Int) {
updateRecord(recordNo, TRANSACTION_STATE_FAIL, failedType)
val recordBean = WithdrawManager.instance?.getRecord(recordNo)
recordBean?.let {
adjustAccountCash(it.cashNum)
}
notifyWithdrawCheckResult(recordNo)
}

View File

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