152 lines
3.2 KiB
TypeScript
152 lines
3.2 KiB
TypeScript
import { ApiProperty } from '@midwayjs/swagger';
|
||
import { Exclude, Expose } from 'class-transformer';
|
||
import {
|
||
Column,
|
||
CreateDateColumn,
|
||
Entity,
|
||
PrimaryGeneratedColumn,
|
||
UpdateDateColumn,
|
||
} from 'typeorm';
|
||
|
||
@Entity('order_item')
|
||
@Exclude()
|
||
export class OrderItem {
|
||
@ApiProperty()
|
||
@PrimaryGeneratedColumn()
|
||
@Expose()
|
||
id: number;
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
name: string;
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
siteId: string; // 来源站点唯一标识
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
orderId: number; // 订单 ID
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
externalOrderId: string; // WooCommerce 订单 ID
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
externalOrderItemId: string; // WooCommerce 订单item ID
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
externalProductId: string; // WooCommerce 产品 ID
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
externalVariationId: string; // WooCommerce 变体 ID
|
||
|
||
@ApiProperty()
|
||
@Column()
|
||
@Expose()
|
||
quantity: number;
|
||
|
||
@ApiProperty()
|
||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
||
@Expose()
|
||
subtotal: number;
|
||
|
||
@ApiProperty()
|
||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
||
@Expose()
|
||
subtotal_tax: number;
|
||
|
||
@ApiProperty()
|
||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
||
@Expose()
|
||
total: number;
|
||
|
||
@ApiProperty()
|
||
@Column('decimal', { precision: 10, scale: 2, nullable: true })
|
||
@Expose()
|
||
total_tax: number;
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
tax_class?: string; // 税类(来自 line_items.tax_class)
|
||
|
||
@ApiProperty()
|
||
@Column({ type: 'json', nullable: true })
|
||
@Expose()
|
||
taxes?: any[]; // 税明细(来自 line_items.taxes,数组)
|
||
|
||
@ApiProperty()
|
||
@Column({ type: 'json', nullable: true })
|
||
@Expose()
|
||
meta_data?: any[]; // 行项目元数据(包含订阅相关键值)
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
sku?: string;
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
global_unique_id?: string; // 全局唯一ID(部分主题/插件会提供)
|
||
|
||
@ApiProperty()
|
||
@Column('decimal', { precision: 10, scale: 2 })
|
||
@Expose()
|
||
price: number;
|
||
|
||
@ApiProperty()
|
||
@Column({ type: 'json', nullable: true })
|
||
@Expose()
|
||
image?: { id?: string | number; src?: string }; // 商品图片(对象,包含 id/src)
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
parent_name?: string; // 父商品名称(组合/捆绑时可能使用)
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
bundled_by?: string; // 捆绑来源标识(bundled_by)
|
||
|
||
@ApiProperty()
|
||
@Column({ nullable: true })
|
||
@Expose()
|
||
bundled_item_title?: string; // 捆绑项标题
|
||
|
||
@ApiProperty()
|
||
@Column({ type: 'json', nullable: true })
|
||
@Expose()
|
||
bundled_items?: any[]; // 捆绑项列表(数组)
|
||
|
||
@ApiProperty({
|
||
example: '2022-12-12 11:11:11',
|
||
description: '创建时间',
|
||
required: true,
|
||
})
|
||
@CreateDateColumn()
|
||
@Expose()
|
||
createdAt: Date;
|
||
|
||
@ApiProperty({
|
||
example: '2022-12-12 11:11:11',
|
||
description: '更新时间',
|
||
required: true,
|
||
})
|
||
@UpdateDateColumn()
|
||
@Expose()
|
||
updatedAt: Date;
|
||
}
|