需求一:对每天的课设置预约次数的限制

需求二:对每周的预约次数进行次数限制
需求三:所有课程48小时内不能取消预约设置可配置
This commit is contained in:
limqhz
2021-05-22 22:19:57 +08:00
parent 3d922c6776
commit 0e9a4b676c
13 changed files with 251 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
package com.sv.mapper;
import com.sv.annotation.NoPlatform;
import com.sv.annotation.PlatformKey;
import com.sv.dto.api.MemberLessonTicketDTO;
import com.sv.dto.api.MemberLessonTicketDetailDTO;
@@ -155,4 +156,4 @@ public interface MemberLessonTicketMapper {
Integer findByZero(@Param("memberId") Integer memberId,@Param("lessonId") Integer lessonId);
List<MemberLessonTicketDetailDTO> findTicketByStatusAndTime(@Param("memberId") Integer memberId,@Param("status") Integer status,@Param("startDate") String startDate,@Param("endDate") String endDate);
}
}

View File

@@ -1,5 +1,6 @@
package com.sv.mapper;
import com.sv.annotation.NoPlatform;
import com.sv.annotation.PlatformKey;
import com.sv.entity.MemberLessonTicket;
import com.sv.entity.VenueLessonTicket;
@@ -108,4 +109,20 @@ public interface VenueLessonTicketMapper {
*/
@PlatformKey
Integer findNum(Integer venueId);
}
/**
* 检验是否满足公益课当天预约限制
* @param memberId
* @param venueId
*/
@NoPlatform
Integer countFreeDayLimit(@Param("memberId") Integer memberId,@Param("venueId") Integer venueId);
/**
* 检验是否满足公益课当周预约限制
* @param memberId
* @param venueId
*/
@NoPlatform
Integer countFreeWeekLimit(@Param("memberId") Integer memberId,@Param("venueId") Integer venueId);
}

View File

@@ -55,6 +55,8 @@ public class MemberLessonTicketService extends BaseServiceImpl {
@Resource
private VenueLessonService venueLessonService;
@Resource
private VenueService venueService;
@Resource
private VenueLessonTicketService venueLessonTicketService;
@Resource
private MemberCardOrderService memberCardOrderService;
@@ -196,6 +198,13 @@ public class MemberLessonTicketService extends BaseServiceImpl {
// 课程是公益课 判断用户是否可以购买公益课
memberService.verifyMemberBanType(member);
// 课程是公益课
Venue venue = venueService.findById(venueLesson.getVenueId());
Integer limitDay = venue.getLimitDay() == null ? 1 : venue.getLimitDay();
Integer limitWeek = venue.getLimitWeek() == null ? 2 : venue.getLimitWeek();
// 1、对每天的课设置预约次数的限制
// 2、对每周的预约次数进行次数限制
venueLessonService.checkFreeLimit(member.getId(),venueLesson.getVenueId(),limitDay,limitWeek);
}
venueLessonService.decide(venueLesson, lessonTicketOrderDTO.getNum());
@@ -494,8 +503,11 @@ public class MemberLessonTicketService extends BaseServiceImpl {
double min = between / 3600;
DecimalFormat df = new DecimalFormat("#.#");
Double hour = Double.parseDouble(df.format(min));
Double subHour = 48D;
if (hour <= subHour) {
Integer orderLimit = venueLesson.getOrderLimit();
if (orderLimit == null){
orderLimit = 48;
}
if (hour <= orderLimit) {
throw new ServiceException(ExceptionCodeTemplate.LESSON_CANCEL);
}

View File

@@ -4,10 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.sv.dto.api.VenueLessonDTO;
import com.sv.dto.app.VenueLessonStatus;
import com.sv.entity.Member;
import com.sv.entity.MemberLessonTicket;
import com.sv.entity.VenueLesson;
import com.sv.entity.VenueLessonTicket;
import com.sv.mapper.VenueLessonMapper;
import com.sv.mapper.VenueLessonTicketMapper;
import com.sv.service.api.util.DateUtilCard;
import com.sv.service.api.util.WeekDayUtil;
import com.ydd.framework.core.common.Pagination;
@@ -45,7 +44,7 @@ public class VenueLessonService extends BaseServiceImpl {
@Resource
private MemberService memberService;
@Resource
private VenueLessonTicketService venueLessonTicketService;
private VenueLessonTicketMapper venueLessonTicketMapper;
/**
* 创建场馆课程
@@ -333,5 +332,22 @@ public class VenueLessonService extends BaseServiceImpl {
return venueLessonMapper.getLessonStatus(venueId);
}
/**
* 检验是否满足公益课预约限制
* @param memberId
* @param venueId
* @param limitDay
* @param limitWeek
*/
public void checkFreeLimit(Integer memberId, Integer venueId, Integer limitDay, Integer limitWeek) {
Integer dayCount = venueLessonTicketMapper.countFreeDayLimit(memberId, venueId);
if (dayCount + 1 > limitDay){
throw new ServiceException("该场馆当天最多可预约" + limitDay + "个公益课");
}
Integer weekCount = venueLessonTicketMapper.countFreeWeekLimit(memberId, venueId);
if (weekCount + 1 > limitWeek){
throw new ServiceException("该场馆一周最多可预约" + limitWeek + "个公益课");
}
}
}