init
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 用户角色
|
||||
const (
|
||||
RoleAdmin = "admin" // 管理员
|
||||
RoleDistributor = "distributor" // 分销商
|
||||
)
|
||||
|
||||
// User 系统用户
|
||||
type User struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Username string `gorm:"uniqueIndex;size:64;not null" json:"username"`
|
||||
PasswordHash string `gorm:"size:255;not null" json:"-"`
|
||||
Nickname string `gorm:"size:64" json:"nickname"`
|
||||
Role string `gorm:"size:32;not null;default:distributor" json:"role"`
|
||||
Status int `gorm:"default:1" json:"status"` // 1启用 0禁用
|
||||
InviteCode string `gorm:"uniqueIndex;size:32" json:"invite_code"`
|
||||
ParentID *uint `gorm:"index" json:"parent_id"` // 上级分销商
|
||||
}
|
||||
|
||||
// Skin 游戏皮肤商品
|
||||
type Skin struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Name string `gorm:"size:128;not null" json:"name"`
|
||||
Game string `gorm:"size:64;index" json:"game"` // 所属游戏
|
||||
Category string `gorm:"size:64;index" json:"category"` // 分类
|
||||
CoverURL string `gorm:"size:512" json:"cover_url"`
|
||||
Price float64 `gorm:"not null;default:0" json:"price"` // 售价
|
||||
CostPrice float64 `gorm:"default:0" json:"cost_price"` // 成本价
|
||||
Commission float64 `gorm:"default:0" json:"commission"` // 佣金比例 0-1
|
||||
Stock int `gorm:"default:0" json:"stock"` // -1 无限
|
||||
Status int `gorm:"default:1" json:"status"` // 1上架 0下架
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
}
|
||||
|
||||
// Order 订单
|
||||
type Order struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
OrderNo string `gorm:"uniqueIndex;size:64;not null" json:"order_no"`
|
||||
SkinID uint `gorm:"index;not null" json:"skin_id"`
|
||||
Skin *Skin `gorm:"foreignKey:SkinID" json:"skin,omitempty"`
|
||||
DistributorID uint `gorm:"index;not null" json:"distributor_id"`
|
||||
Distributor *User `gorm:"foreignKey:DistributorID" json:"distributor,omitempty"`
|
||||
BuyerName string `gorm:"size:64" json:"buyer_name"`
|
||||
Amount float64 `gorm:"not null" json:"amount"`
|
||||
CommissionAmt float64 `gorm:"default:0" json:"commission_amt"`
|
||||
Status string `gorm:"size:32;default:pending" json:"status"` // pending/paid/delivered/cancelled
|
||||
Remark string `gorm:"size:255" json:"remark"`
|
||||
}
|
||||
|
||||
// 订单状态
|
||||
const (
|
||||
OrderStatusPending = "pending"
|
||||
OrderStatusPaid = "paid"
|
||||
OrderStatusDelivered = "delivered"
|
||||
OrderStatusCancelled = "cancelled"
|
||||
)
|
||||
Reference in New Issue
Block a user