ソースを参照

Merge branch 'master' into adapay_delay_1231

周箭河 4 年 前
コミット
d9c00927af

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentExtracurricularExercisesSituationDao.java

@@ -29,7 +29,8 @@ public interface StudentExtracurricularExercisesSituationDao extends BaseDAO<Lon
      * @param monday:
      * @return int
      */
-    int deleteByMonday(@Param("monday") String monday);
+    int deleteByMonday(@Param("monday") String monday,
+                       @Param("studentIds") List<Integer> studentIds);
 
     /**
      * @describe 删除指定学员的服务指标

+ 43 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1561,10 +1561,27 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (musicGroup == null) {
             throw new BizException("乐团不存在");
         }
+        
+        if(musicGroup.getStatus() == MusicGroupStatusEnum.CANCELED || musicGroup.getStatus() == MusicGroupStatusEnum.PAUSE){
+        	throw new BizException("申请失败,乐团状态[已取消]或[已暂停]");
+        }
+        Integer userId = sysUser.getId();
+        
+        StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+        if (studentRegistration == null) {
+            throw new BizException("用户注册信息不存在");
+        }
+        
+        MusicGroupQuit musicGroupQuit = musicGroupQuitDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+    	if(musicGroupQuit != null){
+    		if(musicGroupQuit.getStatus() == ApprovalStatus.PROCESSING){
+    			throw new BizException("申请失败,存在[申请中]的记录");
+    		}
+    	}
 
-        MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
+        musicGroupQuit = new MusicGroupQuit();
         musicGroupQuit.setCreateTime(new Date());
-        musicGroupQuit.setJoinDate(sysUser.getCreateTime());
+        musicGroupQuit.setJoinDate(studentRegistration.getCreateTime());
         musicGroupQuit.setMusicGroupId(musicGroupId);
         musicGroupQuit.setUserId(sysUser.getId());
         musicGroupQuit.setUserComment(reason);
@@ -1624,6 +1641,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String musicGroupId = musicGroupQuit.getMusicGroupId();
         Integer userId = musicGroupQuit.getUserId();
+        
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团不存在");
+        }
+        
+        if(musicGroup.getStatus() == MusicGroupStatusEnum.CANCELED || musicGroup.getStatus() == MusicGroupStatusEnum.PAUSE){
+        	throw new BizException("申请失败,乐团状态[已取消]或[已暂停]");
+        }
 
         musicGroupQuit.setStatus(status);
         musicGroupQuit.setReason(reason);
@@ -1766,12 +1792,26 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (sysUser == null) {
             throw new BizException("获取用户信息失败");
         }
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团不存在");
+        }
+        
+        if(musicGroup.getStatus() == MusicGroupStatusEnum.CANCELED || musicGroup.getStatus() == MusicGroupStatusEnum.PAUSE){
+        	throw new BizException("申请失败,乐团状态[已取消]或[已暂停]");
+        }
 
+        // 判断乐器是否是租赁
+        StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+        if (studentRegistration == null) {
+            throw new BizException("用户注册信息不存在");
+        }
+        
         Date date = new Date();
 
         MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
         musicGroupQuit.setCreateTime(date);
-        musicGroupQuit.setJoinDate(sysUser.getCreateTime());
+        musicGroupQuit.setJoinDate(studentRegistration.getCreateTime());
         musicGroupQuit.setMusicGroupId(musicGroupId);
         musicGroupQuit.setUserId(sysUser.getId());
         musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
@@ -1780,12 +1820,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         musicGroupQuitDao.insert(musicGroupQuit);
 
-        // 判断乐器是否是租赁
-        StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-        if (studentRegistration == null) {
-            throw new BizException("用户注册信息不存在");
-        }
-
         List<Integer> classGroupIdList = classGroupStudentMapperDao.queryClassGroupIdList(musicGroupId, userId, GroupType.MUSIC);
         for (Integer classGroupId : classGroupIdList) {
             ClassGroup classGroup = classGroupService.get(classGroupId);

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -653,6 +653,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }*/
         Date date = new Date();
         String musicGroupId = studentRegistration.getMusicGroupId();
+        
+        studentRegistration.setCreateTime(date);
+        studentRegistration.setUpdateTime(date);
 
         StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(musicGroupId, studentRegistration.getParentsPhone());
         if (phoneAndMusicGroupId != null && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY) {

+ 49 - 46
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -275,7 +275,7 @@ public class StudentServeServiceImpl implements StudentServeService {
             currentPage=currentPage.add(BigDecimal.ONE);
         }
 
-        studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
+        studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), null);
 
         BigDecimal currentPage1=BigDecimal.ONE,
                 pageSize1=new BigDecimal(10000),
