|
@@ -28,8 +28,11 @@ import com.zhongzheng.modules.collect.mapper.CollectCourseMapper;
|
|
import com.zhongzheng.modules.collect.mapper.CollectNoteMapper;
|
|
import com.zhongzheng.modules.collect.mapper.CollectNoteMapper;
|
|
import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
|
|
import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
|
|
import com.zhongzheng.modules.course.bo.CourseQueryBo;
|
|
import com.zhongzheng.modules.course.bo.CourseQueryBo;
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSubject;
|
|
import com.zhongzheng.modules.course.domain.MajorCategory;
|
|
import com.zhongzheng.modules.course.domain.MajorCategory;
|
|
import com.zhongzheng.modules.course.service.ICourseService;
|
|
import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
|
+import com.zhongzheng.modules.course.service.ICourseSubjectService;
|
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
@@ -103,7 +106,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private ICourseService iCourseService;
|
|
|
|
|
|
+ private ICourseSubjectService iCourseSubjectService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -549,6 +552,128 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> importUser(List<UserImportAddBo> list, String importNo) {
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
+ throw new IllegalArgumentException("请勿导入空表格");
|
|
|
|
+ }
|
|
|
|
+ List<UserImportAddBo> errorList = new ArrayList<>();
|
|
|
|
+ List<UserImportAddBo> successList = new ArrayList<>();
|
|
|
|
+ for (UserImportAddBo itemImport : list) {
|
|
|
|
+ if(Validator.isEmpty(itemImport.getTelphone())||itemImport.getTelphone().length()!=11){
|
|
|
|
+ itemImport.setCause("手机号不能为空或者格式不对");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(itemImport.getIdCard())){
|
|
|
|
+ itemImport.setCause("身份证不能为空");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(itemImport.getRealname())){
|
|
|
|
+ itemImport.setCause("真实姓名不能为空");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ User user = getOne(new LambdaQueryWrapper<User>()
|
|
|
|
+ .eq(User::getTelphone,itemImport.getTelphone()).last("limit 1"));
|
|
|
|
+ if(Validator.isNotNull(user)){
|
|
|
|
+ if(Validator.isNotEmpty(user.getImportNo())&&user.getImportNo().equals(importNo)){
|
|
|
|
+ //同批次不作处理
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ itemImport.setCause("该手机号已注册");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ User user2 = getOne(new LambdaQueryWrapper<User>()
|
|
|
|
+ .eq(User::getIdCard,itemImport.getIdCard()).last("limit 1"));
|
|
|
|
+ if(Validator.isNotNull(user2)){
|
|
|
|
+ if(Validator.isNotEmpty(user.getImportNo())&&user.getImportNo().equals(importNo)){
|
|
|
|
+ //同批次不作处理
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ itemImport.setCause("该身份证已被使用");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //科目
|
|
|
|
+ if(Validator.isEmpty(itemImport.getSubjectNames())){
|
|
|
|
+ List<String> SubjectList = Arrays.asList(itemImport.getSubjectNames().split(","));
|
|
|
|
+ List<Long> sIdList = new ArrayList<>();
|
|
|
|
+ for (String subject : SubjectList) {
|
|
|
|
+ Long subjectId = findSubjectId(subject);
|
|
|
|
+ if(Validator.isNotEmpty(subjectId)){
|
|
|
|
+ //科目存在
|
|
|
|
+ sIdList.add(subjectId);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ itemImport.setSubjectIds(ToolsUtils.join(",", sIdList));
|
|
|
|
+ }
|
|
|
|
+ if(Validator.isEmpty(importNo)){
|
|
|
|
+ importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
|
+ }
|
|
|
|
+ User inertData = new User();
|
|
|
|
+ inertData.setTelphone(itemImport.getTelphone());
|
|
|
|
+ //隐藏手机号作为初始昵称
|
|
|
|
+ inertData.setNickname(TelPhoneUtils.hideTelPhone(itemImport.getTelphone()));
|
|
|
|
+ //雪花算法产生账号ID
|
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
|
+ inertData.setUserAccount(String.valueOf(idWorker.nextId()));
|
|
|
|
+ inertData.setSex(1);
|
|
|
|
+ inertData.setIdCard(itemImport.getIdCard());
|
|
|
|
+ inertData.setRealname(itemImport.getRealname());
|
|
|
|
+ inertData.setStatus(1);
|
|
|
|
+ inertData.setRegisterPlat("3");
|
|
|
|
+ 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 = ToolsUtils.getSmsCode(); // 随机密码
|
|
|
|
+ inertData.setPassword(SecurityUtils.encryptPassword(pwd));
|
|
|
|
+ inertData.setImportNo(importNo); //设置导入编号 一个导入页面同时导入多次算一个编号
|
|
|
|
+ if(!save(inertData)){
|
|
|
|
+ itemImport.setCause("注册失败");
|
|
|
|
+ errorList.add(itemImport);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ iSmsService.sendPwdSms(itemImport.getTelphone(),pwd);
|
|
|
|
+ itemImport.setUserId(inertData.getUserId());
|
|
|
|
+ itemImport.setImportNo(importNo);
|
|
|
|
+ successList.add(itemImport);
|
|
|
|
+ }
|
|
|
|
+ Map<String,Object> resultMap = new HashMap<>();
|
|
|
|
+ resultMap.put("errorList",errorList);
|
|
|
|
+ resultMap.put("successList",successList);
|
|
|
|
+ return resultMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long findSubjectId(String subject){
|
|
|
|
+
|
|
|
|
+ if(subject!=null){
|
|
|
|
+ String key = "SUB_"+subject;
|
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
|
+ if(value!=null){
|
|
|
|
+ if(value==0L){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+ CourseSubject info = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>()
|
|
|
|
+ .eq(CourseSubject::getSubjectName,subject).eq(CourseSubject::getStatus,1).last("limit 1"));
|
|
|
|
+ if(info!=null){
|
|
|
|
+ redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
|
|
|
|
+ return info.getId();
|
|
|
|
+ }else{
|
|
|
|
+ redisCache.setCacheObject(key,0L,3, TimeUnit.MINUTES);//3分钟
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Boolean forgetUser(UserAppForgetBo bo) {
|
|
public Boolean forgetUser(UserAppForgetBo bo) {
|
|
if(bo.getTel()==null){
|
|
if(bo.getTel()==null){
|
|
@@ -727,18 +852,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
return baseMapper.orderSum(userId);
|
|
return baseMapper.orderSum(userId);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public Map<String, Object> importUser(List<UserImportAddBo> list) {
|
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
|
- throw new IllegalArgumentException("请勿导入空表格");
|
|
|
|
- }
|
|
|
|
- List<UserImportAddBo> errorList = new ArrayList<>();
|
|
|
|
- List<UserImportAddBo> successList = new ArrayList<>();
|
|
|
|
- for (UserImportAddBo itemImport : list) {
|
|
|
|
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|