payment.entity.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
  2. import { PaymentStatus } from './payment.types.js';
  3. @Entity('payments')
  4. export class PaymentEntity {
  5. @PrimaryGeneratedColumn({ comment: '支付记录ID' })
  6. id!: number;
  7. @Column({ type: 'int', unsigned: true, name: 'external_order_id', comment: '外部订单ID(用于与业务系统集成)' })
  8. externalOrderId!: number;
  9. @Column({ type: 'int', unsigned: true, name: 'user_id', comment: '用户ID' })
  10. userId!: number;
  11. @Column({ type: 'int', unsigned: true, name: 'total_amount', comment: '支付金额(分)' })
  12. totalAmount!: number;
  13. @Column({ type: 'varchar', length: 128, name: 'description', comment: '支付描述' })
  14. description!: string;
  15. @Column({
  16. type: 'enum',
  17. enum: PaymentStatus,
  18. default: PaymentStatus.PENDING,
  19. name: 'payment_status',
  20. comment: '支付状态'
  21. })
  22. paymentStatus!: PaymentStatus;
  23. @Column({ type: 'varchar', length: 64, nullable: true, name: 'wechat_transaction_id', comment: '微信支付交易ID' })
  24. wechatTransactionId?: string;
  25. @Column({ type: 'varchar', length: 64, nullable: true, name: 'out_trade_no', comment: '商户订单号' })
  26. outTradeNo?: string;
  27. @Column({ type: 'varchar', length: 64, name: 'openid', comment: '用户OpenID' })
  28. openid!: string;
  29. @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
  30. createdAt!: Date;
  31. @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
  32. updatedAt!: Date;
  33. }