import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm'

export enum MemberOrderStatus {
    NOT_PAID = 'NOT_PAID',
    FINISH = 'FINISH',
    CANCEL = 'CANCEL'
}

export enum PayMethod {
    WECHAT = 'WECHAT',
    ALIPAY = 'ALIPAY'
}

@Entity()
export class MemberOrder {
    @PrimaryGeneratedColumn()
    id: number

    @Column()
    userId: number

    @Column()
    planId: number

    @Column()
    price: number

    @Column()
    name: string

    @CreateDateColumn()
    createdAt: Date

    @Column({ type: 'enum', enum: MemberOrderStatus })
    status: MemberOrderStatus

    @Column({ nullable: true })
    finishTime?: Date

    @Column({ nullable: true })
    transactionId?: string

    @Column({ type: 'enum', enum: PayMethod, nullable: true })
    payMethod?: PayMethod
}
