Files
assets/model/entity/stock/stock_batch.go
2026-03-18 10:18:03 +08:00

49 lines
2.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package entity
import (
"assets/consts/public"
"assets/consts/stock"
"gitea.com/red-future/common/beans"
"github.com/gogf/gf/v2/os/gtime"
"go.mongodb.org/mongo-driver/v2/bson"
)
// StockBatch 库存批次实体(用于批次管理模式)
type StockBatch struct {
beans.MongoBaseDO `bson:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, TenantId, IsDeleted
AssetID *bson.ObjectID `bson:"assetId" json:"assetId"` // 关联资产ID
AssetSkuID *bson.ObjectID `bson:"assetSkuId" json:"assetSkuId"` // 关联资产SKU ID
BatchNo string `bson:"batchNo" json:"batchNo"` // 批次号
BatchQty int `bson:"batchQty" json:"batchQty"` // 批次总数量(入库后不可变)
AvailableQty int `bson:"availableQty" json:"availableQty"` // 可用数量(实时变化)
// 批次元数据
Metadata []map[string]interface{} `bson:"metadata" json:"metadata"` // 其他元数据
// 状态
Status *stock.BatchStatus `bson:"status" json:"status"` // 批次状态
// 锁定数量 = BatchQty - AvailableQty
// 订单关联
OrderID *bson.ObjectID `bson:"orderId" json:"orderId"` // 关联订单ID如果有
// 渠道分配信息
AssignedChannel string `bson:"assignedChannel" json:"assignedChannel"` // 分配的销售渠道
ChannelSKU string `bson:"channelSku" json:"channelSku"` // 渠道商品SKU
ChannelMetadata map[string]interface{} `bson:"channelMetadata" json:"channelMetadata"` // 渠道专属数据
AllocatedAt *gtime.Time `bson:"allocatedAt" json:"allocatedAt"` // 分配时间
// 临期管理
ProductionDate *gtime.Time `bson:"productionDate" json:"productionDate"` // 生产日期
ExpiryDate *gtime.Time `bson:"expiryDate" json:"expiryDate"` // 过期日期
ExpiryWarningDate *gtime.Time `bson:"expiryWarningDate" json:"expiryWarningDate"` // 临期预警时间(有过期日期时建议填写)
CategoryPath string `bson:"categoryPath" json:"categoryPath"` // 分类路径
}
// CollectionName 获取集合名称
func (StockBatch) CollectionName() string {
return public.StockBatchCollection
}