import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 流水记录
 */
@Entity('t_recycle_transaction')
export class RecycleTransactionEntity extends BaseEntity {
  @Index()
  @Column({ comment: '用户ID' })
  userId: string;

  @Index()
  @Column({ comment: '机构ID', nullable: true })
  departmentId: number;

  @Column({ comment: '流水类型', dict: ['收入', '支出'], default: '收入' })
  type: string;

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

  @Column({
    comment: '来源类型',
    dict: ['回收', '商城', '赠送', '接受', '捐赠', '签到'],
    default: '回收',
  })
  sourceType: string;

  @Column({ comment: '备注', nullable: true })
  remark: string;

  @Index()
  @Column({ comment: '订单ID', nullable: true })
  orderId: string;
  
}