@@ -428,6 +428,7 @@ public class StudentServeServiceImpl implements StudentServeService {
 
         if(!CollectionUtils.isEmpty(results)){
 //            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
+            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds);
             BigDecimal currentPage1=BigDecimal.ONE,
                     pageSize1=new BigDecimal(10000),
                     total1=new BigDecimal(results.size()),
@@ -435,51 +436,53 @@ public class StudentServeServiceImpl implements StudentServeService {
 
             while (currentPage1.compareTo(totalPage1)<=0){
                 List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
-                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
-
-                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
-                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
-
-                Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
-                for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
-                    if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
-                        continue;
-                    }
-                    studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
-                }
-
-                List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
-                List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
-                for (StudentExtracurricularExercisesSituation result : rows) {
-                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){
-                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
-                        Set<Long> courseIds = new HashSet<>();
-                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
-                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
-                        }
-                        if(StringUtils.isNotBlank(result.getCourseIds())){
-                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
-                        }
-                        s.setServeType(result.getServeType());
-                        if(s.getServeType().equals("HOMEWORK")){
-                            s.setCourseIds(StringUtils.join(courseIds, ","));
-                        }else{
-                            s.setCourseIds("");
-                        }
-                        if(StringUtils.isBlank(s.getCourseIds())){
-                            s.setExpectExercisesNum(1);
-                        }else{
-                            s.setExpectExercisesNum(courseIds.size());
-                        }
-                        updateService.add(s);
-                    }else{
-                        newService.add(result);
-                    }
-                }
-                if(!CollectionUtils.isEmpty(updateService))
-                    studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
-                if(!CollectionUtils.isEmpty(newService))
-                    studentExtracurricularExercisesSituationDao.batchInsert(newService);
+//                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
+
+//                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
+//                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
+
+//                Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
+//                for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
+//                    if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
+//                        continue;
+//                    }
+//                    studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
+//                }
+
+//                List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
+//                List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
+//                for (StudentExtracurricularExercisesSituation result : rows) {
+//                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){
+//                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
+//                        Set<Long> courseIds = new HashSet<>();
+//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
+//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
+//                        }
+//                        if(StringUtils.isNotBlank(result.getCourseIds())){
+//                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
+//                        }
+//                        s.setServeType(result.getServeType());
+//                        if(s.getServeType().equals("HOMEWORK")){
+//                            s.setCourseIds(StringUtils.join(courseIds, ","));
+//                        }else{
+//                            s.setCourseIds("");
+//                        }
+//                        if(StringUtils.isBlank(s.getCourseIds())){
+//                            s.setExpectExercisesNum(1);
+//                        }else{
+//                            s.setExpectExercisesNum(courseIds.size());
+//                        }
+//                        updateService.add(s);
+//                    }else{
+//                        newService.add(result);
+//                    }
+//                }
+//                if(!CollectionUtils.isEmpty(updateService))
+//                    studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
+//                if(!CollectionUtils.isEmpty(newService))
+//                    studentExtracurricularExercisesSituationDao.batchInsert(newService);
+
+                studentExtracurricularExercisesSituationDao.batchInsert(rows);
 
                 currentPage1=currentPage1.add(BigDecimal.ONE);
             }

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/StudentExtracurricularExercisesSituationMapper.xml

@@ -177,6 +177,12 @@
 	</delete>
 	<delete id="deleteByMonday">
 		DELETE FROM student_extracurricular_exercises_situation_ WHERE monday_ = #{monday}
+		<if test="studentIds!=null and studentIds.size()>0">
+			AND student_id_ IN
+			<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
+				#{studentId}
+			</foreach>
+		</if>
 	</delete>
 	<delete id="deleteByStudent">
 		DELETE FROM student_extracurricular_exercises_situation_ WHERE student_id_ = #{studentId}

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -719,7 +719,7 @@
     	select sr.*,s.name_ subject_name_,mg.status_ music_group_status_,mg.name_ music_group_name_,mgq.status_ music_group_quit_status_ 
     	from student_registration sr left join subject s on s.id_ = sr.actual_subject_id_
     	left join music_group mg on sr.music_group_id_ = mg.id_
-    	left join (select * from music_group_quit where id_ in (select max(id_) from music_group_quit group by music_group_id_)) mgq  on mgq.music_group_id_ = mg.id_
+    	left join music_group_quit mgq  on mgq.music_group_id_ = mg.id_ and mgq.join_date_ = sr.create_time_
     	where sr.user_id_ = #{userId}
     	order by sr.id_ 
     </select>

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/AdapayController.java

@@ -138,7 +138,7 @@ public class AdapayController extends BaseController {
         long createdLte = DateUtil.getLastSecondWithDay(endTime).getTime();
         int pageIndex = 1;
         List<Map<String, Object>> data = new ArrayList<>();
-        while (profiles.equals("dev")) {
+        while (profiles.equals("prod")) {
             Map<String, Object> paymentList = Payment.queryList(pageIndex, createdGte, createdLte);
             JSONArray payments = (JSONArray) paymentList.get("payments");
             if (!paymentList.get("status").equals("succeeded")) {