|
@@ -3,6 +3,7 @@ package com.zhongzheng.modules.user.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -33,6 +34,7 @@ import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeJson;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeTwoAddBo;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamApply;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamApplySite;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamApplySiteTime;
|
|
@@ -49,12 +51,16 @@ import com.zhongzheng.modules.exam.vo.ExamSessionVo;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
|
import com.zhongzheng.modules.inform.service.IInformUserService;
|
|
|
import com.zhongzheng.modules.inform.vo.InformRemindBusinessVo;
|
|
|
import com.zhongzheng.modules.inform.vo.InformRemindVo;
|
|
|
+import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.domain.UserExamGoods;
|
|
@@ -141,6 +147,11 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
@Autowired
|
|
|
private IMajorService majorService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderGoodsService iOrderGoodsService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeUserService iClassGradeUserService;
|
|
|
+
|
|
|
@Value("${aliyun.sms.cancellationReminder}")
|
|
|
private String cancellationReminder;
|
|
|
|
|
@@ -2101,6 +2112,16 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
if (System.currentTimeMillis()/1000 > time){
|
|
|
throw new CustomException("当前选择的考试时间已过期,请重新预约,选择未过期考试时间");
|
|
|
}
|
|
|
+
|
|
|
+ //查询是否已预约考试
|
|
|
+ ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
|
|
|
+ queryBo.setUserId(bo.getUserId());
|
|
|
+ queryBo.setGoodsId(bo.getGoodsId());
|
|
|
+ queryBo.setOrderGoodsId(bo.getOrderGoodsId());
|
|
|
+ Integer countHaveSubscribe = examApplyMapper.countHaveSubscribe(queryBo);
|
|
|
+ if (countHaveSubscribe > 0) {
|
|
|
+ throw new CustomException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
|
|
|
+ }
|
|
|
//生成座位号
|
|
|
ExamApplySite applySite = iExamApplySiteService.getOne(new LambdaQueryWrapper<ExamApplySite>()
|
|
|
.eq(ExamApplySite::getApplyId, bo.getApplyId())
|
|
@@ -2238,6 +2259,122 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void examApplySubscribe(ExamApplySubscribeBo bo) {
|
|
|
+ //学员校验
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getIdCard()), User::getIdCard, EncryptHandler.encrypt(bo.getIdCard()))
|
|
|
+ .eq(ObjectUtil.isNotNull(bo.getTelphone()), User::getTelphone, EncryptHandler.encrypt(bo.getTelphone()))
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtil.isNull(user)){
|
|
|
+ throw new CustomException("学员信息查询不到!请检查");
|
|
|
+ }
|
|
|
+
|
|
|
+ //考场信息
|
|
|
+ ExamApply examApply = iExamApplyService.getById(bo.getSignId());
|
|
|
+ if (ObjectUtil.isNull(examApply)){
|
|
|
+ throw new CustomException("考场信息查询不到!请检查");
|
|
|
+ }
|
|
|
+ List<Long> goodsIds = iExamApplyService.getApplyGoodsId(examApply.getApplyId(),bo.getMajorName());
|
|
|
+ if (CollectionUtils.isEmpty(goodsIds)){
|
|
|
+ throw new CustomException("该专业下找不到考试对应的课程!请检查");
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否存在订单
|
|
|
+ List<OrderGoods> orderGoodsList = iOrderGoodsService.getApplyOrderGoods(goodsIds,user.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(orderGoodsList)){
|
|
|
+ throw new CustomException("当前学员没有购买该专业下的课程!请检查");
|
|
|
+ }
|
|
|
+ OrderGoods applyOrder = null;
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ ClassGradeUser gradeUser = iClassGradeUserService
|
|
|
+ .getOne(new LambdaQueryWrapper<ClassGradeUser>()
|
|
|
+ .eq(ClassGradeUser::getUserId, user.getUserId())
|
|
|
+ .eq(ClassGradeUser::getGradeId, orderGoods.getGradeId())
|
|
|
+ .eq(ClassGradeUser::getOrderGoodsId, orderGoods.getOrderGoodsId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtil.isNotNull(gradeUser)){
|
|
|
+ //学时是否通过审核
|
|
|
+ if (ObjectUtils.isNotNull(gradeUser.getPeriodStatus()) && gradeUser.getPeriodStatus() == 1){
|
|
|
+ applyOrder = orderGoods;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Validator.isEmpty(applyOrder)){
|
|
|
+ throw new CustomException("该学员未学完,不能预约考试!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询是否已预约考试
|
|
|
+ ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
|
|
|
+ queryBo.setUserId(user.getUserId());
|
|
|
+ queryBo.setGoodsId(applyOrder.getGoodsId());
|
|
|
+ queryBo.setOrderGoodsId(applyOrder.getOrderGoodsId());
|
|
|
+ Integer countHaveSubscribe = examApplyMapper.countHaveSubscribe(queryBo);
|
|
|
+ if (countHaveSubscribe > 0) {
|
|
|
+ throw new CustomException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamSite site = iExamSiteService.getOne(new LambdaQueryWrapper<ExamSite>().eq(ExamSite::getSign, 1).eq(ExamSite::getStatus, 1).last("limit 1"));
|
|
|
+
|
|
|
+ //生成座位号
|
|
|
+ ExamApplySite applySite = iExamApplySiteService.getOne(new LambdaQueryWrapper<ExamApplySite>()
|
|
|
+ .eq(ExamApplySite::getApplyId, examApply.getApplyId())
|
|
|
+ .eq(ExamApplySite::getSiteId, site.getSiteId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(applySite)){
|
|
|
+ throw new CustomException("考试地点查询有误,请检查");
|
|
|
+ }
|
|
|
+ List<ExamApplySiteTime> siteTimeList = iExamApplySiteTimeService.list(new LambdaQueryWrapper<ExamApplySiteTime>()
|
|
|
+ .eq(ExamApplySiteTime::getApplyId, examApply.getApplyId())
|
|
|
+ .eq(ExamApplySiteTime::getApplySiteId, applySite.getId())
|
|
|
+ .eq(ExamApplySiteTime::getExamTime, bo.getApplyTime()));
|
|
|
+ if (CollectionUtils.isEmpty(siteTimeList)){
|
|
|
+ throw new CustomException("考试时间查询有误,请检查");
|
|
|
+ }
|
|
|
+ ExamApplySiteTime examApplySiteTime = siteTimeList.stream().filter(item -> {
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
|
|
|
+ return twoAddBo.getStartTime().equals(bo.getApplyStartTime()) && twoAddBo.getEndTime().equals(bo.getApplyEndTime());
|
|
|
+ }).findFirst().orElse(null);
|
|
|
+ if (ObjectUtils.isNull(examApplySiteTime)){
|
|
|
+ throw new CustomException("预约考试时间不存在,请重新选择");
|
|
|
+ }
|
|
|
+ //考场人数
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(examApplySiteTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ Long userNum = siteTimeTwoAddBos.get(0).getNum();
|
|
|
+
|
|
|
+ //生成座位号
|
|
|
+ UserSubscribeAddBo userSubscribeAddBo = new UserSubscribeAddBo();
|
|
|
+ userSubscribeAddBo.setApplyId(examApply.getApplyId());
|
|
|
+ userSubscribeAddBo.setApplySiteStartTime(bo.getApplyStartTime());
|
|
|
+ userSubscribeAddBo.setApplySiteEndTime(bo.getApplyEndTime());
|
|
|
+ userSubscribeAddBo.setSiteId(site.getSiteId());
|
|
|
+ Integer tNum = getSeatNumber(userSubscribeAddBo,userNum);
|
|
|
+
|
|
|
+ //考场信息
|
|
|
+ UserSubscribe add = new UserSubscribe();
|
|
|
+ add.setOrderGoodsId(applyOrder.getOrderGoodsId());
|
|
|
+ add.setGoodsId(applyOrder.getGoodsId());
|
|
|
+ add.setUserId(user.getUserId());
|
|
|
+ add.setSeatNumber(tNum.toString());
|
|
|
+ add.setApplyId(examApply.getApplyId());
|
|
|
+ add.setApplySiteStartTime(bo.getApplyStartTime());
|
|
|
+ add.setApplySiteEndTime(bo.getApplyEndTime());
|
|
|
+ add.setApplySiteExamTime(bo.getApplyTime());
|
|
|
+ add.setSiteId(site.getSiteId());
|
|
|
+ add.setExamExpend(1);
|
|
|
+ add.setApplySiteAddress(site.getSiteAddress());
|
|
|
+ add.setSubscribeStatus(1);
|
|
|
+ add.setExamStatus(0);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ add.setExamineeCode(ServletUtils.getEncoded("ZZ"+ ToolsUtils.autoGenericCode(String.valueOf(add.getApplyId()),4) +ToolsUtils.autoGenericCode(String.valueOf(add.getUserId()),4)));
|
|
|
+ this.save(add);
|
|
|
+
|
|
|
+ //发送预约考试消息
|
|
|
+// sendExamSucceed(bo);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private Integer getSeatNumber(UserSubscribeAddBo bo,Long userNum) {
|