node_order_payments.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package entity
  2. import (
  3. "app/commons/utils"
  4. "github.com/demdxx/gocast"
  5. "github.com/shopspring/decimal"
  6. "gorm.io/gorm"
  7. )
  8. // 订单支付信息
  9. type NodeOrderPayments struct {
  10. MysqlBaseModel
  11. PaymentRecordId string `json:"paymentRecordId" gorm:"unique;type:VARCHAR(64);comment:支付订单ID"`
  12. NodeOrderRecordId string `json:"nodeOrderRecordId" gorm:"index;type:VARCHAR(64);comment:节点购买记录ID"`
  13. UserId int64 `json:"userId" gorm:"index;comment:用户ID;"`
  14. Uid string `json:"uid" gorm:"index;type:varchar(64);comment:用户交易所ID:;"`
  15. OrderUsdAmount decimal.Decimal `json:"orderUsdAmount" gorm:"type:decimal(25,8);default:0;comment:订单总价值"`
  16. PaySymbol decimal.Decimal `json:"paySymbol" gorm:"type:decimal(25,8);default:0;comment:支付币种"`
  17. PaySymbolUsdPrice decimal.Decimal `json:"paySymbolUsdPrice" gorm:"type:decimal(25,8);default:0;comment:支付币种单价"`
  18. PayQuantity decimal.Decimal `json:"payQuantity" gorm:"type:decimal(25,8);default:0;comment:支付数量"`
  19. PayUsdAmount decimal.Decimal `json:"payUsdAmount" gorm:"type:decimal(25,8);default:0;comment:支付总价值"`
  20. }
  21. func (*NodeOrderPayments) TableName() string {
  22. return NodeModelPrefix + "node_order_payments"
  23. }
  24. func (*NodeOrderPayments) Comment() string {
  25. return "股票活期理财产品表"
  26. }
  27. func NewNodeOrderPayments() *NodeOrderPayments {
  28. return &NodeOrderPayments{}
  29. }
  30. // BeforeCreate GORM 钩子,在创建记录之前调用
  31. func (c *NodeOrderPayments) BeforeCreate(tx *gorm.DB) (err error) {
  32. if c.PaymentRecordId == "" {
  33. c.PaymentRecordId = gocast.ToString(utils.UuidPrefix("PAY"))
  34. }
  35. return nil
  36. }