order-goods.mt.entity.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
  2. import { OrderMt } from './order.mt.entity';
  3. import { GoodsMt } from '@d8d/goods-module-mt';
  4. import { SupplierMt } from '@d8d/supplier-module-mt';
  5. import { FileMt } from '@d8d/file-module-mt';
  6. @Entity('orders_goods_mt')
  7. @Index(['tenantId'])
  8. @Index(['tenantId', 'id'])
  9. @Index(['tenantId', 'orderId'])
  10. @Index(['tenantId', 'goodsId'])
  11. @Index(['tenantId', 'supplierId'])
  12. export class OrderGoodsMt {
  13. @PrimaryGeneratedColumn({ unsigned: true })
  14. id!: number;
  15. @Column({ name: 'tenant_id', type: 'int', unsigned: true, comment: '租户ID' })
  16. tenantId!: number;
  17. @Column({ name: 'order_id', type: 'int', unsigned: true, comment: '订单表id' })
  18. orderId!: number;
  19. @Column({ name: 'order_no', type: 'varchar', length: 50, nullable: true, comment: '订单号' })
  20. orderNo!: string | null;
  21. @Column({ name: 'goods_id', type: 'int', unsigned: true, comment: '商品id' })
  22. goodsId!: number;
  23. @Column({ name: 'goods_name', type: 'varchar', length: 255, nullable: true, comment: '商品名称' })
  24. goodsName!: string | null;
  25. @Column({ name: 'goods_type', type: 'int', default: 1, comment: '1实物产品2虚拟订单' })
  26. goodsType!: number;
  27. @Column({ name: 'supplier_id', type: 'int', unsigned: true, nullable: true, comment: '供货商id' })
  28. supplierId!: number | null;
  29. @Column({ name: 'cost_price', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '成本价' })
  30. costPrice!: number;
  31. @Column({ name: 'price', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '售价' })
  32. price!: number;
  33. @Column({ name: 'num', type: 'int', default: 0, comment: '数量' })
  34. num!: number;
  35. @Column({ name: 'freight_amount', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '运费' })
  36. freightAmount!: number;
  37. @Column({ name: 'state', type: 'int', default: 0, comment: '状态(0未发货、1已发货)' })
  38. state!: number;
  39. @Column({ name: 'express_name', type: 'varchar', length: 255, nullable: true, comment: '快递名称' })
  40. expressName!: string | null;
  41. @Column({ name: 'express_no', type: 'int', nullable: true, comment: '单号' })
  42. expressNo!: number | null;
  43. @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  44. createdAt!: Date;
  45. @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  46. updatedAt!: Date;
  47. @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建人ID' })
  48. createdBy!: number | null;
  49. @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新人ID' })
  50. updatedBy!: number | null;
  51. @Column({ name: 'image_file_id', type: 'int', unsigned: true, nullable: true, comment: '商品图片文件ID' })
  52. imageFileId!: number | null;
  53. // 关联关系
  54. @ManyToOne(() => OrderMt)
  55. @JoinColumn({ name: 'order_id', referencedColumnName: 'id' })
  56. order!: OrderMt;
  57. @ManyToOne(() => GoodsMt)
  58. @JoinColumn({ name: 'goods_id', referencedColumnName: 'id' })
  59. goods!: GoodsMt;
  60. @ManyToOne(() => SupplierMt)
  61. @JoinColumn({ name: 'supplier_id', referencedColumnName: 'id' })
  62. supplier!: SupplierMt;
  63. @ManyToOne(() => FileMt, { nullable: true })
  64. @JoinColumn({ name: 'image_file_id', referencedColumnName: 'id' })
  65. imageFile!: FileMt | null;
  66. }