From 17dda81a98328bdc7b3d63fa53b23917cd32c0e6 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Thu, 27 Nov 2025 10:24:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BA=A7=E5=93=81=E5=AE=9E=E4=BD=93):=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E4=BA=A7=E5=93=81=E5=AE=9E=E4=BD=93=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BB=A5=E6=94=AF=E6=8C=81=E5=AE=8C=E6=95=B4=E7=94=B5?= =?UTF-8?q?=E5=95=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加多个产品相关字段,包括库存管理、价格促销、税务信息、产品分类等 完善字段注释以明确各字段用途和可选值 --- src/entity/wp_product.entity.ts | 140 ++++++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 16 deletions(-) diff --git a/src/entity/wp_product.entity.ts b/src/entity/wp_product.entity.ts index 3cabe1c..b7070b8 100644 --- a/src/entity/wp_product.entity.ts +++ b/src/entity/wp_product.entity.ts @@ -53,42 +53,150 @@ export class WpProduct { name: string; @ApiProperty({ description: '产品状态', enum: ProductStatus }) - @Column({ type: 'enum', enum: ProductStatus }) + @Column({ type: 'enum', enum: ProductStatus, comment: '产品状态: draft, pending, private, publish' }) status: ProductStatus; + @ApiProperty({ description: '是否为特色产品', type: 'boolean' }) + @Column({ default: false, comment: '是否为特色产品' }) + featured: boolean; + + @ApiProperty({ description: '目录可见性', type: 'string' }) + @Column({ default: 'visible', comment: '目录可见性: visible, catalog, search, hidden' }) + catalog_visibility: string; + + @ApiProperty({ description: '产品描述', type: 'string' }) + @Column({ type: 'text', nullable: true, comment: '产品描述' }) + description: string; + + @ApiProperty({ description: '产品短描述', type: 'string' }) + @Column({ type: 'text', nullable: true, comment: '产品短描述' }) + short_description: string; + @ApiProperty({ description: '上下架状态', enum: ProductStockStatus }) @Column({ name: 'stock_status', type: 'enum', enum: ProductStockStatus, - default: ProductStockStatus.INSTOCK + default: ProductStockStatus.INSTOCK, + comment: '库存状态: instock, outofstock, onbackorder', }) stockStatus: ProductStockStatus; + @ApiProperty({ description: '库存数量', type: 'number' }) + @Column({ type: 'int', nullable: true, comment: '库存数量' }) + stock_quantity: number; + + @ApiProperty({ description: '允许缺货下单', type: 'string' }) + @Column({ nullable: true, comment: '允许缺货下单: no, notify, yes' }) + backorders: string; + + @ApiProperty({ description: '是否单独出售', type: 'boolean' }) + @Column({ default: false, comment: '是否单独出售' }) + sold_individually: boolean; + @ApiProperty({ description: '常规价格', type: Number }) - @Column('decimal', { precision: 10, scale: 2, nullable: true }) - regular_price: number; // 常规价格 + @Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '常规价格' }) + regular_price: number; @ApiProperty({ description: '销售价格', type: Number }) - @Column('decimal', { precision: 10, scale: 2, nullable: true }) - sale_price: number; // 销售价格 + @Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '销售价格' }) + sale_price: number; + + @ApiProperty({ description: '促销开始日期', type: 'datetime' }) + @Column({ type: 'datetime', nullable: true, comment: '促销开始日期' }) + date_on_sale_from: Date| null; + + @ApiProperty({ description: '促销结束日期', type: 'datetime' }) + @Column({ type: 'datetime', nullable: true, comment: '促销结束日期' }) + date_on_sale_to: Date|null; @ApiProperty({ description: '是否促销中', type: Boolean }) - @Column({ nullable: true, type: Boolean }) - on_sale: boolean; // 是否促销中 + @Column({ nullable: true, type: 'boolean', comment: '是否促销中' }) + on_sale: boolean; - @ApiProperty({ description: '是否删除', type: Boolean }) - @Column({ nullable: true, type: Boolean , default: false }) - on_delete: boolean; // 是否删除 + @ApiProperty({ description: '税务状态', type: 'string' }) + @Column({ default: 'taxable', comment: '税务状态: taxable, shipping, none' }) + tax_status: string; + @ApiProperty({ description: '税类', type: 'string' }) + @Column({ nullable: true, comment: '税类' }) + tax_class: string; - @ApiProperty({ - description: '产品类型', - enum: ProductType, - }) - @Column({ type: 'enum', enum: ProductType }) + @ApiProperty({ description: '重量(g)', type: 'number' }) + @Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '重量(g)' }) + weight: number; + + @ApiProperty({ description: '尺寸(长宽高)', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '尺寸' }) + dimensions: { length: string; width: string; height: string }; + + @ApiProperty({ description: '允许评论', type: 'boolean' }) + @Column({ default: true, comment: '允许客户评论' }) + reviews_allowed: boolean; + + @ApiProperty({ description: '购买备注', type: 'string' }) + @Column({ nullable: true, comment: '购买备注' }) + purchase_note: string; + + @ApiProperty({ description: '菜单排序', type: 'number' }) + @Column({ default: 0, comment: '菜单排序' }) + menu_order: number; + + @ApiProperty({ description: '产品类型', enum: ProductType }) + @Column({ type: 'enum', enum: ProductType, comment: '产品类型: simple, grouped, external, variable' }) type: ProductType; + @ApiProperty({ description: '父产品ID', type: 'number' }) + @Column({ default: 0, comment: '父产品ID' }) + parent_id: number; + + @ApiProperty({ description: '外部产品URL', type: 'string' }) + @Column({ type: 'text', nullable: true, comment: '外部产品URL' }) + external_url: string; + + @ApiProperty({ description: '外部产品按钮文本', type: 'string' }) + @Column({ nullable: true, comment: '外部产品按钮文本' }) + button_text: string; + + @ApiProperty({ description: '分组产品', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '分组产品' }) + grouped_products: number[]; + + @ApiProperty({ description: '追加销售', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '追加销售' }) + upsell_ids: number[]; + + @ApiProperty({ description: '交叉销售', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '交叉销售' }) + cross_sell_ids: number[]; + + @ApiProperty({ description: '分类', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '分类' }) + categories: { id: number; name: string; slug: string }[]; + + @ApiProperty({ description: '标签', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '标签' }) + tags: { id: number; name: string; slug: string }[]; + + @ApiProperty({ description: '图片', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '图片' }) + images: { id: number; src: string; name: string; alt: string }[]; + + @ApiProperty({ description: '产品属性', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '产品属性' }) + attributes: { id: number; name: string; position: number; visible: boolean; variation: boolean; options: string[] }[]; + + @ApiProperty({ description: '默认属性', type: 'json' }) + @Column({ type: 'json', nullable: true, comment: '默认属性' }) + default_attributes: { id: number; name: string; option: string }[]; + + @ApiProperty({ description: 'GTIN', type: 'string' }) + @Column({ nullable: true, comment: 'GTIN, UPC, EAN, or ISBN' }) + gtin: string; + + @ApiProperty({ description: '是否删除', type: 'boolean' }) + @Column({ nullable: true, type: 'boolean', default: false, comment: '是否删除' }) + on_delete: boolean; @Column({ type: 'json', nullable: true }) metadata: Record; // 产品的其他扩展字段