!2 自动拷贝课程功能 & 非公益课也增加了预约限制

Merge pull request !2 from Ezra/feature_20210317
This commit is contained in:
Ezra
2022-02-18 08:02:08 +00:00
committed by Gitee
355 changed files with 1341 additions and 32289 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

@@ -8,6 +8,7 @@ import com.sv.entity.MemberLessonTicket;
import com.sv.entity.VenueLesson;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
@@ -133,6 +134,13 @@ public interface VenueLessonMapper {
*/
void updateSaleNumBy(@Param("num")Integer num,@Param("lessonId") Integer lessonId);
/**
* APP获取当前预订时间列
* @param venueId
* @return
*/
List<String> getLessonTypes(@Param("venueId") Integer venueId);
/**
* APP获取当前预订情况
* @param venueId
@@ -140,4 +148,15 @@ public interface VenueLessonMapper {
* @return
*/
List<VenueLessonStatus> getLessonStatus(@Param("venueId") Integer venueId);
/**
* 查询课程当天所有的信息
* @param venueId
* @return
*/
List<VenueLesson> getCopyLesson(@Param("venueId") Integer venueId,@Param("date") Date date);
void copyImg(@Param("id") Integer id,@Param("nId") Integer nId);
List<VenueLesson> findAllForCopy(@Param("leftTime") String leftTime, @Param("rightTime") String rightTime);
}

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,41 @@ public interface VenueLessonTicketMapper {
*/
@PlatformKey
Integer findNum(Integer venueId);
}
/**
* 检验是否满足公益课当天预约限制
* @param memberId
* @param venueId
* @param checkDate
*/
@NoPlatform
Integer countFreeDayLimit(@Param("memberId") Integer memberId, @Param("venueId") Integer venueId, @Param("checkDate") String checkDate);
/**
* 检验是否满足公益课当周预约限制
* @param memberId
* @param venueId
* @param checkDate
*/
@NoPlatform
Integer countFreeWeekLimit(@Param("memberId") Integer memberId, @Param("venueId") Integer venueId, @Param("checkDate") String checkDate);
/**
* 检验是否满足普通课当天预约限制
* @param memberId
* @param venueId
* @param checkDate
*/
@NoPlatform
Integer countNormalDayLimit(@Param("memberId") Integer memberId, @Param("venueId") Integer venueId, @Param("checkDate") String checkDate);
/**
* 检验是否满足普通课当周预约限制
* @param memberId
* @param venueId
* @param checkDate
*/
@NoPlatform
Integer countNormalWeekLimit(@Param("memberId") Integer memberId, @Param("venueId") Integer venueId, @Param("checkDate") String checkDate);
}

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;
@@ -192,10 +194,22 @@ public class MemberLessonTicketService extends BaseServiceImpl {
// 1判断选择的课程是否可预约
VenueLesson venueLesson = venueLessonService.findById(lessonTicketOrderDTO.getLessonId());
Venue venue = venueService.findById(venueLesson.getVenueId());
if (new Integer(1).equals(venueLesson.getType())) {
// 课程是公益课 判断用户是否可以购买公益课
memberService.verifyMemberBanType(member);
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,venueLesson.getDate());
}else {
// 课程是非公益课
Integer limitNoDay = venue.getLimitNoDay() == null ? 1 : venue.getLimitNoDay();
Integer limitNoWeek = venue.getLimitNoWeek() == null ? 2 : venue.getLimitNoWeek();
// 1、对每天的课设置预约次数的限制
// 2、对每周的预约次数进行次数限制
venueLessonService.checkNormalLimit(member.getId(),venueLesson.getVenueId(),limitNoDay,limitNoWeek,venueLesson.getDate());
}
venueLessonService.decide(venueLesson, lessonTicketOrderDTO.getNum());
@@ -494,8 +508,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

