feat(产品实体): 扩展产品实体字段以支持完整电商功能
添加多个产品相关字段,包括库存管理、价格促销、税务信息、产品分类等 完善字段注释以明确各字段用途和可选值
This commit is contained in:
parent
b0903aca60
commit
17dda81a98
|
|
@ -53,42 +53,150 @@ export class WpProduct {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@ApiProperty({ description: '产品状态', enum: ProductStatus })
|
@ApiProperty({ description: '产品状态', enum: ProductStatus })
|
||||||
@Column({ type: 'enum', enum: ProductStatus })
|
@Column({ type: 'enum', enum: ProductStatus, comment: '产品状态: draft, pending, private, publish' })
|
||||||
status: ProductStatus;
|
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 })
|
@ApiProperty({ description: '上下架状态', enum: ProductStockStatus })
|
||||||
@Column({
|
@Column({
|
||||||
name: 'stock_status',
|
name: 'stock_status',
|
||||||
type: 'enum',
|
type: 'enum',
|
||||||
enum: ProductStockStatus,
|
enum: ProductStockStatus,
|
||||||
default: ProductStockStatus.INSTOCK
|
default: ProductStockStatus.INSTOCK,
|
||||||
|
comment: '库存状态: instock, outofstock, onbackorder',
|
||||||
})
|
})
|
||||||
stockStatus: ProductStockStatus;
|
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 })
|
@ApiProperty({ description: '常规价格', type: Number })
|
||||||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
@Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '常规价格' })
|
||||||
regular_price: number; // 常规价格
|
regular_price: number;
|
||||||
|
|
||||||
@ApiProperty({ description: '销售价格', type: Number })
|
@ApiProperty({ description: '销售价格', type: Number })
|
||||||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
@Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '销售价格' })
|
||||||
sale_price: number; // 销售价格
|
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 })
|
@ApiProperty({ description: '是否促销中', type: Boolean })
|
||||||
@Column({ nullable: true, type: Boolean })
|
@Column({ nullable: true, type: 'boolean', comment: '是否促销中' })
|
||||||
on_sale: boolean; // 是否促销中
|
on_sale: boolean;
|
||||||
|
|
||||||
@ApiProperty({ description: '是否删除', type: Boolean })
|
@ApiProperty({ description: '税务状态', type: 'string' })
|
||||||
@Column({ nullable: true, type: Boolean , default: false })
|
@Column({ default: 'taxable', comment: '税务状态: taxable, shipping, none' })
|
||||||
on_delete: boolean; // 是否删除
|
tax_status: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '税类', type: 'string' })
|
||||||
|
@Column({ nullable: true, comment: '税类' })
|
||||||
|
tax_class: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({ description: '重量(g)', type: 'number' })
|
||||||
description: '产品类型',
|
@Column('decimal', { precision: 10, scale: 2, nullable: true, comment: '重量(g)' })
|
||||||
enum: ProductType,
|
weight: number;
|
||||||
})
|
|
||||||
@Column({ type: 'enum', enum: ProductType })
|
@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;
|
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 })
|
@Column({ type: 'json', nullable: true })
|
||||||
metadata: Record<string, any>; // 产品的其他扩展字段
|
metadata: Record<string, any>; // 产品的其他扩展字段
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue