import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';

/**
 * 字典信息
 */
@Entity('dj_order')
export class OrderEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: '订单号' })
  orderNo: string;

  @Index({ unique: true })
  @Column({ comment: '商户订单号' })
  outOrderNo: string;

  @Column({ comment: '交易号', nullable: true })
  traceNo: string;

  @Column({ comment: '支付方式' })
  payType: string;

  @Column({ comment: '通道码' })
  code: string;

  @Column({ comment: '商户号' })
  mchId: string;

  @Column({ comment: '用户ID' })
  userId: string;

  @Column({ comment: '用户IP' })
  userIp: string;

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

  @Column({ comment: '货币单位' })
  currency: string;
  
  @Column({ comment: '通道手续费', type: 'decimal', precision: 10, scale: 2 })
  channelCharge: number;

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

  @Column({ comment: '付款时间', nullable: true })
  date: Date;

  @Column({ comment: '同步返回地址', length: 1000, nullable: true })
  returnUrl: string;

  @Column({ comment: '通知地址', length: 1000, nullable: true })
  notifyUrl: string;

  @Column({
    comment: '订单状态 0-待支付 1 已支付 2 支付失败 3 订单取消',
    type: 'tinyint',
    default: 0,
  })
  status: number;

  @Column({
    comment: '订单状态 0-未通知 1 已通知 2 通知失败',
    type: 'tinyint',
    default: 0,
  })
  notifyStatus: number;

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

  @Column({ comment: '支付地址', nullable: true, length: 2000 })
  payUrl: string;
}
