Cài đặt tính năng hiển thị chi phí

This commit is contained in:
2026-06-15 20:20:34 +07:00
parent 879f20985c
commit f52580717f
8 changed files with 319 additions and 42 deletions
+4 -1
View File
@@ -159,12 +159,15 @@ let TourController = class TourController {
this.prisma = prisma;
}
async createTour(body, req) {
const { title, startDate, endDate } = body;
const { title, startDate, endDate, adultCount, childCount, childDiscount } = body;
return this.prisma.tour.create({
data: {
title,
startDate: startDate ? new Date(startDate) : null,
endDate: endDate ? new Date(endDate) : null,
adultCount: adultCount || 1,
childCount: childCount || 0,
childDiscount: childDiscount || 0,
createdById: req.user.id,
participants: {
create: {
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "Tour" ADD COLUMN "adultCount" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "childCount" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN "childDiscount" INTEGER NOT NULL DEFAULT 30;
+4
View File
@@ -83,6 +83,10 @@ model Tour {
createdAt DateTime @default(now())
totalCost Decimal @default(0) @db.Decimal(15, 2)
adultCount Int @default(1)
childCount Int @default(0)
childDiscount Int @default(30)
createdById String
creator User @relation("TourCreator", fields: [createdById], references: [id])
+4 -1
View File
@@ -108,12 +108,15 @@ class TourController {
@UseGuards(JwtAuthGuard)
@Post()
async createTour(@Body() body: any, @Req() req: any) {
const { title, startDate, endDate } = body;
const { title, startDate, endDate, adultCount, childCount, childDiscount } = body;
return this.prisma.tour.create({
data: {
title,
startDate: startDate ? new Date(startDate) : null,
endDate: endDate ? new Date(endDate) : null,
adultCount: adultCount || 1,
childCount: childCount || 0,
childDiscount: childDiscount || 0,
createdById: req.user.id,
participants: {
create: {