order-goods.entity.ts 3.0 KB

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