import { ApiProperty } from '@midwayjs/swagger'; import { Exclude, Expose } from 'class-transformer'; import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; import { SubscriptionStatus } from '../enums/base.enum'; @Entity('subscription') @Exclude() export class Subscription { @ApiProperty() @PrimaryGeneratedColumn() @Expose() id: number; @ApiProperty({ description: '来源站点唯一标识' }) @Column() @Expose() siteId: string; @ApiProperty({ description: 'WooCommerce 订阅 ID' }) @Column() @Expose() externalSubscriptionId: string; @ApiProperty({ type: SubscriptionStatus }) @Column({ type: 'enum', enum: SubscriptionStatus }) @Expose() status: SubscriptionStatus; @ApiProperty() @Column({ default: '' }) @Expose() currency: string; @ApiProperty() @Column('decimal', { precision: 10, scale: 2, default: 0 }) @Expose() total: number; @ApiProperty({ description: '计费周期 e.g. day/week/month/year' }) @Column({ default: '' }) @Expose() billing_period: string; @ApiProperty({ description: '计费周期间隔 e.g. 1/3/12' }) @Column({ type: 'int', default: 0 }) @Expose() billing_interval: number; @ApiProperty() @Column({ type: 'int', default: 0 }) @Expose() customer_id: number; @ApiProperty() @Column({ default: '' }) @Expose() customer_email: string; @ApiProperty({ description: '父订单/父订阅ID(如有)' }) @Column({ type: 'int', default: 0 }) @Expose() parent_id: number; @ApiProperty() @Column({ type: 'timestamp', nullable: true }) @Expose() start_date: Date; @ApiProperty() @Column({ type: 'timestamp', nullable: true }) @Expose() trial_end: Date; @ApiProperty() @Column({ type: 'timestamp', nullable: true }) @Expose() next_payment_date: Date; @ApiProperty() @Column({ type: 'timestamp', nullable: true }) @Expose() end_date: Date; @ApiProperty() @Column({ type: 'json', nullable: true }) @Expose() line_items: any[]; @ApiProperty() @Column({ type: 'json', nullable: true }) @Expose() meta_data: 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; }