Compare commits
2 Commits
5e87ab84d1
...
daff265584
| Author | SHA1 | Date | |
|---|---|---|---|
| daff265584 | |||
| 0f5061a129 |
@@ -1212,6 +1212,21 @@ export class ItineraryService {
|
||||
checkInAddress: true,
|
||||
checkInLat: true,
|
||||
checkInLong: true,
|
||||
checkInCity: {
|
||||
select: {
|
||||
id: true,
|
||||
cityName: true,
|
||||
},
|
||||
},
|
||||
checkOutAddress: true,
|
||||
checkOutLat: true,
|
||||
checkOutLong: true,
|
||||
checkOutCity: {
|
||||
select: {
|
||||
id: true,
|
||||
cityName: true,
|
||||
},
|
||||
},
|
||||
foodAvailable: true,
|
||||
foodIsChargeable: true,
|
||||
trainerAvailable: true,
|
||||
@@ -1410,6 +1425,7 @@ export class ItineraryService {
|
||||
paxCount: item.paxCount,
|
||||
totalAmount: item.totalAmount,
|
||||
bookingStatus: item.bookingStatus,
|
||||
activityPrice: item.totalAmount,
|
||||
activity: item.activity
|
||||
? {
|
||||
id: item.activity.id,
|
||||
@@ -1419,6 +1435,28 @@ export class ItineraryService {
|
||||
checkInAddress: item.activity.checkInAddress,
|
||||
checkInLat: item.activity.checkInLat,
|
||||
checkInLong: item.activity.checkInLong,
|
||||
checkInCityName: item.activity.checkInCity?.cityName ?? null,
|
||||
checkOutAddress: item.activity.checkOutAddress,
|
||||
checkOutLat: item.activity.checkOutLat,
|
||||
checkOutLong: item.activity.checkOutLong,
|
||||
checkOutCityName:
|
||||
item.activity.checkOutCity?.cityName ?? null,
|
||||
pickUpLocation: item.activity.pickUpDropAvailable
|
||||
? {
|
||||
address: item.activity.checkInAddress,
|
||||
cityName: item.activity.checkInCity?.cityName ?? null,
|
||||
lat: item.activity.checkInLat,
|
||||
long: item.activity.checkInLong,
|
||||
}
|
||||
: null,
|
||||
dropLocation: item.activity.pickUpDropAvailable
|
||||
? {
|
||||
address: item.activity.checkOutAddress,
|
||||
cityName: item.activity.checkOutCity?.cityName ?? null,
|
||||
lat: item.activity.checkOutLat,
|
||||
long: item.activity.checkOutLong,
|
||||
}
|
||||
: null,
|
||||
coverImage: coverImage?.mediaFileName ?? null,
|
||||
coverImagePresignedUrl: await attachPresignedUrl(
|
||||
coverImage?.mediaFileName,
|
||||
@@ -1487,6 +1525,9 @@ export class ItineraryService {
|
||||
locationLat: pickUpDetail.locationLat,
|
||||
locationLong: pickUpDetail.locationLong,
|
||||
locationAddress: pickUpDetail.locationAddress,
|
||||
cityName: pickUpDetail.isPickUp
|
||||
? item.activity.checkInCity?.cityName ?? null
|
||||
: item.activity.checkOutCity?.cityName ?? null,
|
||||
transportBasePrice: pickUpDetail.transportBasePrice,
|
||||
transportTotalPrice: pickUpDetail.transportTotalPrice,
|
||||
}),
|
||||
@@ -2202,6 +2243,24 @@ export class ItineraryService {
|
||||
venueName: true,
|
||||
venueLabel: true,
|
||||
venueCapacity: true,
|
||||
ActivityPrices: {
|
||||
where: {
|
||||
isActive: true,
|
||||
deletedAt: null,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'asc',
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noOfSession: true,
|
||||
isPackage: true,
|
||||
sessionValidity: true,
|
||||
sessionValidityFrequency: true,
|
||||
basePrice: true,
|
||||
sellPrice: true,
|
||||
},
|
||||
},
|
||||
ActivityVenueArtifacts: {
|
||||
where: {
|
||||
isActive: true,
|
||||
@@ -2378,6 +2437,7 @@ export class ItineraryService {
|
||||
venueXid: venue.id,
|
||||
venueName: venue.venueName,
|
||||
venueLabel: venue.venueLabel,
|
||||
activityPrices: venue.ActivityPrices,
|
||||
mediaFileName: venue.ActivityVenueArtifacts[0]?.mediaFileName ?? null,
|
||||
mediaType: venue.ActivityVenueArtifacts[0]?.mediaType ?? null,
|
||||
venueCapacity: venue.venueCapacity,
|
||||
@@ -2425,12 +2485,64 @@ export class ItineraryService {
|
||||
new Date(second!.startDateTime).getTime(),
|
||||
);
|
||||
|
||||
const venuePriceDetails = activity.ActivityVenues.map((venue) => {
|
||||
const prices = venue.ActivityPrices.map((price) => ({
|
||||
id: price.id,
|
||||
noOfSession: price.noOfSession,
|
||||
isPackage: price.isPackage,
|
||||
sessionValidity: price.sessionValidity,
|
||||
sessionValidityFrequency: price.sessionValidityFrequency,
|
||||
basePrice: price.basePrice,
|
||||
sellPrice: price.sellPrice,
|
||||
}));
|
||||
|
||||
const lowestPrice = venue.ActivityPrices.reduce(
|
||||
(lowest, current) =>
|
||||
!lowest || current.sellPrice < lowest.sellPrice ? current : lowest,
|
||||
null as (typeof venue.ActivityPrices)[number] | null,
|
||||
);
|
||||
|
||||
return {
|
||||
venueXid: venue.id,
|
||||
venueName: venue.venueName,
|
||||
venueLabel: venue.venueLabel,
|
||||
venueCapacity: venue.venueCapacity,
|
||||
availableSeats: venue.availableSeats,
|
||||
activityPrice: lowestPrice?.sellPrice ?? null,
|
||||
activityBasePrice: lowestPrice?.basePrice ?? null,
|
||||
activityPriceDetails: lowestPrice,
|
||||
prices,
|
||||
};
|
||||
});
|
||||
|
||||
const lowestPriceVenue = venuePriceDetails.reduce(
|
||||
(lowest, current) => {
|
||||
if (!lowest) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (lowest.activityPrice === null) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (current.activityPrice === null) {
|
||||
return lowest;
|
||||
}
|
||||
|
||||
return current.activityPrice < lowest.activityPrice ? current : lowest;
|
||||
},
|
||||
null as (typeof venuePriceDetails)[number] | null,
|
||||
);
|
||||
|
||||
const coverImage =
|
||||
activity.ActivitiesMedia.find((media) => media.isCoverImage) ??
|
||||
activity.ActivitiesMedia[0] ??
|
||||
null;
|
||||
|
||||
const energyLevel = activity.activityType?.energyLevel ?? null;
|
||||
const lowestActivityPrice = lowestPriceVenue?.activityPrice ?? null;
|
||||
const lowestActivityBasePrice = lowestPriceVenue?.activityBasePrice ?? null;
|
||||
const lowestActivityPriceDetails = lowestPriceVenue?.activityPriceDetails ?? null;
|
||||
|
||||
return {
|
||||
userBucketInterestedXid: entry.id,
|
||||
@@ -2438,6 +2550,12 @@ export class ItineraryService {
|
||||
isBucket: entry.isBucket,
|
||||
bucketTypeName: entry.bucketTypeName,
|
||||
distance,
|
||||
activityPrice: lowestActivityPrice,
|
||||
activityBasePrice: lowestActivityBasePrice,
|
||||
activityPriceDetails: lowestActivityPriceDetails,
|
||||
lowestActivityPrice,
|
||||
lowestActivityBasePrice,
|
||||
lowestActivityPriceDetails,
|
||||
activityTitle: activity.activityTitle,
|
||||
activityDescription: activity.activityDescription,
|
||||
activityDurationMins,
|
||||
@@ -2445,13 +2563,19 @@ export class ItineraryService {
|
||||
activityCoverImagePresignedUrl: await attachPresignedUrl(
|
||||
coverImage?.mediaFileName,
|
||||
),
|
||||
venue: availableSlotsWithPresignedUrl[0]
|
||||
venue: lowestPriceVenue
|
||||
? {
|
||||
venueXid: availableSlotsWithPresignedUrl[0].venueXid,
|
||||
venueName: availableSlotsWithPresignedUrl[0].venueName,
|
||||
venueLabel: availableSlotsWithPresignedUrl[0].venueLabel,
|
||||
venueXid: lowestPriceVenue.venueXid,
|
||||
venueName: lowestPriceVenue.venueName,
|
||||
venueLabel: lowestPriceVenue.venueLabel,
|
||||
venueCapacity: lowestPriceVenue.venueCapacity,
|
||||
availableSeats: lowestPriceVenue.availableSeats,
|
||||
activityPrice: lowestPriceVenue.activityPrice,
|
||||
activityBasePrice: lowestPriceVenue.activityBasePrice,
|
||||
activityPriceDetails: lowestPriceVenue.activityPriceDetails,
|
||||
}
|
||||
: null,
|
||||
venuePrices: venuePriceDetails,
|
||||
availableSlots: availableSlotsWithPresignedUrl,
|
||||
entryType: activity.ActivityAllowedEntry[0]?.allowedEntryType ?? null,
|
||||
energyLevel: energyLevel
|
||||
@@ -2600,6 +2724,7 @@ export class ItineraryService {
|
||||
hasPreviousPage: sanitizedPage > 1 && totalPages > 0,
|
||||
},
|
||||
count: paginatedActivities.length,
|
||||
activityCount: totalCount,
|
||||
totalCount,
|
||||
activities: paginatedActivities,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user