按天复制课程
This commit is contained in:
@@ -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;
|
||||
|
||||
/**
|
||||
@@ -140,4 +141,13 @@ 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);
|
||||
}
|
||||
|
||||
@@ -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,25 @@ 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(); //这个时间就是日期往后推一天的结果
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -300,5 +300,30 @@ 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.setModifiedTime(new Date());
|
||||
x.setDate(start);
|
||||
venueLessonMapper.insert(x);
|
||||
venueLessonMapper.copyImg(oldId, x.getId());
|
||||
}
|
||||
start = DateUtilCard.addOneDay(start);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user