1717import com .back .api .queue .dto .response .ProcessEntriesResponse ;
1818import com .back .api .queue .dto .response .WaitingQueueBatchEventResponse ;
1919import com .back .api .queue .dto .response .WaitingQueueResponse ;
20+ import com .back .api .ticket .service .TicketService ;
2021import com .back .domain .event .entity .Event ;
2122import com .back .domain .event .repository .EventRepository ;
2223import com .back .domain .notification .systemMessage .QueueEntriesMessage ;
@@ -51,6 +52,7 @@ public class QueueEntryProcessService {
5152 private final QueueSchedulerProperties properties ;
5253 private final QueueEntryReadService queueEntryReadService ;
5354 private final EventRepository eventRepository ;
55+ private final TicketService ticketService ;
5456
5557
5658 /* ==================== 입장 처리 ==================== */
@@ -102,9 +104,9 @@ public void processEventQueueEntries(Event event) {
102104 Long totalWaitingCount ;
103105
104106 try {
105- totalWaitingCount = queueEntryRedisRepository .getTotalWaitingCount (eventId );
107+ totalWaitingCount = queueEntryRedisRepository .getTotalWaitingCount (eventId );
106108 } catch (Exception e ) {
107- log .warn ("Redis 조회 실패, DB로부터 대기 중 인원 수 조회 시도 - eventId: {}" , eventId , e );
109+ log .warn ("Redis 조회 실패, DB로부터 대기 중 인원 수 조회 시도 - eventId: {}" , eventId , e );
108110 totalWaitingCount = queueEntryRepository .countByEvent_IdAndQueueEntryStatus (
109111 eventId ,
110112 QueueEntryStatus .WAITING
@@ -121,14 +123,13 @@ public void processEventQueueEntries(Event event) {
121123 try {
122124 currentEnteredCount = queueEntryRedisRepository .getTotalEnteredCount (eventId );
123125 } catch (Exception e ) {
124- log .warn ("Redis 조회 실패, DB로부터 입장 완료된 인원 수 조회 시도 - eventId: {}" , eventId , e );
126+ log .warn ("Redis 조회 실패, DB로부터 입장 완료된 인원 수 조회 시도 - eventId: {}" , eventId , e );
125127 currentEnteredCount = queueEntryRepository .countByEvent_IdAndQueueEntryStatus (
126128 eventId ,
127129 QueueEntryStatus .ENTERED
128130 );
129131 }
130132
131-
132133 int maxEnteredLimit = properties .getEntry ().getMaxEnteredLimit ();
133134
134135 //입장 가능한 인원 확인
@@ -153,16 +154,14 @@ public void processEventQueueEntries(Event event) {
153154 log .info ("입장 처리 - eventId: {}, 대기: {}명, 입장완료: {}명, 빈자리: {}명, 배치사이즈: {}명, 입장시킬인원: {}명" ,
154155 eventId , totalWaitingCount , currentEnteredCount , availableEnteredCount , batchSize , entryCount );
155156
156-
157-
158157 List <Long > userIds ;
159158 try {
160159 Set <Object > topWaitingUsers = queueEntryRedisRepository .getTopWaitingUsers (eventId , entryCount );
161160 userIds = topWaitingUsers .stream ()
162161 .map (obj -> Long .parseLong (obj .toString ()))
163162 .toList ();
164163 } catch (Exception e ) {
165- log .warn ("Redis 조회 실패, DB로부터 상위 대기 인원 조회 시도 - eventId: {}" , eventId , e );
164+ log .warn ("Redis 조회 실패, DB로부터 상위 대기 인원 조회 시도 - eventId: {}" , eventId , e );
166165 userIds = queueEntryRepository .findTopNWaitingUsers (eventId , entryCount );
167166 }
168167
@@ -358,7 +357,6 @@ public void expireBatchEntries(List<QueueEntry> entries) {
358357
359358 /* ==================== 결제 완료 처리 ==================== */
360359
361-
362360 @ Transactional
363361 public void completePayment (Long eventId , Long userId ) {
364362
@@ -443,6 +441,8 @@ public MoveToBackResponse moveToBackQueue(Long eventId, Long userId) {
443441
444442 int previousRank = queueEntry .getQueueRank ();
445443
444+ ticketService .releaseDraftTicketAndSeat (eventId , userId );
445+
446446 Long maxRank = queueEntryRepository .findMaxRankInQueue (eventId )
447447 .orElse (0L );
448448
@@ -470,7 +470,6 @@ public MoveToBackResponse moveToBackQueue(Long eventId, Long userId) {
470470
471471 }
472472
473-
474473 private void validateEntry (QueueEntry queueEntry ) {
475474 QueueEntryStatus status = queueEntry .getQueueEntryStatus ();
476475
@@ -519,7 +518,6 @@ private void validatePaymentCompletion(QueueEntry queueEntry) {
519518 }
520519 }
521520
522-
523521 private void updateRedis (Long eventId , Long userId ) {
524522 try {
525523 queueEntryRedisRepository .moveToEnteredQueue (eventId , userId );
@@ -531,7 +529,6 @@ private void updateRedis(Long eventId, Long userId) {
531529 }
532530 }
533531
534-
535532 private void publishEnteredEvent (QueueEntry queueEntry ) {
536533 EnteredQueueResponse response = EnteredQueueResponse .from (
537534 queueEntry .getUserId (),
0 commit comments