@@ -1,5 +1,6 @@
package com.sv.service.api;
import com.common.utils.VenueValidateUtils;
import com.enums.MemberStatusEnum;
import com.enums.MoneyLogEnum;
import com.enums.PayTypeEnum;
@@ -214,7 +215,7 @@ public class MemberService extends BaseServiceImpl {
public Member createByMobile(String mobile, String name, Integer sex, Integer age, String address, Integer platformId) {
// 参数校验
ValidationUtils.assertNotNull(mobile);
ValidationUtils.assertMobile(mobile);
VenueValidateUtils.assertMobile(mobile);
// 验证手机号码是否存在
assertMobileNotUsed(mobile, null);
@@ -433,7 +434,7 @@ public class MemberService extends BaseServiceImpl {
}
if (informationDTO.getMobile() != null) {
ValidationUtils.assertMobile(informationDTO.getMobile()); // 校验手机号码格式
VenueValidateUtils.assertMobile(informationDTO.getMobile()); // 校验手机号码格式
ValidationUtils.assertNotNull(informationDTO.getCaptcha()); // 验证码不能为空
// 校验验证码是否正确
captchaCacheService.assertCaptcha(informationDTO.getMobile(), ApiConstants.UPDATE_PHONE_SMS_CAPTCHA_PREFIX, informationDTO.getCaptcha());

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;
/**
* 创建场馆课程
@@ -323,11 +322,61 @@ public class VenueLessonService extends BaseServiceImpl {
public void updateSaleNum(Integer num,Integer lessonId){
venueLessonMapper.updateSaleNumBy(num,lessonId);
}
@Transactional
public List<String> getLessonTypes(Integer venueId) {
return venueLessonMapper.getLessonTypes(venueId);
}
@Transactional
public List<VenueLessonStatus> getLessonOrder(Integer venueId){
return venueLessonMapper.getLessonStatus(venueId);
}
/**
* 检验是否满足公益课预约限制
* @param memberId
* @param venueId
* @param limitDay
* @param limitWeek
* @param date
*/
public void checkFreeLimit(Integer memberId, Integer venueId, Integer limitDay, Integer limitWeek, Date date) {
if (date == null){
date = new Date();
}
String checkDate = DateUtilCard.getStrFromDate(date);
Integer dayCount = venueLessonTicketMapper.countFreeDayLimit(memberId, venueId, checkDate);
if (dayCount + 1 > limitDay){
throw new ServiceException("该场馆当天最多可预约" + limitDay + "个公益课");
}
Integer weekCount = venueLessonTicketMapper.countFreeWeekLimit(memberId, venueId, checkDate);
if (weekCount + 1 > limitWeek){
throw new ServiceException("该场馆一周最多可预约" + limitWeek + "个公益课");
}
}
/**
* 检验是否满足公益课预约限制
* @param memberId
* @param venueId
* @param limitNoDay
* @param limitNoWeek
* @param date
*/
public void checkNormalLimit(Integer memberId, Integer venueId, Integer limitNoDay, Integer limitNoWeek, Date date) {
if (date == null){
date = new Date();
}
String checkDate = DateUtilCard.getStrFromDate(date);
Integer dayCount = venueLessonTicketMapper.countNormalDayLimit(memberId, venueId, checkDate);
if (dayCount + 1 > limitNoDay){
throw new ServiceException("该场馆当天最多可预约" + limitNoDay + "个普通课程");
}
Integer weekCount = venueLessonTicketMapper.countNormalWeekLimit(memberId, venueId, checkDate);
if (weekCount + 1 > limitNoWeek){
throw new ServiceException("该场馆一周最多可预约" + limitNoWeek + "个普通课程");
}
}
}

View File

@@ -2,13 +2,17 @@ package com.sv.service.api.util;
import com.enums.VipTypeEnum;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtilCard {
private final static SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd");
public static Date getYear(Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
@@ -131,4 +135,32 @@ public class DateUtilCard {
}
return endTime;
}
public static Date getDateFromStr(String date){
try {
Date res = sdf.parse(date);
return res;
} catch (ParseException e) {
return null;
}
}
public static String getStrFromDate(Date date){
return sdf.format(date);
}
public static Date addOneDay(Date date){
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.DATE,1); //把日期往后增加一天,整数 往后推,负数往前移动
return calendar.getTime(); //这个时间就是日期往后推一天的结果
}
public static Date addDays(Date date,int days){
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.DATE,days); //把日期往后增加一天,整数 往后推,负数往前移动
return calendar.getTime(); //这个时间就是日期往后推一天的结果
}
}

View File

