diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index f5cdc9f2..c9e513bd 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -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, diff --git a/server/marketserver/service/recharge.go b/server/marketserver/service/recharge.go index 65043737..428f7dae 100644 --- a/server/marketserver/service/recharge.go +++ b/server/marketserver/service/recharge.go @@ -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)},