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

92 lines
4.7 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 (
consts "assets/consts/procurement"
"assets/consts/public"
"gitea.com/red-future/common/beans"
"github.com/gogf/gf/v2/os/gtime"
"go.mongodb.org/mongo-driver/v2/bson"
)
// ============================================
// 内嵌结构体定义
// ============================================
// DirectPurchaseInfo 指定供应商模式信息
type DirectPurchaseInfo struct {
// 指定供应商信息
SupplierId *bson.ObjectID `bson:"supplierId" json:"supplierId"` // 指定供应商ID
SupplierName string `bson:"supplierName" json:"supplierName"` // 指定供应商名称
SupplierCode string `bson:"supplierCode" json:"supplierCode"` // 供应商编码
AssignReason string `bson:"assignReason" json:"assignReason"` // 指派原因
DeliveryAddress string `bson:"deliveryAddress" json:"deliveryAddress"` // 交付地址
ContactPerson string `bson:"contactPerson" json:"contactPerson"` // 联系人
ContactPhone string `bson:"contactPhone" json:"contactPhone"` // 联系电话
ResponseStatus string `bson:"responseStatus" json:"responseStatus"` // 供应商响应状态
// 时间戳
AssignedAt *gtime.Time `bson:"assignedAt" json:"assignedAt"` // 指派时间
AcceptedAt *gtime.Time `bson:"acceptedAt" json:"acceptedAt"` // 接受时间
RejectedAt *gtime.Time `bson:"rejectedAt" json:"rejectedAt"` // 拒绝时间
DeliveredAt *gtime.Time `bson:"deliveredAt" json:"deliveredAt"` // 交付时间
}
// BiddingInfo 竞价模式信息
type BiddingInfo struct {
// 竞价设置
BidMode consts.BidMode `bson:"bidMode" json:"bidMode"` // 竞价模式price/quality/time/mixed
MinSuppliers int `bson:"minSuppliers" json:"minSuppliers"` // 最少参与供应商数
MaxSuppliers int `bson:"maxSuppliers" json:"maxSuppliers"` // 最多参与供应商数
BidDuration int `bson:"bidDuration" json:"bidDuration"` // 竞价持续时长(分钟)
BidSupplierCount int `bson:"bidSupplierCount" json:"bidSupplierCount"` // 参与竞价的供应商数量
// 时间戳
BidStartAt *gtime.Time `bson:"bidStartAt" json:"bidStartAt"` // 竞价开始时间
BidEndAt *gtime.Time `bson:"bidEndAt" json:"bidEndAt"` // 竞价结束时间
ResultPublishedAt *gtime.Time `bson:"resultPublishedAt" json:"resultPublishedAt"` // 结果发布时间
}
// ============================================
// 主实体定义
// ============================================
// PurchaseOrder 采购订单实体(统一模式,结构化设计)
type PurchaseOrder struct {
beans.MongoBaseDO `bson:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, TenantId, IsDeleted
// ============================================
// 基础订单信息(所有模式共用)
// ============================================
OrderNo string `bson:"orderNo" json:"orderNo"` // 订单编号
Title string `bson:"title" json:"title"` // 订单标题
Description string `bson:"description" json:"description"` // 订单描述
OrderType consts.PurchaseOrderType `bson:"orderType" json:"orderType"` // 订单类型direct/assignment/bidding
// 需求方信息
BuyerId *bson.ObjectID `bson:"buyerId" json:"buyerId"` // 采购方ID经销商/门店)
BuyerName string `bson:"buyerName" json:"buyerName"` // 采购方名称
BuyerType string `bson:"buyerType" json:"buyerType"` // 采购方类型
// 通用状态信息
Status consts.PurchaseOrderStatus `bson:"status" json:"status"` // 订单状态
Priority int `bson:"priority" json:"priority"` // 优先级
// ============================================
// 模式特定信息(内嵌结构体)
// ============================================
DirectPurchase *DirectPurchaseInfo `bson:"directPurchase,omitempty" json:"directPurchase,omitempty"` // 指定供应商模式信息
BiddingInfo *BiddingInfo `bson:"biddingInfo,omitempty" json:"biddingInfo,omitempty"` // 竞价模式信息
// ============================================
// 通用字段
// ============================================
ExpectedDelivery *gtime.Time `bson:"expectedDelivery" json:"expectedDelivery"` // 期望交付时间
ExpiryTime *gtime.Time `bson:"expiryTime" json:"expiryTime"` // 订单有效期/竞价结束时间
}
// CollectionName 获取集合名称
func (PurchaseOrder) CollectionName() string {
return public.PurchaseOrderCollection
}