package schema import ( "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" ) // InspectionDisposalItem 不合格品处置明细子表(2026-11-16 用户拍板:处置下放明细行)。 // 一条不合格检验记录可对应多条处置行(如 10 个不合格 = 5 退货 + 5 返修,各自带数量与备注)。 // 送检判定提交时写入并即时执行库存动作(拆行/翻状态);历史「待处置」记录经 /inspection/dispose // 补处置时也写入本表。处置方式 RETURN=退货 / REWORK=返修 / SCRAP=报废;运单号概念已废除, // 退货物流信息统一填 remark(非必填)。 type InspectionDisposalItem struct { ent.Schema } func (InspectionDisposalItem) Annotations() []schema.Annotation { return []schema.Annotation{entsql.Annotation{Table: "inspection_disposal_items"}, entsql.WithComments(true), schema.Comment("InspectionDisposalItem 不合格品处置明细(按数量分退货/返修/报废)")} } func (InspectionDisposalItem) Fields() []ent.Field { return []ent.Field{ field.Int64("record_id").Comment("父检验记录ID(inspection_records.id)"), field.String("dispose_type").Comment("处置方式 RETURN/REWORK/SCRAP"), field.Int("qty").Positive().Comment("本行处置数量(合计=记录不合格数)"), field.String("remark").Optional().Comment("处置备注(非必填;退货物流信息也填此处)"), field.String("operator").Default("").Comment("操作人"), field.Int64("created_at").DefaultFunc(nowUnix), } } func (InspectionDisposalItem) Indexes() []ent.Index { return []ent.Index{ index.Fields("record_id"), } }