Trần Viết Sơn commited on
Commit
0b96899
·
1 Parent(s): 9a9923b
backend/order-item.entity.ts DELETED
@@ -1,37 +0,0 @@
1
- import {
2
- BaseEntity,
3
- Column,
4
- Entity,
5
- JoinColumn,
6
- ManyToOne,
7
- PrimaryGeneratedColumn,
8
- Relation,
9
- } from 'typeorm';
10
- import { BranchMenuEntity } from './branch-menu.entity.js';
11
- import { OrderEntity } from './order.entity.js';
12
-
13
- @Entity('order_items')
14
- export class OrderItemEntity extends BaseEntity {
15
- @PrimaryGeneratedColumn()
16
- id: number;
17
-
18
- @Column()
19
- order_id: string;
20
-
21
- @ManyToOne(() => OrderEntity, (a) => a.order_items)
22
- @JoinColumn({ name: 'order_id' })
23
- order: Relation<OrderEntity>;
24
-
25
- @Column()
26
- branch_menu_id: string;
27
-
28
- @ManyToOne(() => BranchMenuEntity)
29
- @JoinColumn({ name: 'menu_id' })
30
- branch_menu: Relation<BranchMenuEntity>;
31
-
32
- @Column()
33
- quantity: number;
34
-
35
- @Column()
36
- price: number;
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/order.entity.ts DELETED
@@ -1,68 +0,0 @@
1
- import {
2
- BaseEntity,
3
- Column,
4
- Entity,
5
- JoinColumn,
6
- ManyToOne,
7
- OneToMany,
8
- OneToOne,
9
- PrimaryGeneratedColumn,
10
- Relation,
11
- } from 'typeorm';
12
- import { BranchEntity } from './branch.entity.js';
13
- import { UserEntity } from './user.entity.js';
14
- import { OrderType } from '../common/enums/OrderType.enum.js';
15
- import { OrderStatus } from '../common/enums/OrderStatus.enum.js';
16
- import { OrderItemEntity } from './order-item.entity.js';
17
- import { PaymentEntity } from './payment.entity.js';
18
-
19
- @Entity('orders')
20
- export class OrderEntity extends BaseEntity {
21
- @PrimaryGeneratedColumn('uuid')
22
- id: string;
23
-
24
- @Column({ nullable: true })
25
- customer_id: string;
26
-
27
- @ManyToOne(() => UserEntity, { nullable: true })
28
- customer: Relation<UserEntity>;
29
-
30
- @Column()
31
- branch_id: string;
32
-
33
- @ManyToOne(() => BranchEntity)
34
- @JoinColumn({ name: 'branch_id' })
35
- branch: Relation<BranchEntity>;
36
-
37
- @Column()
38
- employee_id: string;
39
-
40
- @ManyToOne(() => UserEntity)
41
- @JoinColumn({ name: 'employee_id' })
42
- employee: Relation<UserEntity>;
43
-
44
- @Column({ nullable: true })
45
- table_number: number;
46
-
47
- @Column()
48
- total_value: number;
49
-
50
- @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
51
- create_at: Date;
52
-
53
- @Column({ type: 'enum', enum: OrderType, default: OrderType.ONLINE })
54
- order_type: OrderType;
55
-
56
- @Column({ type: 'enum', enum: OrderStatus, default: OrderStatus.PENDING })
57
- order_status: OrderStatus;
58
-
59
- @OneToMany(() => OrderItemEntity, (a) => a.order)
60
- order_items: Relation<OrderItemEntity>[];
61
-
62
- @Column({ nullable: true })
63
- payment_id: number;
64
-
65
- @OneToOne(() => PaymentEntity, (a) => a.order)
66
- @JoinColumn()
67
- payment: Relation<PaymentEntity>;
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/payment.entity.ts DELETED
@@ -1,28 +0,0 @@
1
- import {
2
- BaseEntity,
3
- Column,
4
- Entity,
5
- JoinColumn,
6
- ManyToOne,
7
- OneToOne,
8
- PrimaryGeneratedColumn,
9
- Relation,
10
- } from 'typeorm';
11
- import { BranchMenuEntity } from './branch-menu.entity.js';
12
- import { OrderEntity } from './order.entity.js';
13
- import { PaymentMethod } from '../common/enums/PaymentMethod.enum.js';
14
-
15
- @Entity('payments')
16
- export class PaymentEntity extends BaseEntity {
17
- @PrimaryGeneratedColumn()
18
- id: number;
19
-
20
- @OneToOne(() => OrderEntity, (a) => a.payment)
21
- order: Relation<OrderEntity>;
22
-
23
- @Column({ type: 'enum', enum: PaymentMethod, default: PaymentMethod.CASH })
24
- payment_method: PaymentMethod; // E.g., 'Cash', 'Credit Card', 'Online Payment'
25
-
26
- @Column()
27
- value: number;
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/src/common/enums/OrderStatus.enum.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ export enum OrderStatus {
2
+ PENDING = 'pending', // KH đặt hàng đã thanh toán online, nhân viên chưa xác nhận <online>
3
+ CONFIRMED = 'confirmed', // nhân viên xác nhận và chuyển sang trạng thái <online>
4
+ PREPARING = 'preparing', // nhân viên xác nhận và sang trạng thái preparing này ngay lập tức <online/offline>
5
+ DELIVERING = 'delivering', // dang giao hàng <online>
6
+ DONE = 'done', // <online, offline>
7
+ }
backend/src/common/enums/OrderType.enum.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export enum OrderType {
2
+ TAKE_AWAY = 'take_away',
3
+ OFFLINE = 'offline',
4
+ ONLINE = 'online',
5
+ }
backend/src/common/enums/PaymentMethod.enum.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export enum PaymentMethod {
2
+ CASH = 'cash',
3
+ CARD = 'card',
4
+ ONLINE_PAYMENT = 'online_payment',
5
+ }