import { JsonTransformer } from '../../transformers/json.transformer'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm'

export enum PaperOrderStatus {
    Pending = 'pending',
    Generating = 'generating',
    Complete = 'complete'
}

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

    @CreateDateColumn()
    createdAt: Date

    @Column()
    userId: number

    @Column()
    title: string

    @Column()
    major: string

    @Column({ type: 'text', nullable: true })
    description: string

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

    @Column({ type: 'enum', enum: PaperOrderStatus, default: PaperOrderStatus.Pending })
    status: PaperOrderStatus

    @Column({ type: 'longtext', nullable: true, transformer: new JsonTransformer() })
    chapters?: any

    @Column({ type: 'longtext', nullable: true, transformer: new JsonTransformer() })
    extra?: any

    //订单号, 总价, 定金, 定金交付, 尾款, 尾款交付, 交稿状态, 接单渠道, 学历, 专业,字数(k), 查重要求, 截稿日期, 稿费结款方式, 是否结稿费

    @Column({ nullable: true })
    orderNumber: string // 订单号

    @Column({ nullable: true })
    totalPrice: string // 总价

    @Column({ nullable: true })
    deposit: string // 定金

    @Column({ nullable: true })
    depositPaid: boolean // 定金交付

    @Column({ nullable: true })
    finalPayment: string // 尾款

    @Column({ nullable: true })
    finalPaymentPaid: boolean // 尾款交付

    @Column({ nullable: true })
    deliveryStatus: string // 交稿状态

    @Column({ nullable: true })
    orderChannel: string // 接单渠道

    @Column({ nullable: true })
    education: string // 学历

    @Column({ nullable: true })
    wordCount: string // 字数(k)

    @Column({ nullable: true })
    deadline: string // 截稿日期

    @Column({ nullable: true })
    plagiarismCheck: string // 查重要求

    @Column({ nullable: true })
    paymentMethod: string // 稿费结款方式

    @Column({ nullable: true })
    paymentStatus: boolean // 是否结稿费
}
