daShangDao_psiServer/models/inventory.go
2026-06-15 13:47:39 +08:00

26 lines
1.7 KiB
Go

package models
// Inventory 库存汇总表
type Inventory struct {
ID int64 `json:"id" gorm:"primarykey;comment:库存ID"`
WarehouseID int64 `json:"warehouse_id" gorm:"not null;default:0;uniqueIndex:uk_warehouse_product_batch;index;comment:仓库ID"`
ProductID int64 `json:"product_id" gorm:"not null;default:0;uniqueIndex:uk_warehouse_product_batch;index;comment:商品ID"`
BatchNo string `json:"batch_no" gorm:"size:100;not null;default:'';uniqueIndex:uk_warehouse_product_batch;comment:批次号(无批次管理则为空字符串)"`
ProductionDate int64 `json:"production_date" gorm:"not null;default:0;comment:生产日期时间戳(秒)"`
ExpiryDate int64 `json:"expiry_date" gorm:"not null;default:0;comment:失效日期时间戳(秒)"`
Quantity int64 `json:"quantity" gorm:"not null;default:0;comment:库存数量(最小单位,如个)"`
LockedQuantity int64 `json:"locked_quantity" gorm:"not null;default:0;comment:锁定数量(已分配但未出库)"`
AvailableQuantity int64 `json:"available_quantity" gorm:"->;comment:可用数量(计算字段)"`
CreatedAt int64 `json:"created_at" gorm:"type:bigint;not null;default:0;comment:创建时间戳(秒)"`
UpdatedAt int64 `json:"updated_at" gorm:"type:bigint;not null;default:0;comment:更新时间戳(秒)"`
IsDel int8 `json:"is_del" gorm:"type:tinyint(1);not null;default:0;comment:逻辑删除标记(0:未删除,1:已删除)"`
}
func (Inventory) TableName() string {
return "inventory"
}
func (Inventory) TableOptions() string {
return "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存汇总表'"
}