This commit is contained in:
aozhiwei 2024-08-07 15:12:04 +08:00
parent 4b9489d0b9
commit d6fd79d142
5 changed files with 51 additions and 72 deletions

View File

@ -29,9 +29,9 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
mt.Table.Recharge.RawMetaTable.Traverse(func(tb *mt.Recharge) bool {
tmpmap := map[string]interface{}{}
tmpmap["goods_id"] = tb.GetId()
tmpmap["diamond"] = tb.GetRechargeItemNum()
tmpmap["currency"] = tb.GetRechargeCurrency()
tmpmap["price"] = tb.GetRechargeCostNum()
tmpmap["diamond"] = tb.GetDiamond()
//tmpmap["currency"] = tb.GetRechargeCurrency()
tmpmap["price"] = tb.GetPrice()
rspObj.Rows = append(rspObj.Rows, tmpmap)
@ -53,16 +53,22 @@ func (this *RechargeApi) Buy(c *gin.Context) {
f5.RspErr(c, 1, err.Error())
return
}
if reqJson.Num <= 0 {
f5.RspErr(c, 2, "num param error")
return
}
currencyMeta := mt.Table.RechargeCurrency.Get()
if currencyMeta == nil {
f5.RspErr(c, 2, "server internal error")
return
}
if currencyMeta.GetExchangeRate() <= 0 || currencyMeta.GetExchangeRate() > 1000 {
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() > 10 {
if currencyMeta.GetCurrencyDecimal() <= 0 ||
currencyMeta.GetCurrencyDecimal() > constant.RECHARGE_CURRENCY_MAX_DECIMAL {
f5.RspErr(c, 2, "server internal error")
return
}
@ -101,7 +107,7 @@ func (this *RechargeApi) Buy(c *gin.Context) {
return
}
}
price := currencyMeta.GetCurrencyDecimal() * q5.ToInt64(reqJson.Num)
price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * q5.ToInt64(reqJson.Num)
params := map[string]string{
"c": "BcService",
"a": "recharge",

View File

@ -17,3 +17,9 @@ const (
const (
SHOPCART_MAX_GOODS_NUM = 20
)
const (
RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 50
RECHARGE_CURRENCY_MAX_DECIMAL = 6
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
)

View File

@ -88,13 +88,10 @@ type Language struct {
}
type Recharge struct {
recharge_cost_num string
recharge_icon string
recharge_item int32
recharge_type int32
recharge_item_num int32
id int32
recharge_currency string
diamond int32
price int32
max_buy_times int32
_flags1_ uint64
_flags2_ uint64
@ -394,60 +391,36 @@ func (this *Language) HasEn() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Recharge) GetRechargeCostNum() string {
return this.recharge_cost_num
}
func (this *Recharge) HasRechargeCostNum() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Recharge) GetRechargeIcon() string {
return this.recharge_icon
}
func (this *Recharge) HasRechargeIcon() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Recharge) GetRechargeItem() int32 {
return this.recharge_item
}
func (this *Recharge) HasRechargeItem() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Recharge) GetRechargeType() int32 {
return this.recharge_type
}
func (this *Recharge) HasRechargeType() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Recharge) GetRechargeItemNum() int32 {
return this.recharge_item_num
}
func (this *Recharge) HasRechargeItemNum() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *Recharge) GetId() int32 {
return this.id
}
func (this *Recharge) HasId() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Recharge) GetRechargeCurrency() string {
return this.recharge_currency
func (this *Recharge) GetDiamond() int32 {
return this.diamond
}
func (this *Recharge) HasRechargeCurrency() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
func (this *Recharge) HasDiamond() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Recharge) GetPrice() int32 {
return this.price
}
func (this *Recharge) HasPrice() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Recharge) GetMaxBuyTimes() int32 {
return this.max_buy_times
}
func (this *Recharge) HasMaxBuyTimes() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Web3ServiceCluster) GetUrl() string {
@ -527,13 +500,10 @@ func (this *Language) LoadFromKv(kv map[string]interface{}) {
}
func (this *Recharge) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.recharge_cost_num, "recharge_cost_num", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.recharge_icon, "recharge_icon", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.recharge_item, "recharge_item", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.recharge_type, "recharge_type", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.recharge_item_num, "recharge_item_num", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.recharge_currency, "recharge_currency", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.diamond, "diamond", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.price, "price", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.max_buy_times, "max_buy_times", &this._flags1_, 4, kv)
}
func (this *Web3ServiceCluster) LoadFromKv(kv map[string]interface{}) {

View File

@ -71,13 +71,10 @@ message Language
message Recharge
{
optional string recharge_cost_num = 1;
optional string recharge_icon =2;
optional int32 recharge_item =3;
optional int32 recharge_type =4;
optional int32 recharge_item_num =5;
optional int32 id =6;
optional string recharge_currency = 7;
optional int32 id = 1;
optional int32 diamond = 2;
optional int32 price = 3;
optional int32 max_buy_times = 4;
}
message Web3ServiceCluster

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 489449c65d408c649ec4ceeb3fa1ad48a692eb61
Subproject commit b065fccf5cc960b8a411841424ef1de29dceb3ec