import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Member } from './Member';

@Entity('member_cash_out')
export class MemberCashOut {
  @PrimaryGeneratedColumn()
  cash_out_id: number;

  @Column({ type: 'int', default: 0, comment: '站点ID' })
  site_id: number;

  @Column({ type: 'int', comment: '会员ID' })
  member_id: number;

  @Column({ type: 'varchar', length: 50, comment: '提现单号' })
  cash_out_no: string;

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

  @Column({ type: 'decimal', precision: 10, scale: 2, default: 0, comment: '手续费' })
  fee: number;

  @Column({ type: 'decimal', precision: 10, scale: 2, comment: '实际到账金额' })
  actual_amount: number;

  @Column({ type: 'varchar', length: 50, comment: '提现方式' })
  cash_out_type: string;

  @Column({ type: 'varchar', length: 255, comment: '提现账户' })
  cash_out_account: string;

  @Column({ type: 'varchar', length: 100, comment: '收款人姓名' })
  receiver_name: string;

  @Column({ type: 'varchar', length: 20, comment: '收款人手机号' })
  receiver_mobile: string;

  @Column({ type: 'varchar', length: 255, comment: '提现备注' })
  remark: string;

  @Column({ type: 'tinyint', default: 0, comment: '状态 0:待审核 1:审核通过 2:审核拒绝 3:提现成功 4:提现失败' })
  status: number;

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

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

  @Column({ type: 'varchar', length: 50, comment: '审核人' })
  auditor: string;

  @Column({ type: 'timestamp', nullable: true, comment: '提现时间' })
  cash_out_time: Date;

  @Column({ type: 'tinyint', default: 0, comment: '是否删除 0:否 1:是' })
  is_del: number;

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

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

  // 关联关系
  @ManyToOne(() => Member, member => member.cashOuts)
  @JoinColumn({ name: 'member_id' })
  member: Member;
} 