소스 검색

feat: verifyOrder amont字段取小数点位数控制

wutiaorong 7 달 전
부모
커밋
c66ae73254

+ 1 - 1
app/src/main/java/com/adealink/weparty/module/wallet/data/WalletData.kt

@@ -153,7 +153,7 @@ data class VerifyOrderReq(
     @SerializedName("currency")
     val currency: String? = null,
     @SerializedName("amount")
-    val amount: Double? = null,
+    val amount: Float? = null,
 )
 
 data class VerifyOrderRes(

+ 3 - 2
module/wallet/src/main/java/com/adealink/weparty/wallet/pay/PayManager.kt

@@ -168,7 +168,7 @@ class PayManager : IPayManager, IPayListener, BaseFrame<IListener>() {
                     orderProductType = productInfo.productType,
                     channel = productInfo.channel,
                     currencyCode = productInfo.priceCurrencyCode,
-                    price = String.format("%.2f", productInfo.priceAmountCents.toFloat() / 100)
+                    price = String.format(Locale.US,"%.2f", productInfo.priceAmountCents.toFloat() / 100)
                         .toFloatOrNull()
                 )
             )
@@ -337,7 +337,8 @@ class PayManager : IPayManager, IPayListener, BaseFrame<IListener>() {
                     channel = productInfo.channel,
                     skuId = productInfo.skuId,
                     currency = productInfo.priceCurrencyCode,
-                    amount = productInfo.priceAmountCents.toDouble() / 100
+                    amount = String.format(Locale.US, "%.2f", productInfo.priceAmountCents.toFloat() / 100)
+                        .toFloatOrNull()
                 )
             )
             Log.logRltI(TAG_PAY, "verifyOrder", verifyOrderRlt)