2026-03-18 10:18:03 +08:00
|
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"assets/consts/stock"
|
|
|
|
|
|
|
|
|
|
|
|
"gitea.com/red-future/common/beans"
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-03-22 20:08:32 +08:00
|
|
|
|
type stockBatchCol struct {
|
|
|
|
|
|
beans.SQLBaseCol
|
|
|
|
|
|
AssetId string
|
|
|
|
|
|
AssetSkuId string
|
|
|
|
|
|
BatchNo string
|
|
|
|
|
|
BatchQty string
|
|
|
|
|
|
AvailableQty string
|
|
|
|
|
|
Metadata string
|
|
|
|
|
|
Status string
|
|
|
|
|
|
OrderId string
|
|
|
|
|
|
AssignedChannel string
|
|
|
|
|
|
ChannelSKU string
|
|
|
|
|
|
ChannelMetadata string
|
|
|
|
|
|
AllocatedAt string
|
|
|
|
|
|
ProductionDate string
|
|
|
|
|
|
ExpiryDate string
|
|
|
|
|
|
ExpiryWarningDate string
|
|
|
|
|
|
CategoryPath string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var StockBatchCol = stockBatchCol{
|
|
|
|
|
|
SQLBaseCol: beans.DefSQLBaseCol,
|
|
|
|
|
|
AssetId: "asset_id",
|
|
|
|
|
|
AssetSkuId: "asset_sku_id",
|
|
|
|
|
|
BatchNo: "batch_no",
|
|
|
|
|
|
BatchQty: "batch_qty",
|
|
|
|
|
|
AvailableQty: "available_qty",
|
|
|
|
|
|
Metadata: "metadata",
|
|
|
|
|
|
Status: "status",
|
|
|
|
|
|
OrderId: "order_id",
|
|
|
|
|
|
AssignedChannel: "assigned_channel",
|
|
|
|
|
|
ChannelSKU: "channel_sku",
|
|
|
|
|
|
ChannelMetadata: "channel_metadata",
|
|
|
|
|
|
AllocatedAt: "allocated_at",
|
|
|
|
|
|
ProductionDate: "production_date",
|
|
|
|
|
|
ExpiryDate: "expiry_date",
|
|
|
|
|
|
ExpiryWarningDate: "expiry_warning_date",
|
|
|
|
|
|
CategoryPath: "category_path",
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-18 10:18:03 +08:00
|
|
|
|
// StockBatch 库存批次实体(用于批次管理模式)
|
|
|
|
|
|
type StockBatch struct {
|
2026-03-22 20:08:32 +08:00
|
|
|
|
beans.SQLBaseDO `orm:",inherit"`
|
|
|
|
|
|
AssetId int64 `orm:"asset_id" json:"assetId"` // 关联资产ID
|
|
|
|
|
|
AssetSkuId int64 `orm:"asset_sku_id" json:"assetSkuId"` // 关联资产SKU ID
|
|
|
|
|
|
BatchNo string `orm:"batch_no" json:"batchNo"` // 批次号
|
|
|
|
|
|
BatchQty int `orm:"batch_qty" json:"batchQty"` // 批次总数量(入库后不可变)
|
|
|
|
|
|
AvailableQty int `orm:"available_qty" json:"availableQty"` // 可用数量(实时变化)
|
2026-03-18 10:18:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 批次元数据
|
2026-03-22 20:08:32 +08:00
|
|
|
|
Metadata []map[string]interface{} `orm:"metadata" json:"metadata"` // 其他元数据
|
2026-03-18 10:18:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 状态
|
2026-03-22 20:08:32 +08:00
|
|
|
|
Status stock.BatchStatus `orm:"status" json:"status"` // 批次状态
|
2026-03-18 10:18:03 +08:00
|
|
|
|
// 锁定数量 = BatchQty - AvailableQty
|
|
|
|
|
|
|
|
|
|
|
|
// 订单关联
|
2026-03-22 20:08:32 +08:00
|
|
|
|
OrderID int64 `orm:"order_id" json:"orderId"` // 关联订单ID(如果有)
|
2026-03-18 10:18:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 渠道分配信息
|
2026-03-22 20:08:32 +08:00
|
|
|
|
AssignedChannel string `orm:"assigned_channel" json:"assignedChannel"` // 分配的销售渠道
|
|
|
|
|
|
ChannelSKU string `orm:"channel_sku" json:"channelSku"` // 渠道商品SKU
|
|
|
|
|
|
ChannelMetadata map[string]interface{} `orm:"channel_metadata" json:"channelMetadata"` // 渠道专属数据
|
|
|
|
|
|
AllocatedAt *gtime.Time `orm:"allocated_at" json:"allocatedAt"` // 分配时间
|
2026-03-18 10:18:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 临期管理
|
2026-03-22 20:08:32 +08:00
|
|
|
|
ProductionDate *gtime.Time `orm:"production_date" json:"productionDate"` // 生产日期
|
|
|
|
|
|
ExpiryDate *gtime.Time `orm:"expiry_date" json:"expiryDate"` // 过期日期
|
|
|
|
|
|
ExpiryWarningDate *gtime.Time `orm:"expiry_warning_date" json:"expiryWarningDate"` // 临期预警时间(有过期日期时建议填写)
|
|
|
|
|
|
CategoryPath string `orm:"category_path" json:"categoryPath"` // 分类路径
|
2026-03-18 10:18:03 +08:00
|
|
|
|
}
|