zouxuan 5 years ago
parent
commit
306c6eb46d

+ 19 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -16,6 +16,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
@@ -86,6 +87,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Autowired
 	private OrganizationDao organizationDao;
 	@Autowired
+	private StudentRegistrationDao studentRegistrationDao;
+	@Autowired
 	private SysMessageService sysMessageService;
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
@@ -188,7 +191,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 			musicGroupPaymentCalender.setPayUserType(STUDENT);
 			musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
-			musicGroupPaymentCalender.setExpectNum(1);
+			if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
+				musicGroupPaymentCalender.setExpectNum(1);
+			}
 		}
 		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 			if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
@@ -297,6 +302,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if(musicGroup == null){
 			throw new BizException("乐团查询失败,请检查参数");
 		}
+		//如果是进行中加学生,查看学员是否在团
+		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+			StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(musicGroupId, Integer.parseInt(musicGroupPaymentCalender.getStudentIds()));
+			if(studentRegistration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.QUIT){
+				throw new BizException("修改失败:学员已退团");
+			}
+		}
 		
 		Date date = new Date();
 		
@@ -374,6 +386,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}
 
 		}else {
+			if(musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT){
+				musicGroupPaymentCalender.setExpectNum(1);
+			}
             Set<Integer> roleIds = new HashSet<>(1);
             roleIds.add(SysUserRole.ADMINISTRATOR);
             Organization organization = organizationDao.get(musicGroup.getOrganId());
@@ -613,7 +628,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		musicGroupPaymentCalender.setAuditMemo(auditMemo);
 		musicGroupPaymentCalender.setUpdateTime(date);
-		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
+
 		//如果是报名,并且所有的报名都审核通过,需要修改乐团状态
 		if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
 			int count = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),calenderId);
@@ -633,9 +648,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getUsername());
 			}
 		}else if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+			musicGroupPaymentCalender.setExpectNum(1);
 			List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(calenderId);
 			addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettings);
 		}
+		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 	}
 
 	@Override

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

@@ -114,6 +114,7 @@
     </delete>
 
     <select id="queryByMusicGroupOrganizationCourseSettingsId" resultMap="MusicGroupOrganizationCourseSettingsDetail">
-        SELECT * FROM music_group_organization_course_settings_detail where music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId}
+        SELECT * FROM music_group_organization_course_settings_detail
+        where music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId}
     </select>
 </mapper>

+ 3 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -211,13 +211,12 @@
         SET expect_num_ = expect_num_ - 1
         WHERE id_ IN (SELECT music_group_payment_calender_id_ FROM music_group_payment_calender_detail
         WHERE user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT')
-        AND payment_type_ != 'ADD_STUDENT' AND expect_num_ > 0 AND music_group_id_ = #{musicGroupId}
+        AND expect_num_ > 0 AND music_group_id_ = #{musicGroupId}
     </update>
     <select id="findStudentNoPaymentCalender" resultType="java.lang.Long">
         SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
-        LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
-        WHERE mgpcd.user_id_ = #{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT'
-        AND mgpc.payment_type_ = 'ADD_STUDENT' AND mgpc.music_group_id_ = #{musicGroupId}
+        WHERE mgpc.student_ids_ = #{userId} AND mgpc.payment_type_ = 'ADD_STUDENT'
+        AND mgpc.music_group_id_ = #{musicGroupId} AND status_ = 'AUDITING'
     </select>
 
     <!-- 根据主键删除一条记录 -->