File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
back/src/domains/booking/service Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -150,11 +150,21 @@ export class BookingService {
150150 async setBookingAmount ( sid : string , bookingAmount : number ) {
151151 const isInBooking = await this . inBookingService . isInBooking ( sid ) ;
152152 if ( isInBooking ) {
153+ await this . flushBookedSeats ( sid ) ;
153154 return await this . inBookingService . setBookingAmount ( sid , bookingAmount ) ;
154155 }
155156 return await this . enterBookingService . setBookingAmount ( sid , bookingAmount ) ;
156157 }
157158
159+ private async flushBookedSeats ( sid : string ) {
160+ const bookedSeats = await this . inBookingService . getBookedSeats ( sid ) ;
161+ if ( bookedSeats . length > 0 ) {
162+ const eventId = await this . userService . getUserEventTarget ( sid ) ;
163+ await Promise . all ( bookedSeats . map ( ( seat ) => this . bookingSeatsService . updateSeatDeleted ( eventId , seat ) ) ) ;
164+ await this . inBookingService . removeBookedSeats ( sid ) ;
165+ }
166+ }
167+
158168 async getTimeMs ( ) : Promise < ServerTimeDto > {
159169 try {
160170 return {
Original file line number Diff line number Diff line change @@ -104,6 +104,13 @@ export class InBookingService {
104104 await this . setSession ( eventId , session ) ;
105105 }
106106
107+ async removeBookedSeats ( sid : string ) {
108+ const eventId = await this . getTargetEventId ( sid ) ;
109+ const session = await this . getSession ( eventId , sid ) ;
110+ session . bookedSeats = [ ] ;
111+ await this . setSession ( eventId , session ) ;
112+ }
113+
107114 async getIsSaved ( sid : string ) {
108115 const eventId = await this . getTargetEventId ( sid ) ;
109116 const session = await this . getSession ( eventId , sid ) ;
You can’t perform that action at this time.
0 commit comments