This commit is contained in:
aozhiwei 2024-08-07 16:19:27 +08:00
parent 759365412e
commit 14f4356dcb
3 changed files with 52 additions and 0 deletions

View File

@ -78,6 +78,10 @@ func (this *RechargeApi) Buy(c *gin.Context) {
f5.RspErr(c, 2, "goods id param error")
return
}
if goodsMeta.GetPrice() <= 0 {
f5.RspErr(c, 2, "goods id param error")
return
}
if reqJson.Num < 0 || reqJson.Num > goodsMeta.GetMaxBuyTimes() {
f5.RspErr(c, 2, "num param error")
return
@ -105,6 +109,10 @@ func (this *RechargeApi) Buy(c *gin.Context) {
}
price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * q5.ToInt64(goodsMeta.GetPrice()) *
q5.ToInt64(reqJson.Num)
if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) {
f5.RspErr(c, 3, "server internal error")
return
}
params := map[string]string{
"c": "BcService",
"a": "recharge",

View File

@ -3,6 +3,7 @@ package mt
import (
"f5"
"main/mtb"
"main/constant"
)
type Recharge struct {
@ -12,3 +13,26 @@ type Recharge struct {
type RechargeTable struct {
f5.IdMetaTable[Recharge]
}
func (this *Recharge) Init1() {
if this.GetDiamond() <= 0 {
panic("Recharge diamond <= 0")
return
}
if this.GetDiamond() > constant.RECHARGE_CURRENCY_MAX_EXCHANGE_RAET {
panic("Recharge diamond < upimit")
return
}
if this.GetPrice() <= 0 {
panic("Recharge price <= 0")
return
}
if this.GetMaxBuyTimes() <= 0 {
panic("Recharge max_buy_times <= 0")
return
}
if this.GetMaxBuyTimes() > constant.RECHARGE_CURRENCY_MAX_BUY_NUM {
panic("Recharge max_buy_times > uplimit")
return
}
}

View File

@ -3,6 +3,7 @@ package mt
import (
"f5"
"main/mtb"
"main/constant"
)
type RechargeCurrency struct {
@ -14,6 +15,25 @@ type RechargeCurrencyTable struct {
selfConf *RechargeCurrency
}
func (this *RechargeCurrency) Init1() {
if this.GetExchangeRate() <= 0 {
panic("RechargeCurrency exchange_rate <= 0")
return
}
if this.GetExchangeRate() != constant.RECHARGE_CURRENCY_MAX_EXCHANGE_RAET {
panic("RechargeCurrency exchange_rate > uplimit")
return
}
if this.GetCurrencyDecimal() <= 0 {
panic("RechargeCurrency currency_decimal <= 0")
return
}
if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL {
panic("RechargeCurrency exchange_rate > uplimit")
return
}
}
func (this *RechargeCurrencyTable) PostInit1() {
this.selfConf = this.GetById(int64(0))
if this.selfConf == nil {