提现 init 以及 payout 接口参数 适配
This commit is contained in:
parent
1a3b70076a
commit
3dfeaf54bf
|
|
@ -3,6 +3,8 @@ package com.gamedog.vididin
|
|||
object VidiConst {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Varous type for watching Ad
|
||||
*/
|
||||
|
|
@ -56,7 +58,7 @@ object VidiConst {
|
|||
const val ZEROBUY_APPID: String = "com.vididin.real.money.game"
|
||||
|
||||
const val DIAMOND_NUM_FOR_ONE_AD = 5
|
||||
|
||||
const val WITHDRAW_SMALL_NUM = 0.1F
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ data class PayInit(var data: PayInitReply? = null) : BaseReply() {
|
|||
|
||||
open class PayInitReply (
|
||||
var uuid: String? = null,
|
||||
var items: MutableList<InitIem?>? = null,
|
||||
var items: List<InitIem?>? = null,
|
||||
var days: Int = 0,
|
||||
var error: Int = 0,
|
||||
)
|
||||
|
|
@ -74,6 +74,7 @@ data class PayoutReply (
|
|||
var id: String? = null,
|
||||
var record_no: String? = null,
|
||||
var error: Int = 0,
|
||||
var hasCheckedResult: Boolean = false,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,13 @@ import androidx.lifecycle.Lifecycle
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
|
||||
import com.ama.core.architecture.util.AndroidUtil
|
||||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.ama.core.architecture.util.setOnClickBatch
|
||||
import com.gamedog.vididin.VidiConst
|
||||
import com.vididin.real.money.game.R
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.beans.resp.PayoutReply
|
||||
import com.gamedog.vididin.core.login.login.AccountManager
|
||||
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog
|
||||
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
|
||||
|
|
@ -133,15 +137,14 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
|
||||
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW -> {
|
||||
var withdrawNum: Float = (data.mData as Double).toFloat()
|
||||
withdrawInit()
|
||||
withdrawPayout()
|
||||
withdrawCheck()
|
||||
tryWithdraw(withdrawNum)
|
||||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW)
|
||||
}
|
||||
|
||||
|
||||
override fun ViewBinding.initObservers() {
|
||||
//TODO("Not yet implemented")
|
||||
}
|
||||
|
|
@ -150,8 +153,13 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
//TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
private fun tryWithdraw(withdrawNum: Float) {
|
||||
withdrawInit(withdrawNum)
|
||||
/*withdrawPayout()
|
||||
withdrawCheck()*/
|
||||
}
|
||||
|
||||
private fun withdrawInit() {
|
||||
private fun withdrawInit(withdrawNum: Float) {
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.InitData.collect { result ->
|
||||
|
|
@ -160,6 +168,28 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
|
||||
}
|
||||
is Result.Success -> {
|
||||
val reqInitBean = result.data.data
|
||||
|
||||
reqInitBean?.let {
|
||||
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 == ACTIVE) {
|
||||
withdrawPayout(it.uuid!!, withDrawItem.id, withdrawNum)
|
||||
} else {
|
||||
AndroidUtil.showToast(R.string.withdraw_fail_status_is_unavailable)
|
||||
}
|
||||
|
||||
} else {
|
||||
var errorHint = R.string.withdraw_fail_init_fail
|
||||
// 0成功,1失败,2签名验证失败,3客户端版本过低,4 ts长度错误
|
||||
when (it.error) {
|
||||
3-> R.string.withdraw_fail_version_toolow
|
||||
}
|
||||
AndroidUtil.showToast(errorHint)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
is Result.Error -> {
|
||||
}
|
||||
|
|
@ -171,15 +201,39 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
viewModel.withdrawInit()
|
||||
}
|
||||
|
||||
private fun withdrawPayout() {
|
||||
private fun withdrawPayout(initUUID: String, payItemId: Int, payCashNum: Float) {
|
||||
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 -> {
|
||||
saveTransactionData(result.data.data!!)
|
||||
startTimerForCheckPayoutResult(result.data.data!!)
|
||||
}
|
||||
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) {
|
||||
AndroidUtil.showToast(errHintRes)
|
||||
}
|
||||
}
|
||||
is Result.Error -> {
|
||||
}
|
||||
|
|
@ -187,8 +241,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.withdrawPayout()
|
||||
viewModel.withdrawPayout(initUUID, payItemId, payCashNum)
|
||||
}
|
||||
|
||||
private fun withdrawCheck() {
|
||||
|
|
@ -200,6 +253,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
|
||||
}
|
||||
is Result.Success -> {
|
||||
|
||||
}
|
||||
is Result.Error -> {
|
||||
}
|
||||
|
|
@ -211,8 +265,33 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabSty
|
|||
viewModel.withdrawCheck()
|
||||
}
|
||||
|
||||
private fun saveTransactionData(data: PayoutReply) {
|
||||
val historyList: MutableList<PayoutReply> = SpUtil.instance().getList<PayoutReply>(SpUtil.KEY_WITHDRAW_HISTORY_LIST) as MutableList<PayoutReply>
|
||||
|
||||
historyList.forEachIndexed { index, reply ->
|
||||
var hasExisted = false
|
||||
if (reply.id == data.id) {
|
||||
reply.record_no = data.record_no
|
||||
reply.error = data.error
|
||||
reply.hasCheckedResult = data.hasCheckedResult
|
||||
hasExisted = true
|
||||
}
|
||||
|
||||
if (!hasExisted) {
|
||||
historyList.add(data)
|
||||
}
|
||||
|
||||
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_HISTORY_LIST, historyList)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startTimerForCheckPayoutResult(data: PayoutReply) {
|
||||
withdrawCheck()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ACTIVE = 1
|
||||
|
||||
internal fun startActivity(activity: Activity) {
|
||||
activity.startActivity(Intent(activity.applicationContext, WithDrawActivity::class.java))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.gamedog.vididin.beans.req.PayoutReq
|
|||
import com.gamedog.vididin.beans.resp.PayInit
|
||||
import com.gamedog.vididin.beans.resp.PayoutCheckData
|
||||
import com.gamedog.vididin.beans.resp.PayoutData
|
||||
import com.gamedog.vididin.core.login.login.AccountManager
|
||||
import com.gamedog.vididin.netbase.NetworkUtil
|
||||
import com.gamedog.vididin.netbase.Result
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -43,10 +44,46 @@ class WithdrawViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
|
||||
fun withdrawPayout() {
|
||||
fun withdrawPayout(initUUID: String, payItemId: Int, payCashNum: Float) {
|
||||
viewModelScope.launch {
|
||||
val requestParam = PayoutReq().applyInitFields().apply {
|
||||
// TODO -
|
||||
val bankAccount = "11032341882" //AccountManager.getAccount()?.bankInfo?.bankAccount
|
||||
val accountType = "CPF"
|
||||
|
||||
account = bankAccount
|
||||
item_id = payItemId
|
||||
amount = payCashNum.toString()
|
||||
additional_remark = "communnyboneycashmoneyrewardfastrealgame"
|
||||
uuid = initUUID
|
||||
account_type = accountType
|
||||
document_type = accountType
|
||||
document_id = bankAccount
|
||||
name = "CapyBucks"
|
||||
clientName = "com.jaguar.pace.earn.cash.free.game" //AndroidUtil.getPackageId()
|
||||
|
||||
|
||||
dataAdjust.gps_adid = "gaid"
|
||||
dataAdjust.android_id = "androidid"
|
||||
dataAdjust.adid = "adid"
|
||||
dataAdjust.user_agent = "GetUerAgent"
|
||||
dataAdjust.price = amount
|
||||
dataAdjust.currency = "USD"
|
||||
|
||||
dataShuShu.gps_gaid = "gaid"
|
||||
dataShuShu.android_id = "androidid"
|
||||
dataShuShu.adid = "adid"
|
||||
dataShuShu.user_agent = "GetUerAgent"
|
||||
dataShuShu.price = amount
|
||||
dataShuShu.currency = "USD"
|
||||
dataShuShu.payment_method = "Pix"
|
||||
dataShuShu.payment_type = accountType
|
||||
dataShuShu.payment_number = account
|
||||
dataShuShu.iap_name = "100br"
|
||||
dataShuShu.gamecoin_number = "100"
|
||||
dataShuShu.gamecoin_type = "gold"
|
||||
dataShuShu.ss_account_id = "GetSSAccountId"
|
||||
dataShuShu.ss_distinct_id = "GetSSDistinctId"
|
||||
dataShuShu.ss_super_properties = "GetSSSuper Properties"
|
||||
}
|
||||
|
||||
_PayoutResult.value = Result.Loading
|
||||
|
|
@ -77,7 +114,7 @@ class WithdrawViewModel : ViewModel() {
|
|||
version = AndroidUtil.getAppVersionInfo()
|
||||
ip = NetUtil.getLocalIpAddress()
|
||||
ts = (System.currentTimeMillis()/1000).toString()
|
||||
val signOrigin = "${VidiConst.WITHDRAW_MD5KEY}platform=${platform}deviceid=${deviceid}version=${version}ip=${ip}ts={ts}"
|
||||
val signOrigin = "${VidiConst.WITHDRAW_MD5KEY}platform=${platform}deviceid=${deviceid}version=${version}ip=${ip}ts=$ts"
|
||||
sign = MD5Util.md5ForWithDraw(signOrigin)
|
||||
}
|
||||
return this
|
||||
|
|
|
|||
|
|
@ -129,5 +129,10 @@
|
|||
<string name="zero_win_action">Junte-se a nós!</string>
|
||||
<string name="zero_win_title_winnot_hint">Que pena\nvocê não foi o ganhador</string>
|
||||
<string name="zero_buy_not_win_dialog_descript">" Clique no link abaixo para entrar na nossa comunidade e conferir os ganhadores desta rodada!"</string>
|
||||
<string name="withdraw_fail_init_fail">Withdraw init request failed</string>
|
||||
<string name="withdraw_fail_version_toolow">Your app version is too old, update you app try again.</string>
|
||||
<string name="withdraw_fail_status_is_unavailable">Your account withdraw status is unavailable.</string>
|
||||
<string name="withdraw_fail_region_restricit">Regision restriction</string>
|
||||
<string name="withdraw_fail_amount_limit">Amount limit</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -99,6 +99,14 @@ class AndroidUtil private constructor() {
|
|||
}
|
||||
}
|
||||
|
||||
fun getPackageId(): String {
|
||||
return try {
|
||||
BaseApp.appContext().packageName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
"Failed to get app id: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun getThumbOfView(targetView: View): Bitmap? {
|
||||
|
|
|
|||
|
|
@ -50,14 +50,26 @@ object MD5Util {
|
|||
|
||||
|
||||
|
||||
fun md5ForWithDraw(pOriginal: String): String {
|
||||
val bytes = pOriginal.toByteArray(StandardCharsets.UTF_8)
|
||||
val digest = MessageDigest.getInstance("MD5").digest(bytes)
|
||||
return digest.joinToString("") { "%02x".format(it.toInt() and 0xFF) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* MD5加密函数
|
||||
* @param original 原始字符串
|
||||
* @param charsetName 字符编码名称,默认为"UTF-8"
|
||||
* @return 返回32位小写的MD5哈希字符串
|
||||
*/
|
||||
fun md5ForWithDraw(input: String): String {
|
||||
// 元宝
|
||||
fun md5ForWithDraw2(pOriginal: String): String {
|
||||
val bytes = pOriginal.toByteArray(Charset.forName("UTF-8"))
|
||||
val digest = MessageDigest.getInstance("MD5").digest(bytes)
|
||||
return digest.joinToString("") {"%02".format(it.toInt() and 0xFF) }
|
||||
|
||||
/*// 元宝
|
||||
val bytes = input.toByteArray(charset("UTF-8")) // 按指定字符集转换为字节数组[6](@ref)
|
||||
val digest = MessageDigest.getInstance("MD5") // 获取MD5实例[6,7,8](@ref)
|
||||
val hashBytes = digest.digest(bytes) // 计算MD5哈希值[6,7,8](@ref)
|
||||
|
|
@ -71,7 +83,7 @@ object MD5Util {
|
|||
}
|
||||
hexString.append(hex)
|
||||
}
|
||||
return hexString.toString().lowercase()
|
||||
return hexString.toString().lowercase()*/
|
||||
|
||||
/* // 百度
|
||||
val md = MessageDigest.getInstance("MD5")
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ class SpUtil private constructor(spFileName: String) {
|
|||
const val KEY_ZEROBUY_HAS_NOTIFY_IDS = "KEY_ZEROBUY_HAS_NOTIFY_IDS"
|
||||
|
||||
|
||||
const val KEY_WITHDRAW_HISTORY_LIST = "KEY_WITHDRAW_HISTORY_LIST"
|
||||
|
||||
|
||||
|
||||
|
||||
@Volatile
|
||||
|
|
|
|||
Loading…
Reference in New Issue