@eventista/ticketing-common 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/database/index.d.ts +2 -0
- package/dist/database/index.js +19 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/mongodb/index.d.ts +2 -0
- package/dist/database/mongodb/index.js +19 -0
- package/dist/database/mongodb/index.js.map +1 -0
- package/dist/database/mongodb/mongodb.module.d.ts +2 -0
- package/dist/database/mongodb/mongodb.module.js +50 -0
- package/dist/database/mongodb/mongodb.module.js.map +1 -0
- package/dist/database/mongodb/mongodb.service.d.ts +29 -0
- package/dist/database/mongodb/mongodb.service.js +114 -0
- package/dist/database/mongodb/mongodb.service.js.map +1 -0
- package/dist/database/redis/index.d.ts +2 -0
- package/dist/database/redis/index.js +19 -0
- package/dist/database/redis/index.js.map +1 -0
- package/dist/database/redis/redis.module.d.ts +2 -0
- package/dist/database/redis/redis.module.js +52 -0
- package/dist/database/redis/redis.module.js.map +1 -0
- package/dist/database/redis/redis.service.d.ts +26 -0
- package/dist/database/redis/redis.service.js +126 -0
- package/dist/database/redis/redis.service.js.map +1 -0
- package/dist/exception/exception.filter.d.ts +4 -0
- package/dist/exception/exception.filter.js +35 -0
- package/dist/exception/exception.filter.js.map +1 -0
- package/dist/generic-repository/index.d.ts +4 -0
- package/dist/generic-repository/index.js +21 -0
- package/dist/generic-repository/index.js.map +1 -0
- package/dist/generic-repository/repositories/base.repository.d.ts +39 -0
- package/dist/generic-repository/repositories/base.repository.interface.d.ts +36 -0
- package/dist/generic-repository/repositories/base.repository.interface.js +3 -0
- package/dist/generic-repository/repositories/base.repository.interface.js.map +1 -0
- package/dist/generic-repository/repositories/base.repository.js +96 -0
- package/dist/generic-repository/repositories/base.repository.js.map +1 -0
- package/dist/generic-repository/services/base.service.d.ts +42 -0
- package/dist/generic-repository/services/base.service.interface.d.ts +36 -0
- package/dist/generic-repository/services/base.service.interface.js +3 -0
- package/dist/generic-repository/services/base.service.interface.js.map +1 -0
- package/dist/generic-repository/services/base.service.js +57 -0
- package/dist/generic-repository/services/base.service.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/custom.logger.d.ts +14 -0
- package/dist/logger/custom.logger.js +76 -0
- package/dist/logger/custom.logger.js.map +1 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +19 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger.module.d.ts +2 -0
- package/dist/logger/logger.module.js +27 -0
- package/dist/logger/logger.module.js.map +1 -0
- package/dist/pipes/custom-validation.pipe.d.ts +7 -0
- package/dist/pipes/custom-validation.pipe.js +69 -0
- package/dist/pipes/custom-validation.pipe.js.map +1 -0
- package/dist/response/response.interceptor.d.ts +5 -0
- package/dist/response/response.interceptor.js +29 -0
- package/dist/response/response.interceptor.js.map +1 -0
- package/dist/schemas/base.schema.d.ts +11 -0
- package/dist/schemas/base.schema.js +29 -0
- package/dist/schemas/base.schema.js.map +1 -0
- package/dist/schemas/event/event.interfaces.d.ts +69 -0
- package/dist/schemas/event/event.interfaces.js +9 -0
- package/dist/schemas/event/event.interfaces.js.map +1 -0
- package/dist/schemas/event/event.schema.d.ts +70 -0
- package/dist/schemas/event/event.schema.js +242 -0
- package/dist/schemas/event/event.schema.js.map +1 -0
- package/dist/schemas/index.d.ts +14 -0
- package/dist/schemas/index.js +31 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/order/order.interfaces.d.ts +72 -0
- package/dist/schemas/order/order.interfaces.js +31 -0
- package/dist/schemas/order/order.interfaces.js.map +1 -0
- package/dist/schemas/order/order.schema.d.ts +39 -0
- package/dist/schemas/order/order.schema.js +162 -0
- package/dist/schemas/order/order.schema.js.map +1 -0
- package/dist/schemas/promotions/promotions.interfaces.d.ts +30 -0
- package/dist/schemas/promotions/promotions.interfaces.js +14 -0
- package/dist/schemas/promotions/promotions.interfaces.js.map +1 -0
- package/dist/schemas/promotions/promotions.schema.d.ts +25 -0
- package/dist/schemas/promotions/promotions.schema.js +92 -0
- package/dist/schemas/promotions/promotions.schema.js.map +1 -0
- package/dist/schemas/rows/rows.interfaces.d.ts +14 -0
- package/dist/schemas/rows/rows.interfaces.js +3 -0
- package/dist/schemas/rows/rows.interfaces.js.map +1 -0
- package/dist/schemas/rows/rows.schema.d.ts +22 -0
- package/dist/schemas/rows/rows.schema.js +65 -0
- package/dist/schemas/rows/rows.schema.js.map +1 -0
- package/dist/schemas/schema.helper.d.ts +4 -0
- package/dist/schemas/schema.helper.js +84 -0
- package/dist/schemas/schema.helper.js.map +1 -0
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.d.ts +18 -0
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js +3 -0
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js.map +1 -0
- package/dist/schemas/ticket-classes/ticket-classes.schemas.d.ts +26 -0
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js +75 -0
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js.map +1 -0
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.d.ts +19 -0
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.js +9 -0
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.js.map +1 -0
- package/dist/schemas/ticket-summary/ticket-summary.schema.d.ts +23 -0
- package/dist/schemas/ticket-summary/ticket-summary.schema.js +65 -0
- package/dist/schemas/ticket-summary/ticket-summary.schema.js.map +1 -0
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.d.ts +26 -0
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.js +9 -0
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.js.map +1 -0
- package/dist/schemas/user-fanpass/user-fanpass.schemas.d.ts +29 -0
- package/dist/schemas/user-fanpass/user-fanpass.schemas.js +113 -0
- package/dist/schemas/user-fanpass/user-fanpass.schemas.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +40 -0
- package/src/database/index.ts +2 -0
- package/src/database/mongodb/index.ts +2 -0
- package/src/database/mongodb/mongodb.module.ts +42 -0
- package/src/database/mongodb/mongodb.service.ts +111 -0
- package/src/database/redis/index.ts +2 -0
- package/src/database/redis/redis.module.ts +45 -0
- package/src/database/redis/redis.service.ts +142 -0
- package/src/exception/exception.filter.ts +36 -0
- package/src/generic-repository/index.ts +7 -0
- package/src/generic-repository/repositories/base.repository.interface.ts +78 -0
- package/src/generic-repository/repositories/base.repository.ts +199 -0
- package/src/generic-repository/services/base.service.interface.ts +78 -0
- package/src/generic-repository/services/base.service.ts +165 -0
- package/src/index.ts +11 -0
- package/src/logger/custom.logger.ts +83 -0
- package/src/logger/index.ts +2 -0
- package/src/logger/logger.module.ts +14 -0
- package/src/pipes/custom-validation.pipe.ts +61 -0
- package/src/response/response.interceptor.ts +26 -0
- package/src/schemas/base.schema.ts +19 -0
- package/src/schemas/event/event.interfaces.ts +74 -0
- package/src/schemas/event/event.schema.ts +195 -0
- package/src/schemas/index.ts +16 -0
- package/src/schemas/order/order.interfaces.ts +78 -0
- package/src/schemas/order/order.schema.ts +120 -0
- package/src/schemas/promotions/promotions.interfaces.ts +34 -0
- package/src/schemas/promotions/promotions.schema.ts +71 -0
- package/src/schemas/rows/rows.interfaces.ts +14 -0
- package/src/schemas/rows/rows.schema.ts +47 -0
- package/src/schemas/schema.helper.ts +103 -0
- package/src/schemas/ticket-classes/ticket-classes.interfaces.ts +18 -0
- package/src/schemas/ticket-classes/ticket-classes.schemas.ts +51 -0
- package/src/schemas/ticket-summary/ticket-summary.interfaces.ts +20 -0
- package/src/schemas/ticket-summary/ticket-summary.schema.ts +46 -0
- package/src/schemas/user-fanpass/user-fanpass.interfaces.ts +28 -0
- package/src/schemas/user-fanpass/user-fanpass.schemas.ts +86 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
export enum IPaymentGatewayTypes {
|
|
3
|
+
FREE = 'free',
|
|
4
|
+
MOMO = 'momo',
|
|
5
|
+
ZALOPAY = 'zalopay',
|
|
6
|
+
ZALOPAY_VIETQR = 'zalopay_vietqr',
|
|
7
|
+
ZALOPAY_CC = 'zalopay_cc',
|
|
8
|
+
VNPAY = 'vnpay',
|
|
9
|
+
INTCARD = 'intcard',
|
|
10
|
+
PAYPAL = 'paypal',
|
|
11
|
+
PAYMENTWALL = 'paymentwall',
|
|
12
|
+
COD = 'cod',
|
|
13
|
+
MANUALLY = 'manually',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum IOrderStatus {
|
|
17
|
+
PENDING = 'PENDING',
|
|
18
|
+
REVIEW = 'REVIEW',
|
|
19
|
+
OPEN = 'OPEN',
|
|
20
|
+
SUCCESS = 'SUCCESS',
|
|
21
|
+
FAILED = 'FAILED',
|
|
22
|
+
CANCELED = 'CANCELED',
|
|
23
|
+
EXPIRED = 'EXPIRED',
|
|
24
|
+
CONFIRM = 'CONFIRM',
|
|
25
|
+
USERCANCEL = 'USERCANCEL',
|
|
26
|
+
PAYMENT = 'PAYMENT',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ProductType = 'event' | 'fanpass' | 'merchandise';
|
|
30
|
+
export type DeliveryStatus = 'pending' | 'delivered' | 'canceled';
|
|
31
|
+
export type CurrencyCode = 'VND' | 'USD';
|
|
32
|
+
|
|
33
|
+
export interface IOrderProduct {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
price: number;
|
|
37
|
+
thumbnail: string;
|
|
38
|
+
promotion: Record<string, any>;
|
|
39
|
+
quantity: number;
|
|
40
|
+
totalAmount: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IPromotionUsed {
|
|
44
|
+
code: string;
|
|
45
|
+
discountPercent: number;
|
|
46
|
+
maxValue: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IOrder {
|
|
50
|
+
_id?: string;
|
|
51
|
+
eventId: string;
|
|
52
|
+
status: IOrderStatus;
|
|
53
|
+
userId: string;
|
|
54
|
+
productType: ProductType;
|
|
55
|
+
paymentGateway?: IPaymentGatewayTypes;
|
|
56
|
+
tickets: Record<string, any>[];
|
|
57
|
+
paymentTime?: Date;
|
|
58
|
+
deliveryStatus?: DeliveryStatus;
|
|
59
|
+
products: IOrderProduct[];
|
|
60
|
+
promotionUsed?: IPromotionUsed;
|
|
61
|
+
currencyCode?: CurrencyCode;
|
|
62
|
+
originalAmount?: number;
|
|
63
|
+
originalAmountUSD?: number;
|
|
64
|
+
amount?: number;
|
|
65
|
+
amountInUSD?: number;
|
|
66
|
+
userRefId?: string;
|
|
67
|
+
confirmAt?: Date;
|
|
68
|
+
sellFromPlatform?: string;
|
|
69
|
+
cancelReason?: string;
|
|
70
|
+
quantity: number;
|
|
71
|
+
calendarId: string;
|
|
72
|
+
zoneId?: string;
|
|
73
|
+
ticketClassId: string;
|
|
74
|
+
timeCreatePayment?: number;
|
|
75
|
+
createdAt?: Date;
|
|
76
|
+
updatedAt?: Date;
|
|
77
|
+
isDeleted?: boolean;
|
|
78
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
|
|
4
|
+
import { IOrderStatus, IPaymentGatewayTypes, ProductType, DeliveryStatus, CurrencyCode, IPromotionUsed, IOrderProduct } from './order.interfaces';
|
|
5
|
+
|
|
6
|
+
export type OrderDocument = HydratedDocument<Order> & BaseDocument;
|
|
7
|
+
|
|
8
|
+
@Schema({
|
|
9
|
+
collection: 'orders',
|
|
10
|
+
...defaultSchemaOptions,
|
|
11
|
+
})
|
|
12
|
+
export class Order extends BaseSchema {
|
|
13
|
+
@Prop({
|
|
14
|
+
required: true,
|
|
15
|
+
index: true,
|
|
16
|
+
})
|
|
17
|
+
eventId: string;
|
|
18
|
+
|
|
19
|
+
@Prop({
|
|
20
|
+
required: true,
|
|
21
|
+
enum: Object.values(IOrderStatus),
|
|
22
|
+
default: IOrderStatus.PENDING,
|
|
23
|
+
index: true,
|
|
24
|
+
})
|
|
25
|
+
status: IOrderStatus;
|
|
26
|
+
|
|
27
|
+
@Prop({ required: true, index: true })
|
|
28
|
+
userId: string;
|
|
29
|
+
|
|
30
|
+
@Prop({
|
|
31
|
+
required: true,
|
|
32
|
+
enum: ['event', 'fanpass', 'merchandise'],
|
|
33
|
+
index: true,
|
|
34
|
+
})
|
|
35
|
+
productType: ProductType;
|
|
36
|
+
|
|
37
|
+
@Prop({
|
|
38
|
+
enum: Object.values(IPaymentGatewayTypes),
|
|
39
|
+
index: true,
|
|
40
|
+
})
|
|
41
|
+
paymentGateway: IPaymentGatewayTypes;
|
|
42
|
+
|
|
43
|
+
@Prop({ type: [Object], required: true, default: [] })
|
|
44
|
+
tickets: Record<string, any>[];
|
|
45
|
+
|
|
46
|
+
@Prop()
|
|
47
|
+
paymentTime: Date;
|
|
48
|
+
|
|
49
|
+
@Prop({
|
|
50
|
+
enum: ['pending', 'delivered', 'canceled'],
|
|
51
|
+
default: 'pending',
|
|
52
|
+
})
|
|
53
|
+
deliveryStatus: DeliveryStatus;
|
|
54
|
+
|
|
55
|
+
@Prop([
|
|
56
|
+
{
|
|
57
|
+
id: String,
|
|
58
|
+
name: String,
|
|
59
|
+
price: Number,
|
|
60
|
+
thumbnail: String,
|
|
61
|
+
promotion: Object,
|
|
62
|
+
quantity: Number,
|
|
63
|
+
totalAmount: Number,
|
|
64
|
+
},
|
|
65
|
+
])
|
|
66
|
+
products: IOrderProduct[];
|
|
67
|
+
|
|
68
|
+
@Prop({
|
|
69
|
+
type: {
|
|
70
|
+
code: String,
|
|
71
|
+
discountPercent: Number,
|
|
72
|
+
maxValue: Number,
|
|
73
|
+
},
|
|
74
|
+
default: {}
|
|
75
|
+
})
|
|
76
|
+
promotionUsed: IPromotionUsed;
|
|
77
|
+
|
|
78
|
+
@Prop({ enum: ['VND', 'USD'] })
|
|
79
|
+
currencyCode: CurrencyCode;
|
|
80
|
+
|
|
81
|
+
@Prop() originalAmount: number;
|
|
82
|
+
@Prop() originalAmountUSD: number;
|
|
83
|
+
@Prop() amount: number;
|
|
84
|
+
@Prop() amountInUSD: number;
|
|
85
|
+
|
|
86
|
+
@Prop() userRefId: string;
|
|
87
|
+
|
|
88
|
+
@Prop() confirmAt: Date;
|
|
89
|
+
|
|
90
|
+
@Prop({ default: 'web' })
|
|
91
|
+
sellFromPlatform: string;
|
|
92
|
+
|
|
93
|
+
@Prop({ default: '' })
|
|
94
|
+
cancelReason: string;
|
|
95
|
+
|
|
96
|
+
@Prop({ required: true })
|
|
97
|
+
quantity: number;
|
|
98
|
+
|
|
99
|
+
@Prop({ required: true })
|
|
100
|
+
calendarId: string;
|
|
101
|
+
|
|
102
|
+
@Prop() zoneId: string;
|
|
103
|
+
|
|
104
|
+
@Prop({ required: true, index: true })
|
|
105
|
+
ticketClassId: string;
|
|
106
|
+
|
|
107
|
+
@Prop()
|
|
108
|
+
timeCreatePayment: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const OrderSchema = SchemaFactory.createForClass(Order);
|
|
112
|
+
|
|
113
|
+
// Thêm các hooks và middleware
|
|
114
|
+
addSoftDeleteHooks(OrderSchema);
|
|
115
|
+
addUpdateHooks(OrderSchema);
|
|
116
|
+
|
|
117
|
+
// Thêm các index nếu cần
|
|
118
|
+
OrderSchema.index({ isDeleted: 1 });
|
|
119
|
+
OrderSchema.index({ userId: 1, status: 1 });
|
|
120
|
+
OrderSchema.index({ eventId: 1, status: 1 });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
export enum IPromotionAppliesTo {
|
|
3
|
+
EVENT = 'event',
|
|
4
|
+
TICKET = 'ticket'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IPromotionDiscount {
|
|
8
|
+
percent: number;
|
|
9
|
+
percentInUSD: number;
|
|
10
|
+
maxValue: number;
|
|
11
|
+
maxValueInUSD: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum IPromotionType {
|
|
15
|
+
AUTO = 'auto',
|
|
16
|
+
MANUALLY = 'manually'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IPromotion {
|
|
20
|
+
_id?: string;
|
|
21
|
+
eventId: string;
|
|
22
|
+
code: string;
|
|
23
|
+
appliesTo: IPromotionAppliesTo;
|
|
24
|
+
active: boolean;
|
|
25
|
+
maxUsage: number;
|
|
26
|
+
discount: IPromotionDiscount;
|
|
27
|
+
tickets: Record<string, any>[];
|
|
28
|
+
type: IPromotionType;
|
|
29
|
+
minOrderAmount: number;
|
|
30
|
+
minOrderAmountInUSD: number;
|
|
31
|
+
createdAt?: Date;
|
|
32
|
+
updatedAt?: Date;
|
|
33
|
+
isDeleted?: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
|
|
4
|
+
import { IPromotionAppliesTo, IPromotionDiscount, IPromotionType } from './promotions.interfaces';
|
|
5
|
+
|
|
6
|
+
export type PromotionDocument = HydratedDocument<Promotion> & BaseDocument;
|
|
7
|
+
@Schema({
|
|
8
|
+
collection: 'orders',
|
|
9
|
+
...defaultSchemaOptions,
|
|
10
|
+
})
|
|
11
|
+
export class Promotion extends BaseSchema {
|
|
12
|
+
|
|
13
|
+
@Prop({
|
|
14
|
+
required: true,
|
|
15
|
+
index: true,
|
|
16
|
+
})
|
|
17
|
+
eventId: string;
|
|
18
|
+
|
|
19
|
+
@Prop()
|
|
20
|
+
code: string;
|
|
21
|
+
|
|
22
|
+
@Prop({
|
|
23
|
+
enum: Object.values(IPromotionAppliesTo),
|
|
24
|
+
index: true,
|
|
25
|
+
default: IPromotionAppliesTo.EVENT,
|
|
26
|
+
})
|
|
27
|
+
appliesTo: IPromotionAppliesTo;
|
|
28
|
+
|
|
29
|
+
@Prop({
|
|
30
|
+
default: true,
|
|
31
|
+
type: Boolean,
|
|
32
|
+
})
|
|
33
|
+
active: boolean;
|
|
34
|
+
|
|
35
|
+
@Prop({
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 0,
|
|
38
|
+
})
|
|
39
|
+
maxUsage: number;
|
|
40
|
+
|
|
41
|
+
@Prop({
|
|
42
|
+
type: {
|
|
43
|
+
percent: { type: Number },
|
|
44
|
+
percentInUSD: { type: Number },
|
|
45
|
+
maxValue: { type: Number },
|
|
46
|
+
maxValueInUSD: { type: Number },
|
|
47
|
+
},
|
|
48
|
+
default: {},
|
|
49
|
+
})
|
|
50
|
+
discount: IPromotionDiscount;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@Prop({ type: [Object], required: true, default: [] })
|
|
54
|
+
tickets: Record<string, any>[];
|
|
55
|
+
|
|
56
|
+
@Prop({
|
|
57
|
+
enum: Object.values(IPromotionType),
|
|
58
|
+
})
|
|
59
|
+
type: IPromotionType;
|
|
60
|
+
|
|
61
|
+
@Prop()
|
|
62
|
+
minOrderAmount: number;
|
|
63
|
+
|
|
64
|
+
@Prop()
|
|
65
|
+
minOrderAmountInUSD: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const PromotionSchema = SchemaFactory.createForClass(Promotion);
|
|
69
|
+
addUpdateHooks(PromotionSchema);
|
|
70
|
+
addSoftDeleteHooks(PromotionSchema);
|
|
71
|
+
PromotionSchema.index({ eventId: 1, code: 1 }, { unique: true });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IRow {
|
|
2
|
+
_id?: string;
|
|
3
|
+
calendarId: string;
|
|
4
|
+
eventId: string;
|
|
5
|
+
zoneId: string;
|
|
6
|
+
seatNumberingType: string;
|
|
7
|
+
seatNumberingFrom: string;
|
|
8
|
+
seatNumberingTo: string;
|
|
9
|
+
name: string;
|
|
10
|
+
position: number;
|
|
11
|
+
createdAt?: Date;
|
|
12
|
+
updatedAt?: Date;
|
|
13
|
+
isDeleted?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
|
|
4
|
+
|
|
5
|
+
export type RowDocument = HydratedDocument<Row> & BaseDocument;
|
|
6
|
+
|
|
7
|
+
@Schema({
|
|
8
|
+
collection: 'rows',
|
|
9
|
+
...defaultSchemaOptions,
|
|
10
|
+
})
|
|
11
|
+
export class Row extends BaseSchema {
|
|
12
|
+
@Prop({})
|
|
13
|
+
calendarId: string;
|
|
14
|
+
|
|
15
|
+
@Prop({
|
|
16
|
+
required: true,
|
|
17
|
+
index: true,
|
|
18
|
+
})
|
|
19
|
+
eventId: string;
|
|
20
|
+
|
|
21
|
+
@Prop({
|
|
22
|
+
required: true,
|
|
23
|
+
index: true,
|
|
24
|
+
})
|
|
25
|
+
zoneId: string;
|
|
26
|
+
|
|
27
|
+
@Prop({})
|
|
28
|
+
seatNumberingType: string;
|
|
29
|
+
|
|
30
|
+
@Prop({})
|
|
31
|
+
seatNumberingFrom: string;
|
|
32
|
+
|
|
33
|
+
@Prop({})
|
|
34
|
+
seatNumberingTo: string;
|
|
35
|
+
|
|
36
|
+
@Prop({})
|
|
37
|
+
name: string;
|
|
38
|
+
|
|
39
|
+
@Prop({})
|
|
40
|
+
position: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const RowSchema = SchemaFactory.createForClass(Row);
|
|
44
|
+
|
|
45
|
+
// Thêm các hooks và middleware
|
|
46
|
+
addSoftDeleteHooks(RowSchema);
|
|
47
|
+
addUpdateHooks(RowSchema);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Schema, SchemaOptions } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
export const defaultSchemaOptions: SchemaOptions = {
|
|
4
|
+
timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' },
|
|
5
|
+
toJSON: {
|
|
6
|
+
virtuals: true,
|
|
7
|
+
transform: (_, ret) => {
|
|
8
|
+
delete ret.__v;
|
|
9
|
+
return ret;
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
toObject: {
|
|
13
|
+
virtuals: true,
|
|
14
|
+
transform: (_, ret) => {
|
|
15
|
+
delete ret.__v;
|
|
16
|
+
return ret;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const addSoftDeleteHooks = (schema: Schema): void => {
|
|
22
|
+
// Thêm middleware để không trả về các document đã bị xóa mềm
|
|
23
|
+
schema.pre('find', function() {
|
|
24
|
+
if (!this.getQuery().includeDeleted) {
|
|
25
|
+
this.where({ isDeleted: { $ne: true } });
|
|
26
|
+
}
|
|
27
|
+
delete this.getQuery().includeDeleted;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
schema.pre('findOne', function() {
|
|
31
|
+
if (!this.getQuery().includeDeleted) {
|
|
32
|
+
this.where({ isDeleted: { $ne: true } });
|
|
33
|
+
}
|
|
34
|
+
delete this.getQuery().includeDeleted;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
schema.pre('countDocuments', function() {
|
|
38
|
+
if (!this.getQuery().includeDeleted) {
|
|
39
|
+
this.where({ isDeleted: { $ne: true } });
|
|
40
|
+
}
|
|
41
|
+
delete this.getQuery().includeDeleted;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Thêm method để thực hiện xóa mềm
|
|
45
|
+
schema.methods.softDelete = async function() {
|
|
46
|
+
this.isDeleted = true;
|
|
47
|
+
this.updatedAt = new Date();
|
|
48
|
+
return this.save();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Thêm method để khôi phục document đã xóa mềm
|
|
52
|
+
schema.methods.restore = async function() {
|
|
53
|
+
this.isDeleted = false;
|
|
54
|
+
return this.save();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Thêm static method để thực hiện xóa mềm nhiều document
|
|
58
|
+
schema.statics.softDeleteMany = async function(filter = {}) {
|
|
59
|
+
return this.updateMany(
|
|
60
|
+
filter,
|
|
61
|
+
{
|
|
62
|
+
$set: {
|
|
63
|
+
isDeleted: true,
|
|
64
|
+
updatedAt: new Date(),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Thêm static method để khôi phục nhiều document đã xóa mềm
|
|
71
|
+
schema.statics.restoreMany = async function(filter = {}) {
|
|
72
|
+
return this.updateMany(
|
|
73
|
+
filter,
|
|
74
|
+
{
|
|
75
|
+
$set: {
|
|
76
|
+
isDeleted: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const addUpdateHooks = (schema: Schema): void => {
|
|
84
|
+
// Cập nhật updatedAt khi document được cập nhật
|
|
85
|
+
schema.pre('save', function(next) {
|
|
86
|
+
if (this.isModified()) {
|
|
87
|
+
this.updatedAt = new Date();
|
|
88
|
+
}
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
schema.pre('updateOne', function() {
|
|
93
|
+
this.set({ updatedAt: new Date() });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
schema.pre('updateMany', function() {
|
|
97
|
+
this.set({ updatedAt: new Date() });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
schema.pre('findOneAndUpdate', function() {
|
|
101
|
+
this.set({ updatedAt: new Date() });
|
|
102
|
+
});
|
|
103
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ITicketClass {
|
|
2
|
+
_id?: string;
|
|
3
|
+
eventId: string;
|
|
4
|
+
calendarId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
color: string;
|
|
7
|
+
originalPriceVn: number;
|
|
8
|
+
originalPriceUsd: number;
|
|
9
|
+
finalPriceVn: number;
|
|
10
|
+
finalPriceUsd: number;
|
|
11
|
+
description: string;
|
|
12
|
+
seatType: string;
|
|
13
|
+
maxTicketPerUser: number;
|
|
14
|
+
prototypeUrl: string;
|
|
15
|
+
createdAt?: Date;
|
|
16
|
+
updatedAt?: Date;
|
|
17
|
+
isDeleted?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
|
|
4
|
+
|
|
5
|
+
export type TicketClassDocument = HydratedDocument<TicketClass> & BaseDocument;
|
|
6
|
+
|
|
7
|
+
@Schema({
|
|
8
|
+
collection: 'ticket_classes',
|
|
9
|
+
...defaultSchemaOptions,
|
|
10
|
+
})
|
|
11
|
+
export class TicketClass extends BaseSchema {
|
|
12
|
+
@Prop({ required: true, index: true })
|
|
13
|
+
eventId: string;
|
|
14
|
+
|
|
15
|
+
@Prop({ required: true, index: true })
|
|
16
|
+
calendarId: string;
|
|
17
|
+
|
|
18
|
+
@Prop({})
|
|
19
|
+
name: string;
|
|
20
|
+
|
|
21
|
+
@Prop({})
|
|
22
|
+
color: string;
|
|
23
|
+
|
|
24
|
+
@Prop({})
|
|
25
|
+
originalPriceVn: number;
|
|
26
|
+
|
|
27
|
+
@Prop({})
|
|
28
|
+
originalPriceUsd: number;
|
|
29
|
+
|
|
30
|
+
@Prop({})
|
|
31
|
+
finalPriceVn: number;
|
|
32
|
+
|
|
33
|
+
@Prop({})
|
|
34
|
+
finalPriceUsd: number;
|
|
35
|
+
|
|
36
|
+
@Prop({})
|
|
37
|
+
description: string;
|
|
38
|
+
|
|
39
|
+
@Prop({})
|
|
40
|
+
seatType: string;
|
|
41
|
+
|
|
42
|
+
@Prop({})
|
|
43
|
+
maxTicketPerUser: number;
|
|
44
|
+
|
|
45
|
+
@Prop({})
|
|
46
|
+
prototypeUrl: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const TicketClassSchema = SchemaFactory.createForClass(TicketClass);
|
|
50
|
+
addUpdateHooks(TicketClassSchema);
|
|
51
|
+
addSoftDeleteHooks(TicketClassSchema);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export enum ITicketSummaryType {
|
|
2
|
+
ZONE = 'zone',
|
|
3
|
+
TICKET_CLASS = 'ticketClass',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ITicketSummary {
|
|
7
|
+
_id?: string;
|
|
8
|
+
eventId: string;
|
|
9
|
+
type: ITicketSummaryType;
|
|
10
|
+
referenceId: string;
|
|
11
|
+
ticketClassId: string;
|
|
12
|
+
totalTickets: number;
|
|
13
|
+
holdTickets: number;
|
|
14
|
+
soldTickets: number;
|
|
15
|
+
blockedTickets: number;
|
|
16
|
+
availableTickets: number;
|
|
17
|
+
createdAt?: Date;
|
|
18
|
+
updatedAt?: Date;
|
|
19
|
+
isDeleted?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { BaseDocument, BaseSchema, addSoftDeleteHooks, addUpdateHooks, defaultSchemaOptions } from '../index';
|
|
4
|
+
import { ITicketSummaryType } from './ticket-summary.interfaces';
|
|
5
|
+
|
|
6
|
+
export type TicketSummaryDocument = HydratedDocument<TicketSummary> & BaseDocument;
|
|
7
|
+
|
|
8
|
+
@Schema({
|
|
9
|
+
collection: 'ticket_summaries',
|
|
10
|
+
...defaultSchemaOptions,
|
|
11
|
+
})
|
|
12
|
+
export class TicketSummary extends BaseSchema {
|
|
13
|
+
|
|
14
|
+
@Prop({ required: true, index: true })
|
|
15
|
+
eventId: string;
|
|
16
|
+
|
|
17
|
+
@Prop({ required: true, enum: Object.values(ITicketSummaryType), index: true })
|
|
18
|
+
type: string;
|
|
19
|
+
|
|
20
|
+
@Prop({ required: true, index: true })
|
|
21
|
+
referenceId: string;
|
|
22
|
+
|
|
23
|
+
@Prop({ required: false })
|
|
24
|
+
ticketClassId: string;
|
|
25
|
+
|
|
26
|
+
@Prop({ required: true, default: 0 })
|
|
27
|
+
totalTickets: number;
|
|
28
|
+
|
|
29
|
+
@Prop({ default: 0 })
|
|
30
|
+
holdTickets: number;
|
|
31
|
+
|
|
32
|
+
@Prop({ default: 0 })
|
|
33
|
+
soldTickets: number;
|
|
34
|
+
|
|
35
|
+
@Prop({ default: 0 })
|
|
36
|
+
blockedTickets: number;
|
|
37
|
+
|
|
38
|
+
@Prop({ required: true, default: 0 })
|
|
39
|
+
availableTickets: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const TicketSummarySchema = SchemaFactory.createForClass(TicketSummary);
|
|
43
|
+
addUpdateHooks(TicketSummarySchema);
|
|
44
|
+
addSoftDeleteHooks(TicketSummarySchema);
|
|
45
|
+
|
|
46
|
+
TicketSummarySchema.index({ eventId: 1, type: 1, referenceId: 1 }, { unique: true });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export enum IUserFanpassStatus {
|
|
2
|
+
ACTIVE = 'ACTIVE',
|
|
3
|
+
INACTIVE = 'INACTIVE',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface IUserFanpassPaymentInfo{
|
|
7
|
+
name: string;
|
|
8
|
+
email: string;
|
|
9
|
+
phoneNumber: string;
|
|
10
|
+
address: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IUserFanpass {
|
|
14
|
+
_id?: string;
|
|
15
|
+
orderId: string;
|
|
16
|
+
ticketId: string;
|
|
17
|
+
ticketType: string;
|
|
18
|
+
ticketDescription: string;
|
|
19
|
+
ticketPrice: number;
|
|
20
|
+
userId: string;
|
|
21
|
+
status: IUserFanpassStatus;
|
|
22
|
+
paymentTime?: Date;
|
|
23
|
+
paymentGateway?: string;
|
|
24
|
+
paymentInfo: IUserFanpassPaymentInfo;
|
|
25
|
+
createdAt?: Date;
|
|
26
|
+
updatedAt?: Date;
|
|
27
|
+
isDeleted?: boolean;
|
|
28
|
+
}
|