|
|
@@ -47,14 +47,8 @@ import com.zhongzheng.modules.collect.domain.CollectNote;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectBankMapper;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectCourseMapper;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectNoteMapper;
|
|
|
-import com.zhongzheng.modules.course.domain.Course;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseSubject;
|
|
|
-import com.zhongzheng.modules.course.domain.Major;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseSectionService;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseSubjectService;
|
|
|
-import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
+import com.zhongzheng.modules.course.domain.*;
|
|
|
+import com.zhongzheng.modules.course.service.*;
|
|
|
import com.zhongzheng.modules.exam.service.IExamApplyService;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
@@ -64,6 +58,7 @@ import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.service.impl.ClassGradeServiceImpl;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo;
|
|
|
+import com.zhongzheng.modules.mock.service.IMockApplyService;
|
|
|
import com.zhongzheng.modules.order.vo.OrderListVo;
|
|
|
import com.zhongzheng.modules.system.domain.SysTask;
|
|
|
import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
@@ -73,10 +68,7 @@ import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
|
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
|
-import com.zhongzheng.modules.user.domain.User;
|
|
|
-import com.zhongzheng.modules.user.domain.UserCertificate;
|
|
|
-import com.zhongzheng.modules.user.domain.UserStudyLog;
|
|
|
-import com.zhongzheng.modules.user.domain.UserVisitLog;
|
|
|
+import com.zhongzheng.modules.user.domain.*;
|
|
|
import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
|
import com.zhongzheng.modules.user.mapper.UserMapper;
|
|
|
import com.zhongzheng.modules.user.service.*;
|
|
|
@@ -110,6 +102,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import static cn.hutool.core.util.IdcardUtil.getGenderByIdCard;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 用户Service业务层处理
|
|
|
@@ -188,6 +182,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
private ICourseSectionService iCourseSectionService;
|
|
|
@Autowired
|
|
|
private IFaceOcrService iFaceOcrService;
|
|
|
+ @Autowired
|
|
|
+ private IMockApplyService iMockApplyService;
|
|
|
+ @Autowired
|
|
|
+ private IUserMockSubscribeService iUserMockSubscribeService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseEducationTypeService iCourseEducationTypeService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseProjectTypeService iCourseProjectTypeService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseBusinessService iCourseBusinessService;
|
|
|
@Value("${liveGotoURL}")
|
|
|
private String liveGotoURL;
|
|
|
@Value("${oldSys.goods}")
|
|
|
@@ -2425,6 +2429,166 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getActivityExamApply(ActivityExamApplyBo bo) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseEducationType>().eq(CourseEducationType::getEducationName, "考前培训").eq(CourseEducationType::getStatus, 1).last("limit 1"));
|
|
|
+ Long eduId = educationType.getId();
|
|
|
+ CourseProjectType projectType = iCourseProjectTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseProjectType>().eq(CourseProjectType::getProjectName, "建造师").eq(CourseProjectType::getEducationId, eduId).eq(CourseProjectType::getStatus, 1).last("limit 1"));
|
|
|
+ Long proId = projectType.getId();
|
|
|
+ CourseBusiness business = iCourseBusinessService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseBusiness>().eq(CourseBusiness::getBusinessName, "二级").eq(CourseBusiness::getProjectId, proId).eq(CourseBusiness::getStatus, 1).last("limit 1"));
|
|
|
+ Long businessId = business.getId();
|
|
|
+
|
|
|
+ //查询考试
|
|
|
+ MockApplyByBo byBo = new MockApplyByBo();
|
|
|
+ byBo.setEduId(eduId);
|
|
|
+ byBo.setProId(proId);
|
|
|
+ byBo.setBusinessId(businessId);
|
|
|
+ byBo.setMajorName(bo.getMajorName());
|
|
|
+ MockApplyServiceVo applyServiceVo = iMockApplyService.getMockApplyByBo(byBo);
|
|
|
+ //根据身份证查询账号
|
|
|
+ User user = getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(bo.getUserCard())).eq(User::getStatus, 1).last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(applyServiceVo) ){
|
|
|
+ if (ObjectUtils.isNull(user)){
|
|
|
+ throw new CustomException("考试尚未开始,请耐心等待!");
|
|
|
+ }
|
|
|
+ //时间
|
|
|
+ Long time = DateUtils.getNowTime() - 5L * 24 * 60 * 60 * 1000;
|
|
|
+ UserMockSubscribe subscribeVo = iUserMockSubscribeService.getOne(new LambdaQueryWrapper<UserMockSubscribe>()
|
|
|
+ .eq(UserMockSubscribe::getUserId, user.getUserId())
|
|
|
+ .eq(UserMockSubscribe::getSubscribeStatus, 1)
|
|
|
+ .gt(UserMockSubscribe::getApplySiteExamTime,time)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(subscribeVo)){
|
|
|
+ //有之前的考试记录
|
|
|
+ map.put("mockSing", 1);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (ObjectUtils.isNull(user)){
|
|
|
+ //新增
|
|
|
+ //检测手机号是否重复
|
|
|
+ User user1 = getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getTelphone, EncryptHandler.encrypt(bo.getUserPhone())).eq(User::getStatus, 1).last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(user1)){
|
|
|
+ //手机号码重复
|
|
|
+ bo.setUserPhone(TelPhoneUtils.createMobile());
|
|
|
+ }
|
|
|
+ User inertData = new User();
|
|
|
+ inertData.setTelphone(bo.getUserPhone());
|
|
|
+ //隐藏手机号作为初始昵称
|
|
|
+ inertData.setNickname(TelPhoneUtils.hideTelPhone(bo.getUserPhone(),1));
|
|
|
+ //雪花算法产生账号ID
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
+ inertData.setUserAccount(String.valueOf(idWorker.nextId()));
|
|
|
+ inertData.setSex(1);
|
|
|
+ inertData.setEduLevel("本科");
|
|
|
+ inertData.setSex(getGenderByIdCard(bo.getUserCard()));
|
|
|
+ inertData.setIdCard(bo.getUserCard());
|
|
|
+ inertData.setRealname(bo.getUserName());
|
|
|
+ inertData.setStatus(1);
|
|
|
+ inertData.setRegisterPlat("6");
|
|
|
+ inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
+ inertData.setLastLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ inertData.setLastLoginTime(DateUtils.getNowTime());
|
|
|
+ inertData.setCreateTime(DateUtils.getNowTime());
|
|
|
+ inertData.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ String pwd = "";
|
|
|
+ if (ObjectUtils.isNotNull(bo.getUserCard())){
|
|
|
+ pwd = bo.getUserCard().substring(bo.getUserCard().length() - 6);
|
|
|
+ }else {
|
|
|
+ pwd = bo.getUserPhone().substring(bo.getUserPhone().length() - 6);
|
|
|
+ }
|
|
|
+ inertData.setPasswordAes(EncryptHandler.encrypt(pwd));
|
|
|
+ inertData.setPassword(SecurityUtils.encryptPassword(pwd));
|
|
|
+ if(!save(inertData)){
|
|
|
+ throw new CustomException("注册失败");
|
|
|
+ }
|
|
|
+ user = inertData;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserMockSubscribe subscribeVo = iUserMockSubscribeService.getOne(new LambdaQueryWrapper<UserMockSubscribe>()
|
|
|
+ .eq(UserMockSubscribe::getUserId, user.getUserId())
|
|
|
+ .eq(UserMockSubscribe::getApplyId, applyServiceVo.getApplyId())
|
|
|
+ .eq(UserMockSubscribe::getEachExamId, applyServiceVo.getEachExamId())
|
|
|
+ .eq(UserMockSubscribe::getSubscribeStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(subscribeVo)){
|
|
|
+ //不存在创建预约信息
|
|
|
+ UserMockSubscribe subscribe = new UserMockSubscribe();
|
|
|
+ subscribe.setUserId(user.getUserId());
|
|
|
+ subscribe.setEachExamId(applyServiceVo.getEachExamId());
|
|
|
+ subscribe.setSubscribeStatus(1);
|
|
|
+ subscribe.setBeforeStatus(0);
|
|
|
+ subscribe.setExamStatus(0);
|
|
|
+ subscribe.setHandStatus(0);
|
|
|
+ subscribe.setApplyId(applyServiceVo.getApplyId());
|
|
|
+ subscribe.setMockMajorSubjectId(applyServiceVo.getMockMajorSubjectId());
|
|
|
+ subscribe.setCreateTime(DateUtils.getNowTime());
|
|
|
+ subscribe.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ subscribe.setApplySiteStartTime(applyServiceVo.getStartTime());
|
|
|
+ subscribe.setApplySiteEndTime(applyServiceVo.getEndTime());
|
|
|
+ subscribe.setApplySiteExamTime(applyServiceVo.getExamTime());
|
|
|
+ subscribe.setMockRemind(0);
|
|
|
+ subscribe.setLiveSubscribe(0);
|
|
|
+ subscribe.setHasLiveSubscribe(0);
|
|
|
+ subscribe.setHasMockRemind(0);
|
|
|
+ iUserMockSubscribeService.save(subscribe);
|
|
|
+ subscribeVo = subscribe;
|
|
|
+ }
|
|
|
+ //返回信息
|
|
|
+ UserMockServiceVo serviceVo = BeanUtil.toBean(applyServiceVo, UserMockServiceVo.class);
|
|
|
+ serviceVo.setSubscribeId(subscribeVo.getSubscribeId());
|
|
|
+ serviceVo.setApplySiteEndTime(subscribeVo.getApplySiteEndTime());
|
|
|
+ serviceVo.setApplySiteStartTime(subscribeVo.getApplySiteStartTime());
|
|
|
+ serviceVo.setApplySiteExamTime(subscribeVo.getApplySiteExamTime());
|
|
|
+
|
|
|
+ map.put("mock_service",serviceVo);
|
|
|
+ Long endTime = subscribeVo.getApplySiteExamTime() + 7200L;
|
|
|
+ if (DateUtils.getNowTime() >= subscribeVo.getApplySiteExamTime() && DateUtils.getNowTime() <= endTime){
|
|
|
+ map.put("mockSing", 2); //考前中
|
|
|
+ }else {
|
|
|
+ map.put("mockSing", 3); //未考试
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //登入token
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
+ loginUser.setUser(user);
|
|
|
+
|
|
|
+ map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
|
|
|
+ map.put("user_account",user.getUserAccount());
|
|
|
+ map.put("full_info",true); //是否完善身份信息
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据身份证号码判断性别
|
|
|
+ *
|
|
|
+ * @param idCard 身份证号码
|
|
|
+ * @return "男" 或 "女"
|
|
|
+ */
|
|
|
+ private Integer getGenderByIdCard(String idCard) {
|
|
|
+ if (idCard == null || idCard.length() != 18) {
|
|
|
+ throw new IllegalArgumentException("无效的身份证号码");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取第17位字符
|
|
|
+ char genderChar = idCard.charAt(16);
|
|
|
+
|
|
|
+ // 判断奇偶性
|
|
|
+ int genderDigit = Character.getNumericValue(genderChar);
|
|
|
+ if (genderDigit % 2 == 0) {
|
|
|
+ return 2;
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String getTelPhone(){
|
|
|
String mobile = TelPhoneUtils.createMobile();
|
|
|
int count = count(new LambdaQueryWrapper<User>().eq(User::getIdCard, EncryptHandler.encrypt(mobile)));
|