| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
- import { Order } from './order.entity';
- import { Goods } from '@d8d/goods-module';
- import { Supplier } from '@d8d/supplier-module';
- import { File } from '@d8d/file-module';
- @Entity('orders_goods')
- export class OrderGoods {
- @PrimaryGeneratedColumn({ unsigned: true })
- id!: number;
- @Column({ name: 'order_id', type: 'int', unsigned: true, comment: '订单表id' })
- orderId!: number;
- @Column({ name: 'order_no', type: 'varchar', length: 50, nullable: true, comment: '订单号' })
- orderNo!: string | null;
- @Column({ name: 'goods_id', type: 'int', unsigned: true, comment: '商品id' })
- goodsId!: number;
- @Column({ name: 'goods_name', type: 'varchar', length: 255, nullable: true, comment: '商品名称' })
- goodsName!: string | null;
- @Column({ name: 'goods_type', type: 'int', default: 1, comment: '1实物产品2虚拟订单' })
- goodsType!: number;
- @Column({ name: 'supplier_id', type: 'int', unsigned: true, nullable: true, comment: '供货商id' })
- supplierId!: number | null;
- @Column({ name: 'cost_price', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '成本价' })
- costPrice!: number;
- @Column({ name: 'price', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '售价' })
- price!: number;
- @Column({ name: 'num', type: 'int', default: 0, comment: '数量' })
- num!: number;
- @Column({ name: 'freight_amount', type: 'decimal', precision: 10, scale: 2, default: 0.00, comment: '运费' })
- freightAmount!: number;
- @Column({ name: 'state', type: 'int', default: 0, comment: '状态(0未发货、1已发货)' })
- state!: number;
- @Column({ name: 'express_name', type: 'varchar', length: 255, nullable: true, comment: '快递名称' })
- expressName!: string | null;
- @Column({ name: 'express_no', type: 'int', nullable: true, comment: '单号' })
- expressNo!: number | null;
- @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
- createdAt!: Date;
- @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
- updatedAt!: Date;
- @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建人ID' })
- createdBy!: number | null;
- @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新人ID' })
- updatedBy!: number | null;
- @Column({ name: 'image_file_id', type: 'int', unsigned: true, nullable: true, comment: '商品图片文件ID' })
- imageFileId!: number | null;
- // 关联关系
- @ManyToOne(() => Order)
- @JoinColumn({ name: 'order_id', referencedColumnName: 'id' })
- order!: Order;
- @ManyToOne(() => Goods)
- @JoinColumn({ name: 'goods_id', referencedColumnName: 'id' })
- goods!: Goods;
- @ManyToOne(() => Supplier)
- @JoinColumn({ name: 'supplier_id', referencedColumnName: 'id' })
- supplier!: Supplier;
- @ManyToOne(() => File, { nullable: true })
- @JoinColumn({ name: 'image_file_id', referencedColumnName: 'id' })
- imageFile!: File | null;
- }
|