修复货币精度问题
This commit is contained in:
parent
993bc9bbe7
commit
be3ec0ef5c
@ -13,6 +13,7 @@ import (
|
||||
"q5"
|
||||
"strings"
|
||||
|
||||
"math/big"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -165,8 +166,13 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
}
|
||||
}
|
||||
srcPrice := q5.ToInt64(goodsMeta.GetPrice()) * q5.ToInt64(goodsNum)
|
||||
price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * srcPrice
|
||||
if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) {
|
||||
bnPrice := big.NewInt(0)
|
||||
{
|
||||
var i, e = big.NewInt(10), big.NewInt(currencyMeta.GetCurrencyDecimal())
|
||||
i.Exp(i, e, nil)
|
||||
bnPrice = i.Mul(i, big.NewInt(srcPrice))
|
||||
}
|
||||
if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(q5.ToInt64(goodsMeta.GetPrice()))) < 0 {
|
||||
f5.RspErr(c, 3, "server internal error")
|
||||
return
|
||||
}
|
||||
@ -184,7 +190,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
"order_id": orderId,
|
||||
"account_address": accountAddress,
|
||||
"passport_address": passportAddress,
|
||||
"amount": q5.ToString(price),
|
||||
"amount": bnPrice.String(),
|
||||
"currency_name": currencyContractMeta.GetName(),
|
||||
"currency_address": currencyContractMeta.GetAddress(),
|
||||
}
|
||||
@ -223,7 +229,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
currencyContractMeta.GetAddress(),
|
||||
goodsMeta.GetId(),
|
||||
itemNum,
|
||||
price,
|
||||
bnPrice.String(),
|
||||
srcPrice,
|
||||
diamond,
|
||||
presentDiamond,
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
func AddRechargeOrder(orderId string, shortOrderId string,
|
||||
netId int32, accountAddress string, passportAddress string,
|
||||
currencyAddress string, currencyName string, itemId int32, itemNum int32,
|
||||
price int64, srcPrice int64, diamond int64, presentDiamond int64, email string) bool {
|
||||
price string, srcPrice int64, diamond int64, presentDiamond int64, email string) bool {
|
||||
ok := false
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
fields := [][]string{
|
||||
@ -23,7 +23,7 @@ func AddRechargeOrder(orderId string, shortOrderId string,
|
||||
{"currency_address", currencyAddress},
|
||||
{"item_id", q5.ToString(itemId)},
|
||||
{"item_num", q5.ToString(itemNum)},
|
||||
{"price", q5.ToString(price)},
|
||||
{"price", price},
|
||||
{"diamond", q5.ToString(diamond)},
|
||||
{"present_diamond", q5.ToString(presentDiamond)},
|
||||
{"return_contribution", q5.ToString(srcPrice * 1)},
|
||||
|
Loading…
x
Reference in New Issue
Block a user