1
This commit is contained in:
parent
288b7d1de9
commit
172dd3959f
@ -118,16 +118,6 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
}
|
||||
if currencyMeta.GetExchangeRate() <= 0 ||
|
||||
currencyMeta.GetExchangeRate() > constant.RECHARGE_CURRENCY_MAX_EXCHANGE_RAET {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
}
|
||||
if currencyMeta.GetCurrencyDecimal() <= 0 ||
|
||||
currencyMeta.GetCurrencyDecimal() > constant.RECHARGE_CURRENCY_MAX_DECIMAL {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
}
|
||||
currencyContractMeta := mt.Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName())
|
||||
if currencyContractMeta == nil {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
|
||||
type Currency struct {
|
||||
currencyName string
|
||||
exchangeRate int64
|
||||
currencyDecimal int64
|
||||
contract *Contract
|
||||
}
|
||||
@ -20,9 +19,8 @@ type CurrencyTable struct {
|
||||
netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]]
|
||||
}
|
||||
|
||||
func (this *Currency) init(currencyName string, exchangeRate int64, currencyDecimal int64) {
|
||||
func (this *Currency) init(currencyName string, currencyDecimal int64) {
|
||||
this.currencyName = currencyName
|
||||
this.exchangeRate = exchangeRate
|
||||
this.currencyDecimal = currencyDecimal
|
||||
}
|
||||
|
||||
@ -30,10 +28,6 @@ func (this *Currency) GetCurrencyName() string {
|
||||
return this.currencyName
|
||||
}
|
||||
|
||||
func (this *Currency) GetExchangeRate() int64 {
|
||||
return this.exchangeRate
|
||||
}
|
||||
|
||||
func (this *Currency) GetCurrencyDecimal() int64 {
|
||||
return this.currencyDecimal
|
||||
}
|
||||
@ -43,14 +37,6 @@ func (this *Currency) GetContract() *Contract {
|
||||
}
|
||||
|
||||
func (this *Currency) check() {
|
||||
if this.GetExchangeRate() <= 0 {
|
||||
panic("Currency exchange_rate <= 0")
|
||||
return
|
||||
}
|
||||
if this.GetExchangeRate() != constant.RECHARGE_CURRENCY_MAX_EXCHANGE_RAET {
|
||||
panic("Currency exchange_rate > uplimit")
|
||||
return
|
||||
}
|
||||
if this.GetCurrencyDecimal() <= 0 {
|
||||
panic("Currency currency_decimal <= 0")
|
||||
return
|
||||
@ -107,7 +93,6 @@ func (this *CurrencyTable) Load() {
|
||||
f5.GetSysLog().Info("load currency %s", fileName)
|
||||
currencysCfg := []struct {
|
||||
CurrencyName string `json:"currency_name"`
|
||||
ExchangeRate int64 `json:"exchange_rate"`
|
||||
CurrencyDecimal int64 `json:"currency_decimal"`
|
||||
}{}
|
||||
if err := q5.DecodeJson(jsonStr, ¤cysCfg); err != nil {
|
||||
@ -115,7 +100,7 @@ func (this *CurrencyTable) Load() {
|
||||
}
|
||||
for _, currencyCfg := range currencysCfg {
|
||||
p := new(Currency)
|
||||
p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal)
|
||||
p.init(currencyCfg.CurrencyName, currencyCfg.CurrencyDecimal)
|
||||
p.check()
|
||||
currencysMeta := this.GetByNetId(netId)
|
||||
if currencysMeta == nil {
|
||||
@ -137,7 +122,8 @@ func (this *CurrencyTable) PostInit1() {
|
||||
func(key2 string, val2 *Currency) bool {
|
||||
currencyMeta := val2
|
||||
Table.Recharge.Traverse(func(ele *Recharge) bool {
|
||||
if int64(ele.GetPrice())*currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) {
|
||||
if int64(ele.GetPrice())*constant.RECHARGE_CURRENCY_MAX_EXCHANGE_RAET !=
|
||||
int64(ele.GetDiamond()) {
|
||||
panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId()))
|
||||
}
|
||||
return true
|
||||
|
Loading…
x
Reference in New Issue
Block a user