| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package entity
- import (
- "app/commons/utils"
- "github.com/demdxx/gocast"
- "github.com/shopspring/decimal"
- "gorm.io/gorm"
- )
- // 用户节点订单
- // 节点收益是否需要 手动领取
- const (
- NodeOrderPayStateWaiting = iota // 待支付
- NodeOrderPayStateSuccess // 支付成功
- NodeOrderPayStateFail // 支付失败
- )
- const (
- NodeOrderStateUnknown = iota // 未知
- NodeOrderStateEffective // 有效
- NodeOrderStateExpired // 过期失效
- NodeOrderStateFailInvalid // 主动失效
- )
- const (
- NodeOrderSourceFromUser = iota // 用户购买
- NodeOrderSourceBuy1 //
- NodeOrderSourceBuy2 //
- NodeOrderSourceBuy3 //
- NodeOrderSourceFromAdminBuy // 管理后台购买
- )
- type NodeOrder struct {
- MysqlBaseModel
- RecordId string `json:"recordId" gorm:"unique;type:VARCHAR(64);comment:奖励记录ID"`
- UserId int64 `json:"userId" gorm:"index;comment:用户ID;"`
- Uid string `json:"uid" gorm:"index;type:varchar(64);comment:用户交易所ID:;"`
- ProductId int64 `json:"productId" gorm:"comment:产品ID;"`
- ProductName string `json:"productName" gorm:"type:varchar(64);comment:产品名称;"`
- UsdPrice decimal.Decimal `json:"usdPrice" gorm:"type:decimal(25,8);default:0;comment:单价"`
- Quantity decimal.Decimal `json:"quantity" gorm:"type:decimal(25,2);default:0;comment:数量"`
- UsdAmount decimal.Decimal `json:"usdAmount" gorm:"type:decimal(25,8);default:0;comment:总价值"`
- PayState int `json:"payState" gorm:"default:0;comment:支付状态:0:待支付 1: 支付成功 2: 支付失败 "`
- State int `json:"state" gorm:"default:0;comment:订单状态:0:未知 1:有效 2:过期失效 3:其他失效 "`
- Source int `json:"source" gorm:"default:0;comment:来源:0 用户购买 1: 2: 3: 4:后台购买"`
- }
- func (*NodeOrder) TableName() string {
- return NodeModelPrefix + "node_order"
- }
- func (*NodeOrder) Comment() string {
- return "股票活期理财产品表"
- }
- func NewNodeOrder() *NodeOrder {
- return &NodeOrder{}
- }
- // BeforeCreate GORM 钩子,在创建记录之前调用
- func (c *NodeOrder) BeforeCreate(tx *gorm.DB) (err error) {
- if c.RecordId == "" {
- c.RecordId = gocast.ToString(utils.UuidPrefix("ND"))
- }
- return nil
- }
|