Browse Source

feat:乐团费用改造

Joburgess 5 years ago
parent
commit
8556f8ad42

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -128,4 +128,13 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
     List<CalenderPushDto> getCalenderPushDto(@Param("calenderIds") Collection<Long> calenderIds);
     List<CalenderPushDto> getCalenderPushDto(@Param("calenderIds") Collection<Long> calenderIds);
 
 
     List<CalenderPushDto> getMusicCalenderPushDto(@Param("configValue") String configValue, @Param("format") String format);
     List<CalenderPushDto> getMusicCalenderPushDto(@Param("configValue") String configValue, @Param("format") String format);
-}
+
+    /**
+     * @describe 获取乐团下未使用的最早的缴费记录
+     * @author Joburgess
+     * @date 2020.10.27
+     * @param musicGroupId:
+     * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender
+     */
+    MusicGroupPaymentCalender getMusicGroupUnusedFirstPaymentCalender(@Param("musicGroupId") String musicGroupId);
+}

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -135,4 +135,13 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return
 	 * @return
 	 */
 	 */
     Integer countOpenPayment(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
     Integer countOpenPayment(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
-}
+
+    /**
+     * @describe 获取指定缴费日历的详情
+     * @author Joburgess
+     * @date 2020.10.27
+     * @param calenderId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail>
+     */
+    List<MusicGroupPaymentCalenderDetail> getCalenderDetailWithCalender(@Param("calenderId") Long calenderId);
+}

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -34,6 +34,10 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 	@Autowired
 	@Autowired
 	private SysUserCashAccountService sysUserCashAccountService;
 	private SysUserCashAccountService sysUserCashAccountService;
+	@Autowired
+	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
+	@Autowired
+	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 
 
 	@Override
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -267,6 +271,26 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 
 	@Override
 	@Override
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
+		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId);
+		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
+			throw new BizException("当前乐团无未使用缴费记录");
+		}
+
+		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalender = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(unusedPaymentCalender)){
+			throw new BizException("当前乐团无学员缴费信息");
+		}
+		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalender.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
+		for (Integer studentId : studentIds) {
+			List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetails = studentPaymentCalenderMap.get(studentId);
+			if(CollectionUtils.isEmpty(musicGroupPaymentCalenderDetails)){
+				throw new BizException("部分学员无缴费信息");
+			}
+			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = musicGroupPaymentCalenderDetails.stream().min(Comparator.comparing(MusicGroupPaymentCalenderDetail::getCreateTime)).get();
+			if(!musicGroupPaymentCalenderDetail.getMusicGroupPaymentCalenderId().equals(musicGroupUnusedFirstPaymentCalender.getId())){
+				throw new BizException("缴费信息异常");
+			}
 
 
+		}
 	}
 	}
 }
 }

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -300,4 +300,12 @@
 		WHERE mgpcd.user_id_ = #{userId} AND mgpc.music_group_id_ = #{musicGroupId} AND (mgpc.payment_status_ = 1 OR mgpcd.open_ = 1)
 		WHERE mgpcd.user_id_ = #{userId} AND mgpc.music_group_id_ = #{musicGroupId} AND (mgpc.payment_status_ = 1 OR mgpcd.open_ = 1)
 		AND mgpcd.payment_status_ != 'PAID_COMPLETED'
 		AND mgpcd.payment_status_ != 'PAID_COMPLETED'
 	</select>
 	</select>
+	<select id="getCalenderDetailWithCalender" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT
+			mgpcd.*
+		FROM
+			music_group_payment_calender_detail mgpcd
+		WHERE
+			mgpc.music_group_payment_calender_id_ = #{calenderId}
+	</select>
 </mapper>
 </mapper>

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

@@ -280,4 +280,10 @@
         WHERE mg.payment_valid_end_date_ IS NOT NULL AND
         WHERE mg.payment_valid_end_date_ IS NOT NULL AND
         DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
         DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
     </select>
     </select>
+    <select id="getMusicGroupUnusedFirstPaymentCalender" resultMap="MusicGroupPaymentCalender">
+        SELECT * FROM music_group_payment_calender mgpc
+        WHERE music_group_id_=#{musicGroupId}
+        AND NOT EXISTS ( SELECT id_ FROM course_schedule WHERE batch_no_ = mgpc.id_ AND music_group_id_ = #{musicGroupId} )
+        ORDER BY create_time_ LIMIT 1;
+    </select>
 </mapper>
 </mapper>