|
@@ -19,7 +19,15 @@ import com.zhongzheng.common.utils.polyv.PolyvUtils;
|
|
|
import com.zhongzheng.modules.base.service.IProfileTpService;
|
|
|
import com.zhongzheng.modules.base.vo.ProfileTpVo;
|
|
|
import com.zhongzheng.modules.base.vo.UserProfileVo;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamBeforeQueryBo;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApply;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamBefore;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamNumber;
|
|
|
+import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
|
|
|
+import com.zhongzheng.modules.exam.mapper.ExamBeforeMapper;
|
|
|
+import com.zhongzheng.modules.exam.vo.ExamApplyVo;
|
|
|
+import com.zhongzheng.modules.exam.vo.ExamBeforeVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
@@ -60,19 +68,14 @@ import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
|
|
|
import com.zhongzheng.modules.polyv.vo.PolyvVideoVo;
|
|
|
import com.zhongzheng.modules.polyv.vo.PolyvVo;
|
|
|
import com.zhongzheng.modules.schedule.service.IScheduleService;
|
|
|
-import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
|
|
|
-import com.zhongzheng.modules.user.bo.UserExamGoodsSupplementAddBo;
|
|
|
-import com.zhongzheng.modules.user.bo.UserQueryBo;
|
|
|
-import com.zhongzheng.modules.user.bo.UserSubscribeQueryBo;
|
|
|
+import com.zhongzheng.modules.user.bo.*;
|
|
|
import com.zhongzheng.modules.user.domain.UserExamGoods;
|
|
|
+import com.zhongzheng.modules.user.domain.UserPlan;
|
|
|
+import com.zhongzheng.modules.user.domain.UserPlanGoods;
|
|
|
import com.zhongzheng.modules.user.domain.UserSubscribe;
|
|
|
-import com.zhongzheng.modules.user.service.IUserExamGoodsService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserExamGoodsSupplementService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
-import com.zhongzheng.modules.user.vo.UserExamGoodsVo;
|
|
|
-import com.zhongzheng.modules.user.vo.UserSubscribeVo;
|
|
|
-import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
+import com.zhongzheng.modules.user.mapper.UserPlanMapper;
|
|
|
+import com.zhongzheng.modules.user.service.*;
|
|
|
+import com.zhongzheng.modules.user.vo.*;
|
|
|
import com.zhongzheng.modules.wx.service.IWxPayService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -149,6 +152,18 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
|
|
|
@Autowired
|
|
|
private IUserSubscribeService iUserSubscribeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserPlanService userPlanService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserPlanMapper userPlanMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamApplyMapper examApplyMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamBeforeMapper examBeforeMapper;
|
|
|
+
|
|
|
@Value("${aliyun.sms.OpenTheGoodsCode}")
|
|
|
private String OpenTheGoodsCode;
|
|
|
|
|
@@ -546,7 +561,192 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
|
|
|
|
|
|
@Override
|
|
|
public void UpPlan(UserQueryBo bo) {
|
|
|
+ UserPlanQueryBo userPlanQueryBo = new UserPlanQueryBo();
|
|
|
+ userPlanQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
|
|
|
+ List<UserPlanVo> userPlanVos = userPlanService.queryList(userPlanQueryBo);
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
+ boolean status = false;
|
|
|
+ for (UserPlanVo userPlanVo : userPlanVos) {
|
|
|
+ List<CalendarStudyVo> calendarStudyUp = userPlanVo.getCalendarStudyVo();
|
|
|
+ for (CalendarStudyVo studyVo : calendarStudyUp) {
|
|
|
+ if (studyVo.getMonth().equals(Convert.toLong(rightNow.get(Calendar.MONTH) + 1)) && studyVo.getYear().equals(Convert.toLong(rightNow.get(Calendar.YEAR)))) {
|
|
|
+ for (DayStudyVo dayStudyVo : studyVo.getDayStudyList()) {
|
|
|
+ if (dayStudyVo.getDate().equals(Convert.toLong(rightNow.get(Calendar.DAY_OF_MONTH)))) {
|
|
|
+ if (dayStudyVo.getPerform() != null && dayStudyVo.getPerform().equals(2)) {
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
+ status = true;
|
|
|
+ for (DaySectionVo daySectionVo : dayStudyVo.getDaySectionList()) {
|
|
|
+ daySectionVo.setGoodsPerform(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (status) {
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
+ List<CalendarStudyVo> clCalendarStudyVos = userPlanVo.getCalendarStudyVo();
|
|
|
+ Long secAll = 0L;
|
|
|
+ Long sumUp = 0L;
|
|
|
+ for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
|
+ for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
|
+ Calendar c5 = Calendar.getInstance();
|
|
|
+ if ((clCalendarStudyVo.getMonth() <= (c5.get(Calendar.MONTH) + 1) && dayStudyVo.getDate() > c5.get(Calendar.DAY_OF_MONTH)) && (clCalendarStudyVo.getMonth() <= (c5.get(Calendar.MONTH) + 1) || clCalendarStudyVo.getYear() <= (c5.get(Calendar.YEAR)))) {
|
|
|
+ dayStudyVo.setStudyCourseKnob(null);
|
|
|
+ dayStudyVo.setDaySectionList(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Long aLong : userPlanVo.getGoodsId()) {
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
+ Date date1 = new Date(userPlanVo.getEndTime() * 1000L);
|
|
|
+ //获得相隔天数
|
|
|
+ int dutyDays = getDutyDays(new Date(), date1, userPlanVo.getStudyCount(), userPlanVo.getStudyDay());
|
|
|
+ if (dutyDays < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> seLongs = userPlanMapper.selectGoods(aLong);
|
|
|
+ Long allNum = 0L;
|
|
|
+ for (Long seLong : seLongs) {
|
|
|
+ allNum += seLong;
|
|
|
+ }
|
|
|
+ Long reduce = baseMapper.selectGoodsPlanCount(aLong,userPlanVo.getPlanId());
|
|
|
+ sumUp = allNum-reduce;
|
|
|
+ //计算每天需要学习多少节课
|
|
|
+ int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
+ secAll += Sec;
|
|
|
+ for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
|
+ for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
|
+ if (Arrays.asList(userPlanVo.getStudyCount()).contains(dayStudyVo.getStudyDay())) {
|
|
|
+ if (allNum < 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Calendar c5 = Calendar.getInstance();
|
|
|
+ if (dayStudyVo.getDate() <= c5.get(Calendar.DAY_OF_MONTH) && clCalendarStudyVo.getMonth() == (c5.get(Calendar.MONTH) + 1) && clCalendarStudyVo.getYear() == (c5.get(Calendar.YEAR))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
|
+ if (allNum < Sec) {
|
|
|
+ dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + allNum);
|
|
|
+ } else {
|
|
|
+ dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (allNum < Sec) {
|
|
|
+ dayStudyVo.setStudyCourseKnob(allNum);
|
|
|
+ } else {
|
|
|
+ dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
+ List<DaySectionVo> daySectionList = new ArrayList<>();
|
|
|
+ if (!com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
|
|
|
+ daySectionList = dayStudyVo.getDaySectionList();
|
|
|
+ }
|
|
|
+ DaySectionVo daySectionVo = new DaySectionVo();
|
|
|
+ daySectionVo.setGoodsId(aLong);
|
|
|
+ if (allNum < Sec) {
|
|
|
+ daySectionVo.setStudyGoodsKnob(Convert.toLong(allNum));
|
|
|
+ } else {
|
|
|
+ daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
|
|
|
+ }
|
|
|
+
|
|
|
+ daySectionVo.setGoodsPerform(0);
|
|
|
+ daySectionList.add(daySectionVo);
|
|
|
+ dayStudyVo.setDaySectionList(daySectionList);
|
|
|
+ allNum -= Sec;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String s = JSON.toJSONString(clCalendarStudyVos);
|
|
|
+ userPlan.setSchedule(s);
|
|
|
+ userPlan.setPlanId(userPlanVo.getPlanId());
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ userPlanMapper.updateById(userPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void UpExam(UserQueryBo bo) {
|
|
|
+ ExamApplyQueryBo examApplyQueryBo = new ExamApplyQueryBo();
|
|
|
+ examApplyQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
|
|
|
+ List<ExamApplyVo> examApplyVos = examApplyMapper.queryExam(examApplyQueryBo);
|
|
|
+ for (ExamApplyVo examApplyVo : examApplyVos) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
|
|
+ calendar.setTimeInMillis(System.currentTimeMillis());
|
|
|
+ if ((examApplyVo.getApplyEndTime()) < calendar.getTimeInMillis()/1000){
|
|
|
+ ExamApply update = new ExamApply();
|
|
|
+ update.setApplyId(examApplyVo.getApplyId());
|
|
|
+ update.setStatus(2);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ examApplyMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExamBeforeQueryBo examBeforeQueryBo = new ExamBeforeQueryBo();
|
|
|
+ examBeforeQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
|
|
|
+ List<ExamBeforeVo> examBeforeVos = examBeforeMapper.queryBefore(examBeforeQueryBo);
|
|
|
+ for (ExamBeforeVo examBeforeVo : examBeforeVos) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
|
|
+ calendar.setTimeInMillis(System.currentTimeMillis());
|
|
|
+ if ((examBeforeVo.getBeforeEndTime()) < calendar.getTimeInMillis()/1000){
|
|
|
+ ExamBefore update = new ExamBefore();
|
|
|
+ update.setBeforeId(examBeforeVo.getBeforeId());
|
|
|
+ update.setStatus(2);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ examBeforeMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UserPlanQueryBo userPlanQueryBo = new UserPlanQueryBo();
|
|
|
+ userPlanQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
|
|
|
+ List<UserPlanVo> userPlanVos = userPlanService.queryList(userPlanQueryBo);
|
|
|
+ for (UserPlanVo userPlanVo : userPlanVos) {
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
+ userPlan.setPlanId(userPlanVo.getPlanId());
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
|
|
+ calendar.setTimeInMillis(System.currentTimeMillis());
|
|
|
+ if ((userPlanVo.getEndTime()) < calendar.getTimeInMillis()/1000 && userPlanVo.getStatus().equals(1)){
|
|
|
+ if (userPlanVo.getPitchNum().equals(userPlanVo.getStudyNum())){
|
|
|
+ userPlan.setStatus(2);
|
|
|
+ }else {
|
|
|
+ userPlan.setStatus(3);
|
|
|
+ }
|
|
|
+ userPlanMapper.updateById(userPlan);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获得可用学习天数
|
|
|
+ private static int getDutyDays(Date startDateStr, Date endDateStr,Long[] longs,Long studyDay) {
|
|
|
+ int result = 0;
|
|
|
+ Date endDate = endDateStr;
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(endDate);
|
|
|
+ c.add(Calendar.DATE, - Convert.toInt(studyDay));
|
|
|
+ endDate = c.getTime();
|
|
|
+
|
|
|
+ Date startDate = startDateStr;
|
|
|
+ int day = startDate.getDay();
|
|
|
+ while (startDate.compareTo(endDate) <= 0) {
|
|
|
+ for (Long integer : longs) {
|
|
|
+ if (startDate.getDay() == integer) {
|
|
|
+ result++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startDate.setDate(startDate.getDate() + 1);
|
|
|
+ }
|
|
|
+ return result-1;
|
|
|
}
|
|
|
|
|
|
private void updateApply() throws ParseException {
|