wechat-coupon.entity.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
  2. import { WechatCouponStock } from './wechat-coupon-stock.entity';
  3. @Entity('wechat_coupons')
  4. export class WechatCoupon {
  5. @PrimaryGeneratedColumn({ unsigned: true })
  6. id!: number;
  7. @Column({ name: 'coupon_id', type: 'varchar', length: 32, unique: true, comment: '微信支付代金券ID' })
  8. couponId!: string;
  9. @Column({ name: 'stock_id', type: 'varchar', length: 32, comment: '批次号' })
  10. stockId!: string;
  11. @Column({ name: 'openid', type: 'varchar', length: 64, comment: '用户openid' })
  12. openid!: string;
  13. @Column({ name: 'out_request_no', type: 'varchar', length: 64, comment: '商户请求单号' })
  14. outRequestNo!: string;
  15. @Column({ name: 'coupon_status', type: 'varchar', length: 20, default: 'SENDED', comment: '代金券状态:SENDED-已发放,USED-已使用,EXPIRED-已过期' })
  16. couponStatus!: string;
  17. @Column({ name: 'amount', type: 'int', comment: '代金券面额(分)' })
  18. amount!: number;
  19. @Column({ name: 'available_start_time', type: 'datetime', comment: '可用开始时间' })
  20. availableStartTime!: Date;
  21. @Column({ name: 'available_end_time', type: 'datetime', comment: '可用结束时间' })
  22. availableEndTime!: Date;
  23. @Column({ name: 'used_time', type: 'datetime', nullable: true, comment: '使用时间' })
  24. usedTime!: Date | null;
  25. @Column({ name: 'transaction_id', type: 'varchar', length: 64, nullable: true, comment: '微信支付订单号' })
  26. transactionId!: string | null;
  27. @Column({ name: 'stock_id_ref', type: 'int', unsigned: true, comment: '批次ID' })
  28. stockIdRef!: number;
  29. @ManyToOne(() => WechatCouponStock)
  30. @JoinColumn({ name: 'stock_id_ref' })
  31. stock!: WechatCouponStock;
  32. @Column({ name: 'created_by', type: 'int', nullable: true, comment: '创建用户ID' })
  33. createdBy!: number | null;
  34. @Column({ name: 'updated_by', type: 'int', nullable: true, comment: '更新用户ID' })
  35. updatedBy!: number | null;
  36. @CreateDateColumn({ name: 'created_at' })
  37. createdAt!: Date;
  38. @UpdateDateColumn({ name: 'updated_at' })
  39. updatedAt!: Date;
  40. }