package models import ( "platform/web/core" "github.com/shopspring/decimal" ) // ProductDiscount 产品折扣表 type ProductDiscount struct { core.Model Name string `json:"name" gorm:"column:name"` // 产品名称 Discount int32 `json:"discount" gorm:"column:discount"` // 产品折扣 } func (pd ProductDiscount) Rate() decimal.Decimal { return decimal.NewFromInt32(pd.Discount). Div(decimal.NewFromInt32(100)) }