Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
6ca96c1319

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -145,4 +145,6 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      */
     BigDecimal sumGroupIncomeFee(@Param("musicGroupId") String musicGroupId,
                                  @Param("groupType") String groupType);
+
+    List<StudentPaymentOrder> findStudentPaymentOrder(@Param("groupType") String groupType,@Param("musicGroupId") String musicGroupId);
 }

+ 6 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -285,7 +285,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 for (StudentRegistration studentRegistration : musicGroupStudentRegistrationList) {
                     studentRegistration.setId(null);
                     studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
-                    studentRegistration.setPaymentStatus(PaymentStatusEnum.NO);
+                    studentRegistration.setPaymentStatus(PaymentStatusEnum.OPEN);
                     studentRegistration.setMusicGroupId(musicGroupId);
                     studentRegistration.setSubjectId(e.getSubjectId());
                     studentRegistration.setActualSubjectId(e.getSubjectId());
@@ -308,7 +308,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     if (studentRegistrationList.size() > 0) {
                         //修改为已缴费
                         studentRegistrationList.forEach(e->e.setPaymentStatus(PaymentStatusEnum.YES));
-                        studentRegistrationDao.batchInsert(studentRegistrationList);
                     }
                 }
             }
@@ -316,6 +315,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 studentRegistrationDao.batchInsert(studentRegistrationList);
             }
             musicGroupDao.update(musicGroup);
+            List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
+            if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
+                Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId);
+                musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate);
+            }
             musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "跨团调整", sysUser.getId(),""));
         }
 

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherServiceImpl.java

@@ -48,6 +48,8 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher>  imple
 	@Autowired
 	private SysUserCashAccountDao sysUserCashAccountDao;
 	@Autowired
+	private StudentPaymentOrderDao studentPaymentOrderDao;
+	@Autowired
 	private SysUserFeignService sysUserFeignService;
 	@Autowired
 	private ImFeignService imFeignService;
@@ -308,6 +310,18 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher>  imple
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());
 			dataList = teacherDao.queryMusicGroupStudentApply(params);
+			String paymentStatus = queryInfo.getPaymentStatus();
+			if(StringUtils.isNotEmpty(paymentStatus) && paymentStatus.equals("2")){
+				List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.findStudentPaymentOrder("MUSIC",queryInfo.getMusicGroupId());
+				Map<Integer, List<StudentPaymentOrder>> collect = studentPaymentOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getUserId));
+				dataList.forEach(e->{
+					List<StudentPaymentOrder> paymentOrders = collect.get(e.getUserId());
+					if(paymentOrders != null && paymentOrders.size() > 0){
+						e.setPaymentAmount(paymentOrders.get(0).getActualAmount());
+						e.setPayTime(paymentOrders.get(0).getPayTime());
+					}
+				});
+			}
 		}
 		if (count == 0) {
 			dataList = new ArrayList<>();

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

@@ -165,7 +165,7 @@
 
     <select id="initMusicGroupStudentFee" resultMap="MusicGroupStudentFee">
         SELECT sr.music_group_id_,sr.user_id_,sr.actual_subject_id_ subject_id_ FROM student_registration sr
-        LEFT JOIN music_group_student_fee_ mgsf ON sr.user_id_ = mgsf.user_id_
+        LEFT JOIN music_group_student_fee_ mgsf ON sr.user_id_ = mgsf.user_id_ AND sr.music_group_id_ = mgsf.music_group_id_
         WHERE sr.music_group_status_ != 'QUIT' AND sr.payment_status_ = 2 AND mgsf.id_ IS NULL AND sr.music_group_id_ = #{musicGroupId}
     </select>
 

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -318,5 +318,10 @@
             group_type_ = #{groupType}
             AND music_group_id_ = #{musicGroupId}
     </select>
+    <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
+        SELECT * FROM student_payment_order WHERE id_ IN (SELECT MAX(sp.id_) FROM (SELECT * FROM student_payment_order
+        WHERE group_type_ = #{groupType} AND type_ = 'APPLY' AND music_group_id_ = #{musicGroupId} AND status_ = 'SUCCESS'
+        ORDER BY id_ DESC) sp GROUP BY sp.user_id_)
+    </select>
 
 </mapper>

+ 2 - 4
mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -446,17 +446,16 @@
     </resultMap>
     <select id="queryMusicGroupStudentApply" resultMap="musicGroupStudentApplyDto">
         SELECT sr.user_id_,su.username_,sr.current_class_,sr.current_grade_,s.name_ subject_name_,sr.remark_,
-        spo.actual_amount_,spo.pay_time_,sr.payment_status_,sr.actual_subject_id_
+        sr.payment_status_,sr.actual_subject_id_
         FROM student_registration sr
         LEFT JOIN sys_user su ON sr.user_id_ = su.id_
         LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
-        LEFT JOIN student_payment_order spo ON spo.user_id_ = sr.user_id_ AND spo.music_group_id_ = sr.music_group_id_
         <include refid="queryMusicGroupStudentApplySql"/>
         <include refid="global.limit"/>
     </select>
     <sql id="queryMusicGroupStudentApplySql">
         <where>
-            sr.music_group_id_ = #{musicGroupId} AND (spo.type_ = 'APPLY' OR spo.type_ IS NULL) AND sr.music_group_status_ != 'QUIT'
+            sr.music_group_id_ = #{musicGroupId} AND sr.music_group_status_ != 'QUIT'
             <if test="subjectId != null">
                 AND sr.actual_subject_id_ = #{subjectId}
             </if>
@@ -470,7 +469,6 @@
         FROM student_registration sr
         LEFT JOIN sys_user su ON sr.user_id_ = su.id_
         LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
-        LEFT JOIN student_payment_order spo ON spo.user_id_ = sr.user_id_ AND spo.music_group_id_ = sr.music_group_id_
         <include refid="queryMusicGroupStudentApplySql"/>
     </select>