|
|
@@ -1,10 +1,12 @@
|
|
|
package com.izouma.ticketExchange.service;
|
|
|
|
|
|
import com.izouma.ticketExchange.domain.Cinema;
|
|
|
+import com.izouma.ticketExchange.domain.CouponReceive;
|
|
|
import com.izouma.ticketExchange.domain.Schedule;
|
|
|
import com.izouma.ticketExchange.domain.Show;
|
|
|
import com.izouma.ticketExchange.exception.BusinessException;
|
|
|
import com.izouma.ticketExchange.repo.CinemaRepo;
|
|
|
+import com.izouma.ticketExchange.repo.CouponReceiveRepo;
|
|
|
import com.izouma.ticketExchange.repo.ScheduleRepo;
|
|
|
import com.izouma.ticketExchange.repo.ShowRepo;
|
|
|
import com.taobao.api.ApiException;
|
|
|
@@ -25,12 +27,13 @@ import static java.time.temporal.ChronoUnit.DAYS;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class SeatService {
|
|
|
- private TppService tppService;
|
|
|
- private ScheduleRepo scheduleRepo;
|
|
|
- private ShowRepo showRepo;
|
|
|
- private CinemaRepo cinemaRepo;
|
|
|
+ private TppService tppService;
|
|
|
+ private ScheduleRepo scheduleRepo;
|
|
|
+ private ShowRepo showRepo;
|
|
|
+ private CinemaRepo cinemaRepo;
|
|
|
+ private CouponReceiveRepo couponReceiveRepo;
|
|
|
|
|
|
- public Map seatMap(Long scheduleId, Long couponId) throws ApiException {
|
|
|
+ public Map seatMap(Long scheduleId, Long couponId, Long userId) throws ApiException {
|
|
|
Schedule schedule = scheduleRepo.findById(scheduleId).orElseThrow(new BusinessException("无记录"));
|
|
|
Show show = showRepo.findById(schedule.getShowId()).orElseThrow(new BusinessException("无记录"));
|
|
|
Cinema cinema = cinemaRepo.findById(schedule.getCinemaId()).orElseThrow(new BusinessException("无记录"));
|
|
|
@@ -39,13 +42,15 @@ public class SeatService {
|
|
|
map.put("seatMap", seatMap);
|
|
|
map.put("show", show);
|
|
|
map.put("cinema", cinema);
|
|
|
- map.put("width", seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getLeftPx())).max().orElse(0) - seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getLeftPx())).min().orElse(0));
|
|
|
- map.put("height", seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getTopPx())).max().orElse(0) - seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getTopPx())).min().orElse(0));
|
|
|
+ map.put("schedule", schedule);
|
|
|
+ map.put("width", seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getLeftPx())).max().orElse(0) + 60);
|
|
|
+ map.put("height", seatMap.getSeats().stream().mapToInt(value -> Math.toIntExact(value.getTopPx())).max().orElse(0) + 60);
|
|
|
map.put("rowNames", new ArrayList<>(seatMap.getSeats()
|
|
|
.stream()
|
|
|
.collect(Collectors.groupingBy(FilmDataThirdPartySeatMapResponse.Seat::getRowName))
|
|
|
.keySet())
|
|
|
.stream().sorted(Comparator.comparingInt(Integer::parseInt)).collect(Collectors.toList()));
|
|
|
+ map.put("usableCouponCount", couponReceiveRepo.findAllByUserIdAndCouponId(userId, couponId).stream().filter(couponReceive -> !couponReceive.getUsed()).count());
|
|
|
return map;
|
|
|
}
|
|
|
}
|