package com.adealink.weparty.wallet.recharge.data

import com.adealink.weparty.module.wallet.data.Currency
import com.adealink.weparty.module.wallet.data.PayChannel
import com.google.gson.annotations.GsonNullable
import com.google.gson.annotations.SerializedName


data class RechargeConfigReq(
    @SerializedName("walletType") val currency: Int,
    @SerializedName("rechargePlatform") val platform: Int = 1 //0:Official, 1:Android, 2:Browser
)

data class RechargeConfigRes(
    @SerializedName("items") val items: List<RechargeProduct>,
)

data class RechargeProduct(
    @SerializedName("id") val id: String, //用作服务端下单
    @SerializedName("coinRechargeAmount") val amount: Int, //充值数量
    @SerializedName("amount") val price: Double, //价格
    @SerializedName("currency") val priceCurrency: String, //法币名称
    @SerializedName("code") val productId: String, //用作查询Google充值档位(eg: com.jiehe.gami.3000)

    //默认Google渠道
    @SerializedName("product_channel")
    var productChannel: Int = PayChannel.Google.type,
    @SerializedName("product_currency")
    var productCurrency: Int = Currency.COIN.type,
) {

    fun skuId(): String {
        return "${productId}"
    }

    companion object {
        @JvmStatic
        val INVALID_PRODUCT = RechargeProduct(
            "",
            0,
            0.0,
            "",
            ""
        )
    }
}


data class ConvertCurrencyReq(
    @SerializedName("fromWalletType") val fromCurrency: Int,
    @SerializedName("toWalletType") val toCurrency: Int,
    @SerializedName("amount") val amount: Double,
)

/**
 * 预下单
 */
data class PrePurchaseReq(
    @SerializedName("id") val id: String,
    @SerializedName("uri") val uri: String = "", //回调uri,不能为null
)

data class PrePurchaseRes(
    @SerializedName("result") val result: String,
)

/**
 * 充值成功回调
 */
data class PaySuccessReq(
    @SerializedName("userId") val uid: String,
    @SerializedName("orderId") val orderId: String,
    @SerializedName("payType") val payType: Int,
    @SerializedName("receipt") val receipt: String,
)

/**
 * 充值失败取消回调
 */
data class PayFailReq(
    @SerializedName("id") val orderId: String,
)

/**
 * 通用配置
 */

data class CurrencyExchangedConfigRes(
    @SerializedName("commonCoinExchangeConsts") val config: List<CurrencyExchangeConfig>,
)

data class CurrencyExchangeConfig(
    @SerializedName("IDR") val idr: Double,

    @GsonNullable
    @SerializedName("goldCoin") val coin: Double?,
    @GsonNullable
    @SerializedName("diamond") val diamond: Double?,
    @GsonNullable
    @SerializedName("bean") val bean: Double?
)


/**
 * 充值失败取消回调
 */
data class PreConvertReq(
    @SerializedName("fromWalletType") val fromCurrency: Int,
    @SerializedName("toWalletType") val toCurrency: Int,
    @SerializedName("amount") val amount: Double,
)

data class PreConvertRes(
    @SerializedName("amount") val amount: Double,
)