import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './user.entity';

@Entity('mkt_invite_withdrawals')
export class MktInviteWithdrawal {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Column({ type: 'bigint', unsigned: true, comment: '活动ID' })
  @Index()
  activity_id: number;

  @Column({ type: 'bigint', unsigned: true, comment: '用户ID' })
  @Index()
  user_id: number;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'user_id' })
  user: User;

  @Column({ type: 'decimal', precision: 10, scale: 2, comment: '提现金额' })
  amount: number;

  @Column({
    type: 'enum',
    enum: ['pending', 'approved', 'rejected', 'paid'],
    default: 'pending',
    comment: '状态'
  })
  @Index()
  status: 'pending' | 'approved' | 'rejected' | 'paid';

  @Column({ type: 'varchar', length: 500, nullable: true, comment: '拒绝原因' })
  reject_reason: string;

  @Column({ type: 'bigint', unsigned: true, nullable: true, comment: '审核人ID' })
  reviewer_id: number;

  @Column({ type: 'datetime', nullable: true, comment: '审核时间' })
  reviewed_at: Date;

  @Column({ type: 'datetime', nullable: true, comment: '打款时间' })
  paid_at: Date;

  @CreateDateColumn({ comment: '创建时间' })
  created_at: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  updated_at: Date;
}
