package models // InventoryLog 库存流水表 type InventoryLog struct { ID int64 `json:"id" gorm:"primarykey;comment:流水ID"` WarehouseID int64 `json:"warehouse_id" gorm:"not null;default:0;index;comment:仓库ID"` LocationID int64 `json:"location_id" gorm:"not null;default:0;comment:库位ID(可为空)"` ProductID int64 `json:"product_id" gorm:"not null;default:0;index;comment:商品ID"` BatchNo string `json:"batch_no" gorm:"size:100;not null;default:'';comment:批次号"` ChangeType int8 `json:"change_type" gorm:"not null;default:0;comment:变动类型(1:入库,2:出库,3:移库,4:盘点调整,5:锁定库存,6:解锁库存)"` ChangeQuantity int64 `json:"change_quantity" gorm:"not null;default:0;comment:变动数量(正增负减,最小单位)"` BeforeQuantity int64 `json:"before_quantity" gorm:"not null;default:0;comment:变动前数量"` AfterQuantity int64 `json:"after_quantity" gorm:"not null;default:0;comment:变动后数量"` RelatedOrderType string `json:"related_order_type" gorm:"size:50;not null;default:'';comment:关联单据类型(如:采购单/purchase, 销售单/sales, 波次单/wave)"` RelatedOrderNo string `json:"related_order_no" gorm:"size:100;not null;index;comment:关联单据号"` Operator string `json:"operator" gorm:"size:100;not null;comment:操作人"` OperatorID int64 `json:"operator_id" gorm:"not null;default:0;comment:操作人ID"` Remark string `json:"remark" gorm:"size:255;not null;comment:备注"` CreatedAt int64 `json:"created_at" gorm:"type:bigint;not null;default:0;index;comment:操作时间戳(秒)"` IsDel int8 `json:"is_del" gorm:"type:tinyint(1);not null;default:0;comment:逻辑删除标记(0:未删除,1:已删除)"` } func (InventoryLog) TableName() string { return "inventory_log" } func (InventoryLog) TableOptions() string { return "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存流水表'" }