Files
order/model/entity/order_base.go
2025-12-10 13:51:09 +08:00

55 lines
2.8 KiB
Go
Raw 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 (
"go.mongodb.org/mongo-driver/v2/bson"
"time"
)
// OrderBase 订单基础信息
// 所有订单状态共有的字段
// 按状态拆分的订单表会继承这个基础结构
// 每个状态对应一个独立的MongoDB集合
// 例如orders_pending, orders_paid, orders_shipped, orders_completed, orders_cancelled
type OrderBase struct {
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
UserID string `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"` // 订单描述
CreatedAt time.Time `bson:"created_at" json:"created_at"` // 创建时间
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` // 更新时间
ExpiredAt *time.Time `bson:"expired_at,omitempty" json:"expired_at"` // 过期时间
}
// OrderItem 订单商品项
// 所有订单状态共有的商品信息
// 按状态拆分的订单表会包含这个结构
type OrderItem struct {
ProductID string `bson:"product_id" json:"product_id"` // 商品ID
ProductName string `bson:"product_name" json:"product_name"` // 商品名称
Price int64 `bson:"price" json:"price"` // 单价(分)
Quantity int `bson:"quantity" json:"quantity"` // 数量
TotalPrice int64 `bson:"total_price" json:"total_price"` // 小计(分)
ImageURL string `bson:"image_url,omitempty" json:"image_url"` // 商品图片
}
// 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"` // 邮编
}