zouxuan 2 years ago
parent
commit
8057e795b0

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.page.ArrearageStudentsQueryInfo;
@@ -71,6 +72,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
     private VipGroupActivityDao vipGroupActivityDao;
     @Autowired
     private OperatingReportCloudService operatingReportCloudService;
+    @Autowired
+    private MemberFeeSettingService memberFeeSettingService;
 
     @Override
     public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
@@ -242,6 +245,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
             musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
             musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
             musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
+            musicGroupPaymentCalenderDetail.setCourseIncome(this.getCourseIncome(calenderMember,musicGroup));
             musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
             if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0 || musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
                 // 添加会员
@@ -313,6 +317,18 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
         }
     }
 
+    private BigDecimal getCourseIncome(MusicGroupPaymentCalenderMember calenderMember,MusicGroup musicGroup){
+        if(Objects.nonNull(calenderMember) && musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+            //获取云教练溢出费用
+            BigDecimal courseIncome = memberFeeSettingService.getAmount(musicGroup.getOrganId(), 1, calenderMember.getPeriod(),
+                    calenderMember.getNum(), MemberFeeSettingServiceImpl::getIncome);
+            if(calenderMember.getActualAmount().compareTo(courseIncome) > 0){
+                return calenderMember.getActualAmount().subtract(courseIncome);
+            }
+        }
+        return BigDecimal.ZERO;
+    }
+
     @Override
     public List<FeeStudentDto> queryFeeStudents(String musicGroupId, String search, Integer subjectId) {
         return musicGroupStudentFeeDao.queryFeeStudents(musicGroupId, search, subjectId);