|
@@ -5,10 +5,7 @@ import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
-import com.ym.mec.biz.dal.enums.HumanCostTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.StudentPreVisitQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentVisitQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentVisitService;
|
|
@@ -112,36 +109,44 @@ public class StudentVisitServiceImpl extends BaseServiceImpl<Integer, StudentVis
|
|
|
public void batchAddVisit(List<StudentVisit> studentVisit) {
|
|
|
Integer userId = sysUserService.getUserId();
|
|
|
StudentVisit.VisiterTypeEnum visitType = StudentVisit.VisiterTypeEnum.EDU_TEACHER;
|
|
|
- List<Integer> studentIds = studentVisit.stream().map(e -> e.getStudentId()).collect(Collectors.toList());
|
|
|
- List<SimpleUserDto> userDtos = teacherDao.getUsersSimpleInfo(studentIds);
|
|
|
- Date now = new Date();
|
|
|
- Map<Integer, SimpleUserDto> userDtoMap = userDtos.stream().collect(Collectors.groupingBy(e -> e.getUserId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
|
- Map<String,List<Integer>> visitMap = new HashMap<>();
|
|
|
- for (StudentVisit visit : studentVisit) {
|
|
|
- visit.setType("其他");
|
|
|
- visit.setPurpose("其他");
|
|
|
- visit.setTeacherId(userId);
|
|
|
- visit.setVisiterType(visitType);
|
|
|
- SimpleUserDto userDto = userDtoMap.get(visit.getStudentId());
|
|
|
- if (Objects.isNull(userDto)){
|
|
|
- throw new BizException("学员编号{}用户信息不存在",visit.getStudentId());
|
|
|
+ Map<String, List<StudentVisit>> musicMap = studentVisit.stream().collect(Collectors.groupingBy(e -> e.getMusicGroupId()));
|
|
|
+ for (String musicGroupId : musicMap.keySet()) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if(musicGroup.getStatus() != MusicGroupStatusEnum.PAY){
|
|
|
+ throw new BizException("当前乐团状态无需批量回访");
|
|
|
+ }
|
|
|
+ List<StudentVisit> studentVisits = musicMap.get(musicGroupId);
|
|
|
+ List<Integer> studentIds = studentVisits.stream().map(e -> e.getStudentId()).collect(Collectors.toList());
|
|
|
+ List<SimpleUserDto> userDtos = teacherDao.getUsersSimpleInfo(studentIds);
|
|
|
+ Date now = new Date();
|
|
|
+ Map<Integer, SimpleUserDto> userDtoMap = userDtos.stream().collect(Collectors.groupingBy(e -> e.getUserId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
|
+ Map<String,List<Integer>> visitMap = new HashMap<>();
|
|
|
+ for (StudentVisit visit : studentVisits) {
|
|
|
+ visit.setType("其他");
|
|
|
+ visit.setPurpose("其他");
|
|
|
+ visit.setTeacherId(userId);
|
|
|
+ visit.setVisiterType(visitType);
|
|
|
+ SimpleUserDto userDto = userDtoMap.get(visit.getStudentId());
|
|
|
+ if (Objects.isNull(userDto)){
|
|
|
+ throw new BizException("学员编号{}用户信息不存在",visit.getStudentId());
|
|
|
+ }
|
|
|
+ visit.setOrganId(Integer.parseInt(userDto.getOrganIds()));
|
|
|
+ visit.setCreateTime(now);
|
|
|
+ String month = DateUtil.format(visit.getVisitTime(), DateUtil.ISO_YEAR_MONTH_FORMAT);
|
|
|
+ List<Integer> userIds;
|
|
|
+ if(visitMap.containsKey(month)){
|
|
|
+ userIds = visitMap.get(month);
|
|
|
+ }else {
|
|
|
+ userIds = new ArrayList<>();
|
|
|
+ }
|
|
|
+ userIds.add(visit.getStudentId());
|
|
|
+ visitMap.put(month,userIds);
|
|
|
}
|
|
|
- visit.setOrganId(Integer.parseInt(userDto.getOrganIds()));
|
|
|
- visit.setCreateTime(now);
|
|
|
- String month = DateUtil.format(visit.getVisitTime(), DateUtil.ISO_YEAR_MONTH_FORMAT);
|
|
|
- List<Integer> userIds;
|
|
|
- if(visitMap.containsKey(month)){
|
|
|
- userIds = visitMap.get(month);
|
|
|
- }else {
|
|
|
- userIds = new ArrayList<>();
|
|
|
+ studentVisitDao.batchInsert(studentVisits);
|
|
|
+ //更新学员回访统计数据
|
|
|
+ for (String month : visitMap.keySet()) {
|
|
|
+ studentOperatingVisitDao.batchUpdateVisit(visitMap.get(month),month);
|
|
|
}
|
|
|
- userIds.add(visit.getStudentId());
|
|
|
- visitMap.put(month,userIds);
|
|
|
- }
|
|
|
- studentVisitDao.batchInsert(studentVisit);
|
|
|
- //更新学员回访统计数据
|
|
|
- for (String month : visitMap.keySet()) {
|
|
|
- studentOperatingVisitDao.batchUpdateVisit(visitMap.get(month),month);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -308,7 +313,7 @@ public class StudentVisitServiceImpl extends BaseServiceImpl<Integer, StudentVis
|
|
|
StudentVisit cost = JSONObject.parseObject(objectMap.toJSONString(), StudentVisit.class);
|
|
|
StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(cost.getStudentId(), cost.getMusicGroupId());
|
|
|
if(Objects.isNull(studentRegistration)){
|
|
|
- throw new BizException("学员{}不在乐团{}中,无需回访",studentRegistration.getUserId(),studentRegistration.getMusicGroupId());
|
|
|
+ throw new BizException("学员{}不在乐团{}中,无需回访",cost.getStudentId(),cost.getMusicGroupId());
|
|
|
}
|
|
|
if(studentRegistration.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY){
|
|
|
throw new BizException("学员{}已缴费无需回访",studentRegistration.getUserId());
|