| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package entity
- import (
- "github.com/shopspring/decimal"
- "gorm.io/gorm"
- )
- // 系统配置表 -- 可修改
- type AssetConfig struct {
- MysqlBaseModel
- WithdrawStatus bool `json:"withdrawStatus" gorm:"type:tinyint;default:false;comment:是否允许提现(全局):0=禁止,1=允许"`
- WithdrawNoauditLimit decimal.Decimal `json:"withdrawNoauditLimit" gorm:"default:0;type:decimal(25,8);comment:提现免审额度,0表示都需要审核"`
- MinWithdrawAmount decimal.Decimal `json:"minWithdrawAmount" gorm:"default:0;type:decimal(25,8);comment:提现最小限额,0表示无限制"`
- MaxWithdrawAmount decimal.Decimal `json:"maxWithdrawAmount" gorm:"default:0;type:decimal(25,8);comment:每笔提现最大限额,-1表示无限制,0表示不能提现"`
- WithdrawRatio decimal.Decimal `json:"withdrawRatio" gorm:"type:decimal(25,8);comment:提现手续费比例"`
- WithdrawBaseAmount decimal.Decimal `json:"withdrawBaseAmount" gorm:"default:0;type:decimal(25,8);comment:单次提现手续费数量"`
- }
- func (*AssetConfig) TableName() string {
- return ModelPrefix + "asset_config"
- }
- func (*AssetConfig) Comment() string {
- return "提现配置配置表"
- }
- func NewAssetConfig() *AssetConfig {
- return &AssetConfig{}
- }
- func (c *AssetConfig) DataInit(db *gorm.DB) error {
- list := []AssetConfig{
- {
- WithdrawNoauditLimit: decimal.NewFromFloat(10000),
- MinWithdrawAmount: decimal.NewFromFloat(1),
- MaxWithdrawAmount: decimal.NewFromFloat(100000),
- WithdrawStatus: true,
- WithdrawRatio: decimal.Zero,
- },
- }
- for _, row := range list {
- find := NewAssetConfig()
- if stat := db.Model(&AssetConfig{}).Where("id = ?", 1).
- Find(&find).Statement; stat.RowsAffected == 0 {
- if err := db.Create(&row).Error; err != nil {
- return err
- }
- }
- }
- return nil
- }
|