需求一:对每天的课设置预约次数的限制
需求二:对每周的预约次数进行次数限制 需求三:所有课程48小时内不能取消预约设置可配置
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 + "个公益课");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<result column="deleted" property="deleted"/>
|
||||
<result column="note" property="note"/>
|
||||
<result column="type" property="type"></result>
|
||||
<result column="order_limit" property="orderLimit"></result>
|
||||
</resultMap>
|
||||
<resultMap id="VenueLessonOrderDtoMap" type="com.sv.dto.api.VenueLessonDTO" extends="VenueLessonMap">
|
||||
<result column="address" property="address"/>
|
||||
@@ -70,7 +71,8 @@
|
||||
deleted,
|
||||
note,
|
||||
status,
|
||||
type
|
||||
type,
|
||||
order_limit
|
||||
</sql>
|
||||
|
||||
<!-- 字段值 -->
|
||||
@@ -96,6 +98,7 @@
|
||||
#{deleted, jdbcType=TINYINT},
|
||||
#{note, jdbcType=VARCHAR},
|
||||
#{status, jdbcType=INTEGER}
|
||||
#{orderLimit, jdbcType=INTEGER}
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部记录 -->
|
||||
@@ -177,6 +180,9 @@
|
||||
<if test="deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="orderLimit != null">
|
||||
order_limit,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -242,6 +248,9 @@
|
||||
<if test="deleted != null">
|
||||
#{deleted},
|
||||
</if>
|
||||
<if test="orderLimit != null">
|
||||
#{orderLimit},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -333,6 +342,9 @@
|
||||
<if test="note != null">
|
||||
note = #{note},
|
||||
</if>
|
||||
<if test="orderLimit != null">
|
||||
order_limit = #{orderLimit},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
@@ -487,6 +499,7 @@
|
||||
ve.latitude,
|
||||
ve.longitude,
|
||||
le.type,
|
||||
le.order_limit,
|
||||
ve.`name` AS venueName
|
||||
FROM
|
||||
sv_venue_lesson AS le
|
||||
@@ -508,7 +521,8 @@
|
||||
vl.price,
|
||||
vl.num,
|
||||
vl.sale_num,
|
||||
vl.note
|
||||
vl.note,
|
||||
vl.order_limit
|
||||
FROM
|
||||
sv_venue_lesson AS vl
|
||||
LEFT JOIN sv_venue AS ue ON vl.venue_id = ue.id
|
||||
|
||||
@@ -344,4 +344,40 @@
|
||||
lesson_id = #{venueId}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
<select id="countFreeWeekLimit" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(0)
|
||||
FROM
|
||||
sv_member_lesson_ticket t,sv_venue_lesson a
|
||||
WHERE
|
||||
t.lesson_id = a.id
|
||||
AND t.venue_id = #{venueId}
|
||||
AND a.type = 1
|
||||
AND t.deleted = 0
|
||||
AND t.status in (0,1,3)
|
||||
AND t.member_id = #{memberId}
|
||||
AND (CASE WHEN DAYNAME(CURDATE())='Sunday'
|
||||
THEN DATE_SUB(CURDATE(),INTERVAL 6 DAY)
|
||||
ELSE DATE_SUB(CURDATE(),INTERVAL DAYOFWEEK(CURDATE())-2 DAY) END) <![CDATA[ <= ]]> DATE(t.created_time)
|
||||
AND (CASE WHEN DAYNAME(CURDATE())='Sunday'
|
||||
THEN CURDATE()
|
||||
ELSE DATE_ADD(CURDATE(),INTERVAL 8-DAYOFWEEK(CURDATE()) DAY) END) <![CDATA[ >= ]]> DATE(t.created_time);
|
||||
</select>
|
||||
|
||||
<select id="countFreeDayLimit" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(0)
|
||||
FROM
|
||||
sv_member_lesson_ticket t,sv_venue_lesson a
|
||||
WHERE
|
||||
t.lesson_id = a.id
|
||||
AND t.venue_id = #{venueId}
|
||||
AND a.type = 1
|
||||
AND t.deleted = 0
|
||||
AND t.status in (0,1,3)
|
||||
AND t.member_id = #{memberId}
|
||||
AND CURDATE() <![CDATA[ <= ]]> DATE(t.created_time)
|
||||
AND CURDATE() <![CDATA[ >= ]]> DATE(t.created_time);
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
<result column="modified_time" property="modifiedTime"/>
|
||||
<result column="code_url" property="codeUrl"></result>
|
||||
<result column="deleted" property="deleted"/>
|
||||
<result column="limit_day" property="limitDay"/>
|
||||
<result column="limit_week" property="limitWeek"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="VenueDtoMap" type="com.sv.dto.api.VenueDTO">
|
||||
@@ -50,6 +52,8 @@
|
||||
<result column="created_time" property="createdTime"/>
|
||||
<result column="modified_time" property="modifiedTime"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
<result column="limit_day" property="limitDay"/>
|
||||
<result column="limit_week" property="limitWeek"/>
|
||||
<result column="code_url" property="codeUrl"></result>
|
||||
<association property="cards" select="com.sv.mapper.VenueCardMapper.findByVenueId"
|
||||
column="{venueId = id,venueType=type}"></association>
|
||||
@@ -105,7 +109,9 @@
|
||||
created_time,
|
||||
modified_time,
|
||||
code_url,
|
||||
deleted
|
||||
deleted,
|
||||
limit_day,
|
||||
limit_week
|
||||
</sql>
|
||||
|
||||
<!-- 字段值 -->
|
||||
@@ -129,6 +135,8 @@
|
||||
#{createdTime, jdbcType=TIMESTAMP},
|
||||
#{modifiedTime, jdbcType=TIMESTAMP},
|
||||
#{deleted, jdbcType=TINYINT}
|
||||
#{limit_day, jdbcType=TINYINT}
|
||||
#{limit_week, jdbcType=TINYINT}
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部记录 -->
|
||||
@@ -251,6 +259,12 @@
|
||||
<if test="deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="limitDay != null">
|
||||
limit_day,
|
||||
</if>
|
||||
<if test="limitWeek != null">
|
||||
limit_week,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -325,6 +339,12 @@
|
||||
<if test="deleted != null">
|
||||
#{deleted},
|
||||
</if>
|
||||
<if test="limitDay != null">
|
||||
#{limitDay},
|
||||
</if>
|
||||
<if test="limitWeek != null">
|
||||
#{limitWeek},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -430,6 +450,12 @@
|
||||
<if test="codeUrl != null">
|
||||
code_url = #{codeUrl},
|
||||
</if>
|
||||
<if test="limitDay != null">
|
||||
limit_day = #{limitDay},
|
||||
</if>
|
||||
<if test="limitWeek != null">
|
||||
limit_week = #{limitWeek},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
@@ -465,7 +491,9 @@
|
||||
description,
|
||||
longitude,
|
||||
latitude,
|
||||
card_content
|
||||
card_content,
|
||||
limit_day,
|
||||
limit_week
|
||||
FROM
|
||||
sv_venue
|
||||
WHERE
|
||||
@@ -535,4 +563,4 @@
|
||||
<delete id="deleteMember">
|
||||
delete from sv_venue_member where member_id = #{memberId} and venue_id = #{venueId}
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user