@@ -119,19 +119,21 @@ public class OSSClientUtil {
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
String name = UUIDGenerator.randomUUID() + substring;
backUrl = healthDir + name;
String uploadUrl = healthDir + name;
// 上传文件
ossClient.putObject(bucketName, backUrl, multipartFile.getInputStream());
ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead);
ossClient.putObject(bucketName, uploadUrl, multipartFile.getInputStream());
ossClient.setObjectAcl(bucketName, uploadUrl, CannedAccessControlList.PublicRead);
// 判断是否上传成功
boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl);
boolean uploadResult = ossClient.doesObjectExist(bucketName, uploadUrl);
if (uploadResult) {
backUrl = getUploadUrl(name);
} else {
backUrl = "";
}
} finally {
} catch (Exception ex) {
log.error("upload error",ex);
}finally {
if (ossClient != null) {
ossClient.shutdown();
}
@@ -139,10 +141,9 @@ public class OSSClientUtil {
return backUrl;
}
private String getUploadUrl(String fileUrl) {
if (!StringUtils.isEmpty(fileUrl)) {
String[] split = fileUrl.split("/");
return url + this.healthDir + split[split.length - 1];
private String getUploadUrl(String fileName) {
if (!StringUtils.isEmpty(fileName)) {
return this.url + this.healthDir + fileName;
}
return null;
}

View File

@@ -1,6 +1,7 @@
package com.sv.service.common;
import com.common.Sms;
import com.common.utils.VenueValidateUtils;
import com.enums.SmsEnum;
import com.github.pagehelper.PageHelper;
import com.sv.exception.api.ExceptionCodeTemplate;
@@ -69,7 +70,7 @@ public class SmsService extends BaseServiceImpl {
@Transactional
public void sendRegisterCaptcha(String mobile, Integer type) {
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
ValidationUtils.assertMobile(mobile);
VenueValidateUtils.assertMobile(mobile);
// 验证码手机号码是否存在
String prefix = ApiConstants.REGISTER_SMS_CAPTCHA_PREFIX;
@@ -105,7 +106,7 @@ public class SmsService extends BaseServiceImpl {
@Transactional
public void sendLoginCaptcha(String mobile) {
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
ValidationUtils.assertMobile(mobile);
VenueValidateUtils.assertMobile(mobile);
if (!memberService.isMobileExists(mobile, null)) {
// 手机号码不存在
@@ -130,7 +131,7 @@ public class SmsService extends BaseServiceImpl {
@Transactional
public void sendUpdatePhoneCaptcha(String mobile) {
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
ValidationUtils.assertMobile(mobile);
VenueValidateUtils.assertMobile(mobile);
if (memberService.isMobileExists(mobile, null)) {
// 手机号码已存在
@@ -267,7 +268,7 @@ public class SmsService extends BaseServiceImpl {
@Transactional
public void record(String mobile, String content, SmsTypeEnum type, SmsStatusEnum status, SmsEnum platform) {
ValidationUtils.assertNotNull(mobile, content, type, status, platform);
ValidationUtils.assertMobile(mobile);
VenueValidateUtils.assertMobile(mobile);
// 保存短信内容
Sms sms = new Sms();

View File

@@ -1,4 +1,5 @@
package com.sv.service.oms;
import com.common.utils.VenueValidateUtils;
import com.github.pagehelper.PageHelper;
import com.sv.dto.api.MemberTokenDTO;
import com.sv.entity.MemberAuth;
@@ -154,7 +155,7 @@ public class MemberService extends MemberCardCommonService {
*/
public void saveMember(Member member){
ValidationUtils.assertNotBlank(member.getMobile(), "请输入手机号码");
ValidationUtils.assertMobile(member.getMobile());
VenueValidateUtils.assertMobile(member.getMobile());
synchronized (member.getMobile()){
// 根据手机号码创建新用户
@@ -171,7 +172,7 @@ public class MemberService extends MemberCardCommonService {
public Member createByMobile(Member member) {
// 参数校验
ValidationUtils.assertNotNull(member.getMobile());
ValidationUtils.assertMobile(member.getMobile());
VenueValidateUtils.assertMobile(member.getMobile());
// 创建用户
String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";

View File

@@ -5,11 +5,13 @@ import com.github.pagehelper.PageHelper;
import com.sv.dto.oms.VenueLessonOmsDTO;
import com.sv.entity.Platform;
import com.sv.entity.VenueLesson;
import com.sv.entity.VenueLessonTag;
import com.sv.entity.VenueLessonTicket;
import com.sv.exception.oms.OmsException;
import com.sv.mapper.VenueLessonMapper;
import com.sv.mapper.VenueLessonTagMapper;
import com.sv.mapper.VenueLessonTicketMapper;
import com.sv.service.api.util.DateUtilCard;
import com.sv.service.common.OSSClientUtil;
import com.sv.service.common.PlatformService;
import com.sv.service.common.RedisLock;
@@ -31,10 +33,8 @@ import redis.clients.jedis.Jedis;
import javax.annotation.Resource;
import java.io.InputStream;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;
import static com.sv.entity.Constants.LESSON_TICKET_LOCK_KEY;
@@ -78,7 +78,6 @@ public class VenueLessonService extends BaseServiceImpl {
*/
@Transactional(rollbackFor = Exception.class)
public void save(VenueLessonOmsDTO venueLesson) {
venueLesson.setVeneuType(VenueTypeEnum.FITNESS.value);
validateLessonDate(venueLesson);
RedisLock redisLock = new RedisLock(redisTemplate,LESSON_TICKET_LOCK_KEY+venueLesson.getId());
if (venueLesson.getId() != null && venueLesson.getId() > 0) {
@@ -291,6 +290,15 @@ public class VenueLessonService extends BaseServiceImpl {
return pagination;
}
/**
* 查询场馆课程
*
* @return 需要拷贝的场馆课程
*/
public List<VenueLesson> findAllForCopy(String leftTime, String rightTime) {
return venueLessonMapper.findAllForCopy(leftTime, rightTime);
}
/**
* 查看教练有多少课程
* @param id
@@ -300,5 +308,32 @@ public class VenueLessonService extends BaseServiceImpl {
return venueLessonMapper.countByCoachId(id);
}
/**
* copy课程
* @param lessonId
* @param start
* @param end
*/
@Transactional(readOnly = false)
public void copy(Integer lessonId, Date start, Date end) {
VenueLesson byId = venueLessonMapper.findById(lessonId);
List<VenueLesson> copyLesson = venueLessonMapper.getCopyLesson(byId.getVenueId(), byId.getDate());
if (copyLesson != null && copyLesson.size() > 0){
while (!start.after(end)){
for (VenueLesson x : copyLesson) {
Integer oldId = x.getId();
x.setId(null);
x.setModifiedId(999);
x.setSaleNum(0);
x.setModifiedTime(new Date());
x.setDate(start);
venueLessonMapper.insert(x);
insertLessonTicket(x);
venueLessonMapper.copyImg(oldId, x.getId());
}
start = DateUtilCard.addOneDay(start);
}
}
}
}

View File

@@ -213,5 +213,10 @@ public class VenueService extends BaseServiceImpl {
public void clearNumber(Integer id) {
venueMapper.updateNumber(0, id);
}
@Transactional
public Venue getVenue(Integer id){
return venueMapper.findById(id);
}
}

View File

@@ -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>
@@ -413,9 +425,9 @@
SELECT count(0) FROM sv_venue_lesson
WHERE
(
(<![CDATA[ start_time <= #{startTime}]]> and end_time >= #{startTime})
(<![CDATA[ start_time < #{startTime}]]> and end_time > #{startTime})
or
(<![CDATA[ start_time <= #{endTime}]]> and end_time >= #{endTime})
(<![CDATA[ start_time < #{endTime}]]> and end_time > #{endTime})
)
and deleted = 0 and coach_id = #{coachId} and `date` = #{date}
<if test="lessonId != null">
@@ -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
@@ -604,7 +618,15 @@
</update>
<!-- 修改库存 -->
<select id="getLessonTypes" resultType="string">
select DISTINCT start_time from sv_venue_lesson a
where DATE(a.date) <![CDATA[ >= ]]> CURRENT_DATE
AND DATE(a.date) <![CDATA[ <= ]]> DATE_ADD(CURRENT_DATE,INTERVAL 4 DAY)
and a.venue_id = #{venueId}
ORDER BY a.start_time
</select>
<!-- 获取预定信息 -->
<select id="getLessonStatus" resultType="com.sv.dto.app.VenueLessonStatus">
select (select x.name from sv_venue x where x.id = a.venue_id) as 'venueName',
a.`name` as 'lessonName',a.date as 'searchDate',
@@ -612,14 +634,55 @@
a.sale_num as 'saleNum',(a.num-a.sale_num) as 'limitNum',
IFNULL(t.orderUsers,'暂无预订') as 'orderUsers',a.note
from sv_venue_lesson a LEFT JOIN
(select b.lesson_id,group_concat(distinct d.nickname,'(',d.mobile,')' SEPARATOR '<![CDATA[ <br/> ]]>') as 'orderUsers'
(select b.lesson_id,group_concat(distinct d.nickname SEPARATOR ',') as 'orderUsers'
from sv_member_lesson_ticket b , sv_member d
where b.member_id = d.id
and b.`status` != '2'
GROUP BY b.lesson_id) t on a.id = t.lesson_id
where a.date <![CDATA[ >= ]]> NOW()
AND a.date <![CDATA[ <= ]]> DATE_ADD(NOW(),INTERVAL 2 DAY)
where DATE(a.date) <![CDATA[ >= ]]> CURRENT_DATE
AND DATE(a.date) <![CDATA[ <= ]]> DATE_ADD(CURRENT_DATE,INTERVAL 7 DAY)
and a.deleted = '0'
and a.venue_id = #{venueId}
ORDER BY a.date,a.start_time
</select>
<!-- api 查询需要copy的信息 -->
<select id="getCopyLesson" resultMap="VenueLessonMap">
SELECT
*
FROM
sv_venue_lesson
WHERE
date = #{date}
AND venue_id = #{venueId}
AND deleted = 0
</select>
<!-- copy -->
<update id="copyImg">
INSERT INTO sv_venue_lesson_image
(lesson_id,url,platform_id,created_id,modified_id,created_time,modified_time,deleted)
(
SELECT
#{nId},url,platform_id,created_id,'999',created_time,modified_time,deleted
FROM sv_venue_lesson_image where sv_venue_lesson_image.deleted = 0
AND sv_venue_lesson_image.lesson_id = #{id}
)
</update>
<select id="findAllForCopy" resultMap="VenueLessonMap">
SELECT
<include refid="Field"></include>
FROM
<include refid="tableName"></include>
WHERE
deleted = 0
<if test="leftTime != null">
and date &gt;= #{leftTime}
</if>
<if test="rightTime != null">
and date &lt;= #{rightTime}
</if>
</select>
</mapper>

View File

@@ -344,4 +344,74 @@
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(#{checkDate})='Sunday'
THEN DATE_SUB(#{checkDate},INTERVAL 6 DAY)
ELSE DATE_SUB(#{checkDate},INTERVAL DAYOFWEEK(#{checkDate})-2 DAY) END) <![CDATA[ <= ]]> DATE(a.date)
AND (CASE WHEN DAYNAME(#{checkDate})='Sunday'
THEN #{checkDate}
ELSE DATE_ADD(#{checkDate},INTERVAL 8-DAYOFWEEK(#{checkDate}) DAY) END) <![CDATA[ >= ]]> DATE(a.date);
</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 a.date = #{checkDate};
</select>
<select id="countNormalWeekLimit" 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 = 0
AND t.deleted = 0
AND t.status in (0,1,3)
AND t.member_id = #{memberId}
AND (CASE WHEN DAYNAME(#{checkDate})='Sunday'
THEN DATE_SUB(#{checkDate},INTERVAL 6 DAY)
ELSE DATE_SUB(#{checkDate},INTERVAL DAYOFWEEK(#{checkDate})-2 DAY) END) <![CDATA[ <= ]]> DATE(a.date)
AND (CASE WHEN DAYNAME(#{checkDate})='Sunday'
THEN #{checkDate}
ELSE DATE_ADD(#{checkDate},INTERVAL 8-DAYOFWEEK(#{checkDate}) DAY) END) <![CDATA[ >= ]]> DATE(a.date);
</select>
<select id="countNormalDayLimit" 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 = 0
AND t.deleted = 0
AND t.status in (0,1,3)
AND t.member_id = #{memberId}
AND a.date = #{checkDate};
</select>
</mapper>

View File

@@ -28,6 +28,13 @@
<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"/>
<result column="limit_no_day" property="limitNoDay"/>
<result column="limit_no_week" property="limitNoWeek"/>
<result column="copy_week" property="copyWeek"/>
<result column="copy_time" property="copyTime"/>
<result column="copy_target" property="copyTarget"/>
</resultMap>
<resultMap id="VenueDtoMap" type="com.sv.dto.api.VenueDTO">
@@ -50,6 +57,13 @@
<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="limit_no_day" property="limitNoDay"/>
<result column="limit_no_week" property="limitNoWeek"/>
<result column="copy_week" property="copyWeek"/>
<result column="copy_time" property="copyTime"/>
<result column="copy_target" property="copyTarget"/>
<result column="code_url" property="codeUrl"></result>
<association property="cards" select="com.sv.mapper.VenueCardMapper.findByVenueId"
column="{venueId = id,venueType=type}"></association>
@@ -105,7 +119,14 @@
created_time,
modified_time,
code_url,
deleted
deleted,
limit_day,
limit_week,
limit_no_day,
limit_no_week,
copy_week,
copy_time,
copy_target
</sql>
<!-- 字段值 -->
@@ -128,7 +149,14 @@
#{modifiedId, jdbcType=INTEGER},
#{createdTime, jdbcType=TIMESTAMP},
#{modifiedTime, jdbcType=TIMESTAMP},
#{deleted, jdbcType=TINYINT}
#{deleted, jdbcType=TINYINT},
#{limit_day, jdbcType=TINYINT},
#{limit_week, jdbcType=TINYINT},
#{limit_no_day, jdbcType=TINYINT},
#{limit_no_week, jdbcType=TINYINT},
#{copy_week, jdbcType=TINYINT},
#{copy_time, jdbcType=TIMESTAMP},
#{copy_target, jdbcType=TINYINT}
</sql>
<!-- 查询全部记录 -->
@@ -251,6 +279,27 @@
<if test="deleted != null">
deleted,
</if>
<if test="limitDay != null">
limit_day,
</if>
<if test="limitWeek != null">
limit_week,
</if>
<if test="limitNoDay != null">
limit_no_day,
</if>
<if test="limitNoWeek != null">
limit_no_week,
</if>
<if test="copyWeek != null">
copy_week,
</if>
<if test="copyTime != null">
copy_time,
</if>
<if test="copyTarget != null">
copy_target,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -325,6 +374,21 @@
<if test="deleted != null">
#{deleted},
</if>
<if test="limitDay != null">
#{limitDay},
</if>
<if test="limitWeek != null">
#{limitWeek},
</if>
<if test="copyWeek != null">
#{copyWeek},
</if>
<if test="copyTime != null">
#{copyTime},
</if>
<if test="copyTarget != null">
#{copyTarget},
</if>
</trim>
</insert>
@@ -430,6 +494,27 @@
<if test="codeUrl != null">
code_url = #{codeUrl},
</if>
<if test="limitDay != null">
limit_day = #{limitDay},
</if>
<if test="limitWeek != null">
limit_week = #{limitWeek},
</if>
<if test="limitNoDay != null">
limit_no_day = #{limitNoDay},
</if>
<if test="limitNoWeek != null">
limit_no_week = #{limitNoWeek},
</if>
<if test="copyWeek != null">
copy_week = #{copyWeek},
</if>
<if test="copyTime != null">
copy_time = #{copyTime},
</if>
<if test="copyTarget != null">
copy_target = #{copyTarget},
</if>
</set>
WHERE id = #{id}
</update>
@@ -465,7 +550,14 @@
description,
longitude,
latitude,
card_content
card_content,
limit_day,
limit_week,
limit_no_day,
limit_no_week,
copy_week,
copy_time,
copy_target
FROM
sv_venue
WHERE
@@ -535,4 +627,4 @@
<delete id="deleteMember">
delete from sv_venue_member where member_id = #{memberId} and venue_id = #{venueId}
</delete>
</mapper>
</mapper>