mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 01:48:12 +00:00
Package inquiry, UAT related update
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||
import { PrismaService } from '../../common/prisma.service';
|
||||
import { CurrencyService } from '../currency/currency.service';
|
||||
import { CreatePackageDto, BookPackageDto, UpdatePriceTierDto, CreatePriceTierDto } from './packages.dto';
|
||||
import { CreatePackageDto, BookPackageDto, UpdatePriceTierDto, CreatePriceTierDto, CreateInquiryDto } from './packages.dto';
|
||||
import { Currency } from '@prisma/client';
|
||||
|
||||
function generateRef(): string {
|
||||
@@ -17,6 +17,53 @@ export class PackagesService {
|
||||
private readonly currencyService: CurrencyService,
|
||||
) {}
|
||||
|
||||
async createInquiry(dto: CreateInquiryDto) {
|
||||
return this.prisma.packageInquiry.create({
|
||||
data: {
|
||||
packageId: dto.packageId,
|
||||
priceTierId: dto.priceTierId ?? null,
|
||||
travelerCount: dto.travelerCount,
|
||||
contactName: dto.contactName,
|
||||
contactEmail: dto.contactEmail ?? null,
|
||||
contactPhone: dto.contactPhone ?? null,
|
||||
notes: dto.notes ?? null,
|
||||
enquiredAt: new Date(),
|
||||
},
|
||||
include: { package: { select: { id: true, name: true, code: true } }, priceTier: { select: { id: true, label: true } } },
|
||||
});
|
||||
}
|
||||
|
||||
async listInquiries({ packageId, status, page = 1, pageSize = 20 }: { packageId?: string; status?: string; page?: number; pageSize?: number }) {
|
||||
const where: any = {};
|
||||
if (packageId) where.packageId = packageId;
|
||||
if (status) where.status = status;
|
||||
const skip = (page - 1) * pageSize;
|
||||
const [items, total] = await Promise.all([
|
||||
this.prisma.packageInquiry.findMany({
|
||||
where,
|
||||
include: { package: { select: { id: true, name: true, code: true } }, priceTier: { select: { id: true, label: true, priceMinor: true } } },
|
||||
orderBy: { enquiredAt: 'desc' },
|
||||
skip,
|
||||
take: pageSize,
|
||||
}),
|
||||
this.prisma.packageInquiry.count({ where }),
|
||||
]);
|
||||
return { items, total, page, pageSize };
|
||||
}
|
||||
|
||||
async updateInquiryStatus(id: string, status: string) {
|
||||
const inquiry = await this.prisma.packageInquiry.findUnique({ where: { id } });
|
||||
if (!inquiry) throw new NotFoundException('Inquiry not found');
|
||||
return this.prisma.packageInquiry.update({ where: { id }, data: { status } });
|
||||
}
|
||||
|
||||
async deleteInquiry(id: string) {
|
||||
const inquiry = await this.prisma.packageInquiry.findUnique({ where: { id } });
|
||||
if (!inquiry) throw new NotFoundException('Inquiry not found');
|
||||
await this.prisma.packageInquiry.delete({ where: { id } });
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
listActive() {
|
||||
const now = new Date();
|
||||
return this.prisma.travelPackage.findMany({
|
||||
|
||||
Reference in New Issue
Block a user