|
|
@@ -3,6 +3,7 @@ package com.example.cinema.blImpl;
|
|
|
import com.example.cinema.bl.HallService;
|
|
|
import com.example.cinema.bl.TicketService;
|
|
|
import com.example.cinema.data.*;
|
|
|
+import com.example.cinema.po.Activity;
|
|
|
import com.example.cinema.po.Coupon;
|
|
|
import com.example.cinema.po.Ticket;
|
|
|
import com.example.cinema.po.VIPCard;
|
|
|
@@ -53,7 +54,13 @@ public class TicketServiceImpl implements TicketService {
|
|
|
}
|
|
|
try {
|
|
|
ticketMapper.insertTickets(tickets);
|
|
|
- return ResponseVO.buildSuccess(tickets.stream().map(ticket -> ticket.getVO()).collect(Collectors.toList()));
|
|
|
+ TicketWithCouponVO vo=new TicketWithCouponVO();
|
|
|
+ vo.setTicketVOList(tickets.stream().map(ticket -> ticket.getVO()).collect(Collectors.toList()));
|
|
|
+ ScheduleItem scheduleItem = scheduleMapper.selectScheduleById(tickets.get(0).getScheduleId());
|
|
|
+ double total=scheduleItem.getFare()*tickets.size();
|
|
|
+ vo.setTotal(total);
|
|
|
+ vo.setCoupons(couponMapper.selectCouponByUserAndAmount(tickets.get(0).getUserId(),total));
|
|
|
+ return ResponseVO.buildSuccess(vo);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseVO.buildFailure("失败");
|
|
|
@@ -66,10 +73,26 @@ public class TicketServiceImpl implements TicketService {
|
|
|
public ResponseVO completeTicket(List<Integer> id, int couponId) {
|
|
|
try {
|
|
|
List<Ticket> tickets=updateState(id,1);
|
|
|
+ int userId=tickets.get(0).getUserId();
|
|
|
if (couponId != 0) {
|
|
|
- couponMapper.deleteCouponUser(couponId, tickets.get(0).getUserId());
|
|
|
+ couponMapper.deleteCouponUser(couponId, userId);
|
|
|
+ }
|
|
|
+ ScheduleItem schedule=scheduleMapper.selectScheduleById(tickets.get(0).getScheduleId());
|
|
|
+ // 按电影优惠
|
|
|
+ List<ActivityVO> activityVOS=activityMapper.selectActivities();
|
|
|
+ List<Integer> coupons=new ArrayList<>();
|
|
|
+ for (ActivityVO vo:activityVOS ) {
|
|
|
+ coupons.add(vo.getCoupon().getId());
|
|
|
+ }
|
|
|
+ // 按时间优惠
|
|
|
+ List<ActivityVO> timeActivityVOS=activityMapper.selectActivitiesWithoutMovie();
|
|
|
+ for (ActivityVO vo:timeActivityVOS ) {
|
|
|
+ coupons.add(vo.getCoupon().getId());
|
|
|
+ }
|
|
|
+ coupons=coupons.stream().distinct().collect(Collectors.toList());
|
|
|
+ for (Integer coupon : coupons) {
|
|
|
+ couponMapper.insertCouponUser(coupon,userId);
|
|
|
}
|
|
|
-
|
|
|
return ResponseVO.buildSuccess(tickets.stream().map(ticket -> ticket.getVO()).collect(Collectors.toList()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|