|
@@ -7,12 +7,13 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.inform.mapper.InformUserMapper;
|
|
|
-import com.zhongzheng.modules.user.bo.UserPlanGoodsAddBo;
|
|
|
+import com.zhongzheng.modules.user.bo.*;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlanGoods;
|
|
|
import com.zhongzheng.modules.user.service.IUserPlanCourceService;
|
|
|
import com.zhongzheng.modules.user.service.IUserPlanGoodsService;
|
|
@@ -25,13 +26,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
-import com.zhongzheng.modules.user.bo.UserPlanAddBo;
|
|
|
-import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
|
|
|
-import com.zhongzheng.modules.user.bo.UserPlanEditBo;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlan;
|
|
|
import com.zhongzheng.modules.user.mapper.UserPlanMapper;
|
|
|
import com.zhongzheng.modules.user.vo.UserPlanVo;
|
|
|
import com.zhongzheng.modules.user.service.IUserPlanService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
@@ -172,6 +171,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException {
|
|
|
validEntityPlanBeforeSave(bo);
|
|
|
UserPlan userPlan = new UserPlan();
|
|
@@ -205,13 +205,20 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Long secAll = 0L;
|
|
|
//当前商品总节数
|
|
|
Long sumUp = 0L;
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
+ Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
+ //获得相隔天数
|
|
|
+ int dutyDays = getDutyDays(date, date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
+ if (dutyDays < 1){
|
|
|
+ throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
+ }
|
|
|
for (Long aLong : bo.getGoodsId()) {
|
|
|
- //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
- Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
- //获得相隔天数
|
|
|
- int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
- if (dutyDays < 1){
|
|
|
- throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
+ UserPlanGoodsQueryBo queryBo = new UserPlanGoodsQueryBo();
|
|
|
+ queryBo.setUserId(bo.getUserId());
|
|
|
+ queryBo.setSourceId(aLong);
|
|
|
+ Long havePlanId = userPlanGoodsService.checkBuyGoods(queryBo);
|
|
|
+ if(Validator.isNotEmpty(havePlanId)){
|
|
|
+ throw new CustomException("已有商品正在计划进行中");
|
|
|
}
|
|
|
//查询商品每个课程得总节数
|
|
|
List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
@@ -223,6 +230,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
//计算每天需要学习多少节课
|
|
|
int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
secAll+=Sec;
|
|
|
+
|
|
|
//给大于等于今天的天数赋值学习节数
|
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
@@ -303,6 +311,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(UserPlanEditBo bo) throws ParseException {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
if (bo.getStatus().equals(-1)){
|
|
@@ -336,21 +345,26 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
c1.setTime(dateTwo);
|
|
|
//设置为当月最后一天
|
|
|
c1.set(Calendar.DAY_OF_MONTH, c1.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
- System.out.println(c.getTimeInMillis());
|
|
|
- System.out.println(c1.getTimeInMillis());
|
|
|
//获得学习时间范围的日历
|
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(c.getTimeInMillis()/1000,c1.getTimeInMillis()/1000);
|
|
|
//所有商品总节数
|
|
|
Long secAll = 0L;
|
|
|
//当前商品总节数
|
|
|
Long sumUp = 0L;
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
+ Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
+ //获得相隔天数
|
|
|
+ int dutyDays = getDutyDays(date, date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
+ if (dutyDays < 1){
|
|
|
+ throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
+ }
|
|
|
for (Long aLong : bo.getGoodsId()) {
|
|
|
- //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
- Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
- //获得相隔天数
|
|
|
- int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
- if (dutyDays < 1){
|
|
|
- throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
+ UserPlanGoodsQueryBo queryBo = new UserPlanGoodsQueryBo();
|
|
|
+ queryBo.setUserId(bo.getUserId());
|
|
|
+ queryBo.setSourceId(aLong);
|
|
|
+ Long havePlanId = userPlanGoodsService.checkBuyGoods(queryBo);
|
|
|
+ if(Validator.isNotEmpty(havePlanId)&&!havePlanId.equals(bo.getPlanId())){
|
|
|
+ throw new CustomException("已有商品正在计划进行中");
|
|
|
}
|
|
|
//查询每个商品的总节数
|
|
|
List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
@@ -488,27 +502,23 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
c1.setTime(dateTwo);
|
|
|
//设置为当月最后一天
|
|
|
c1.set(Calendar.DAY_OF_MONTH, c1.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
- System.out.println(c.getTimeInMillis());
|
|
|
- System.out.println(c1.getTimeInMillis());
|
|
|
//获得学习范围的日历
|
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(c.getTimeInMillis()/1000,c1.getTimeInMillis()/1000);
|
|
|
Long secAll = 0L;
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
+ Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
+ //获得相隔天数
|
|
|
+ int dutyDays = getDutyDays(date, date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
+ if (dutyDays < 1){
|
|
|
+ throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
+ }
|
|
|
for (Long aLong : bo.getGoodsId()) {
|
|
|
- //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
- Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
- //获得相隔天数
|
|
|
- int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
- if (dutyDays < 1){
|
|
|
- throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
- }
|
|
|
//查询商品每个课程得总节数
|
|
|
List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
|
Long allNum = 0L;
|
|
|
for (Long seLong : seLongs) {
|
|
|
allNum += seLong;
|
|
|
}
|
|
|
- System.out.println("总节数"+allNum);
|
|
|
- System.out.println("学习天数"+dutyDays);
|
|
|
//计算每天需要学习多少节课
|
|
|
int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
secAll+=Sec;
|
|
@@ -624,21 +634,18 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
c.setTime(endDate);
|
|
|
c.add(Calendar.DATE, - Convert.toInt(studyDay));
|
|
|
endDate = c.getTime();
|
|
|
- System.out.println(startDateStr.getTime()+"开始天数");
|
|
|
- System.out.println(endDateStr.getTime()+"开始天数");
|
|
|
Date startDate = startDateStr;
|
|
|
int day = startDate.getDay();
|
|
|
while (startDate.compareTo(endDate) <= 0) {
|
|
|
for (Long integer : longs) {
|
|
|
if (startDate.getDay() == integer) {
|
|
|
- System.out.println(startDate.getDay()+"号数");
|
|
|
result++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
startDate.setDate(startDate.getDate() + 1);
|
|
|
}
|
|
|
- return result-1;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|