zouxuan 3 年 前
コミット
4e31f28f30

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

@@ -452,4 +452,6 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
     StudentPaymentOrderVo queryOrderDetail(@Param("orderNo") String orderNo);
 
+    //获取学员之前的乐团缴费订单数量
+    int getStudentMusicOrderNum(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId, @Param("orderId") Long orderId);
 }

+ 47 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -1647,6 +1647,21 @@ public class ExportServiceImpl implements ExportService {
         if(org.apache.commons.collections.CollectionUtils.isNotEmpty(outOrderList)){
             outOrderAmountMap = MapUtil.convertIntegerMap(sellOrderDao.sumOutOrderAmount(outOrderList));
         }
+        List<Long> otherOrderIds = studentPaymentOrderExportDtos.stream().filter(e -> e.getGroupType() != GroupType.GOODS_SELL
+                && e.getGroupType() != GroupType.REPLACEMENT
+                && e.getGroupType() != GroupType.PRACTICE
+                && e.getGroupType() != GroupType.SPORADIC
+                && e.getGroupType() != GroupType.MEMBER
+                && e.getGroupType() != GroupType.ACTIVITY
+                && e.getGroupType() != GroupType.VIP).map(e -> e.getId()).collect(Collectors.toList());
+        Map<Long, List<StudentPaymentOrderExportDto>> feeByTypeMap = new HashMap<>();
+        Map<Long, BigDecimal> childRepairMap = new HashMap<>();
+        if(!CollectionUtils.isEmpty(otherOrderIds)){
+            List<StudentPaymentOrderExportDto> feeByType = sellOrderDao.queryFeeByType(otherOrderIds);
+            feeByTypeMap = feeByType.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
+            childRepairMap = MapUtil.convertIntegerMap(sellOrderDao.queryChildRepair(otherOrderIds));
+        }
+
         for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
             if (row.getActualAmount() == null) {
                 row.setActualAmount(BigDecimal.ZERO);
@@ -1889,27 +1904,39 @@ public class ExportServiceImpl implements ExportService {
                     row.setTypeDesc(StudentPaymentOrderExportDto.TypeDesc.LARGE_MUSICAL);
                 }
             } else {
-                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
-                BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
-                row.setMusicalFee(feeByType.getMusicalFee());
-                row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
-                row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
-                row.setOtherFee(feeByType.getOtherFee());
-                if (row.getGroupType().equals(GroupType.MUSIC)) {
-                    StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
-                    if (studentRegistration != null) {
-                        row.setSubjectName(studentRegistration.getSubjectName());
-                        row.setSchoolName(studentRegistration.getSchoolName());
-                        row.setCooperationOrganName(studentRegistration.getRemark());
-                        row.setEduTeacher(studentRegistration.getName());
+                List<StudentPaymentOrderExportDto> exportDtoList = feeByTypeMap.get(row.getId());
+                if(!CollectionUtils.isEmpty(exportDtoList)){
+                    StudentPaymentOrderExportDto feeByType = exportDtoList.get(0);
+                    BigDecimal childRepairFee = childRepairMap.get(row.getId()) == null?BigDecimal.ZERO:childRepairMap.get(row.getId());
+//                    StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
+//                    BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
+                    row.setMusicalFee(feeByType.getMusicalFee());
+                    row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
+                    row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
+                    row.setOtherFee(feeByType.getOtherFee());
+                    if (row.getGroupType().equals(GroupType.MUSIC)) {
+                        if(row.getType() != OrderTypeEnum.APPLY && row.getType() != OrderTypeEnum.ADD_STUDENT){
+                            //判断之前是否有付费订单,如果没有,那么是乐团转化
+                            int orderNum = studentPaymentOrderDao.getStudentMusicOrderNum(row.getMusicGroupId(),row.getUserId(),row.getId());
+                            if(orderNum == 0){
+                                row.setTypeDesc(StudentPaymentOrderExportDto.TypeDesc.MUSIC_CONVERT);
+                            }
+                        }
+                        StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
+                        if (studentRegistration != null) {
+                            row.setSubjectName(studentRegistration.getSubjectName());
+                            row.setSchoolName(studentRegistration.getSchoolName());
+                            row.setCooperationOrganName(studentRegistration.getRemark());
+                            row.setEduTeacher(studentRegistration.getName());
+                        }
+                        row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()));
+                    } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
+                        row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
+                    } else if (row.getType().equals(OUTORDER)) {
+                        row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()));
+                        row.setTransferFee(BigDecimal.ZERO);
+                        row.setPlatformFee(BigDecimal.ZERO);
                     }
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()));
-                } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
-                    row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
-                } else if (row.getType().equals(OUTORDER)) {
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()));
-                    row.setTransferFee(BigDecimal.ZERO);
-                    row.setPlatformFee(BigDecimal.ZERO);
                 }
             }
             //如果合作单位不存在取学员的第一个乐团的合作单位,乐团主管

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

@@ -1056,6 +1056,10 @@
              student_payment_order_detail as b on a.id_ = b.payment_order_id_
         where order_no_ = #{orderNo}
     </select>
+    <select id="getStudentMusicOrderNum" resultType="int">
+        SELECT COUNT(0) FROM student_payment_order spo
+        WHERE spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId} AND group_type_ = 'MUSIC' AND status_ = 'SUCCESS' AND spo.id_ &lt; #{orderId}
+    </select>
 
 
 </mapper>