package entity import ( "time" "gitea.com/red-future/common/beans" ) // OrderBase 订单基础信息 // 所有订单状态共有的字段 // 按状态拆分的订单表会继承这个基础结构 // 每个状态对应一个独立的MongoDB集合 // 例如:orders_pending, orders_paid, orders_shipped, orders_completed, orders_cancelled type OrderBase struct { beans.MongoBaseDO `bson:",inline"` OrderNo string `bson:"order_no" json:"order_no"` // 订单号 UserID int64 `bson:"user_id" json:"user_id"` // 用户ID TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额(分) PayAmount int64 `bson:"pay_amount" json:"pay_amount"` // 实付金额(分) OrderType string `bson:"order_type" json:"order_type"` // 订单类型:normal-普通订单 Subject string `bson:"subject" json:"subject"` // 订单标题 Description string `bson:"description" json:"description"` // 订单描述 OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品项 ExpiredAt *time.Time `bson:"expired_at,omitempty" json:"expired_at"` // 过期时间 } // OrderItem 订单商品项 // 所有订单状态共有的商品信息 // 按状态拆分的订单表会包含这个结构 type OrderItem struct { AssetID string `bson:"asset_id" json:"asset_id"` // 资产ID AssetName string `bson:"asset_name" json:"asset_name"` // 资产名称 AssetType string `bson:"asset_type" json:"asset_type"` // 资产类型:product-商品型,service-服务型,software-软件型 ImageURL string `bson:"image_url,omitempty" json:"image_url"` // 资产图片 Quantity int `bson:"quantity" json:"quantity"` // 总数量 TotalPrice int64 `bson:"total_price" json:"total_price"` // 小计(分) Stocks []OrderItemStock `bson:"stocks" json:"stocks"` // 库存项列表 } // OrderItemStock 订单商品项库存明细 // 用于追溯具体使用了哪些库存项,支持明细模式和批次模式 // 明细模式:一个库存项对应一条记录,数量固定为1 // 批次模式:一个批次记录可以包含多个数量 type OrderItemStock struct { // 库存ID(明细模式必填,批次模式为空) StockID string `bson:"stock_id,omitempty" json:"stock_id,omitempty"` // 批次信息(批次模式必填,明细模式为空) BatchID string `bson:"batch_id,omitempty" json:"batch_id,omitempty"` // 批次ID BatchNo string `bson:"batch_no,omitempty" json:"batch_no,omitempty"` // 批次号 // 数量(明细模式固定为1,批次模式可以>1) Quantity int `bson:"quantity" json:"quantity"` // 使用数量 // 价格信息 Price int64 `bson:"price" json:"price"` // 该库存项的单价(分) // 库存管理模式 StockMode int `bson:"stock_mode" json:"stock_mode"` // 库存管理模式:1-明细模式,2-批次模式 // 库存项属性(动态字段,存储该库存项的具体规格属性) StockAttrs map[string]interface{} `bson:"stock_attrs,omitempty" json:"stock_attrs,omitempty"` } // ShippingInfo 收货信息 // 所有订单状态共有的收货信息 // 按状态拆分的订单表会包含这个结构 type ShippingInfo struct { Consignee string `bson:"consignee" json:"consignee"` // 收货人 Phone string `bson:"phone" json:"phone"` // 手机号 Province string `bson:"province" json:"province"` // 省份 City string `bson:"city" json:"city"` // 城市 District string `bson:"district" json:"district"` // 区县 Address string `bson:"address" json:"address"` // 详细地址 PostalCode string `bson:"postal_code,omitempty" json:"postal_code"` // 邮编 }