Prechádzať zdrojové kódy

update:学校缴费,学员删除

yonge 4 rokov pred
rodič
commit
5cf96e9aa3

+ 15 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -15,7 +15,6 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import com.ym.mec.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -32,7 +31,6 @@ import com.ym.mec.biz.dal.dto.FeeStudentDto;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
@@ -48,6 +46,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
+import com.ym.mec.util.collection.MapUtil;
 
 @Service
 public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderDetail>  implements MusicGroupPaymentCalenderDetailService {
@@ -501,10 +500,20 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if(details == null || details.size() == 0){
 			throw new BizException("删除失败: 数据不可为空");
 		}
-		//是否已缴费
-		long count = details.stream().filter(e -> e.getPaymentStatus() != NON_PAYMENT).count();
-		if(count > 0){
-			throw new BizException("删除失败: 存在已缴费的学员");
+		Long musicGroupPaymentCalenderId = details.get(0).getMusicGroupPaymentCalenderId();
+		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
+		
+		if(musicGroupPaymentCalender == null){
+			throw new BizException("查询缴费项目失败[{}]", musicGroupPaymentCalender);
+		}
+		
+		long count = 0;
+		if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
+			// 是否已缴费
+			count = details.stream().filter(e -> e.getPaymentStatus() != NON_PAYMENT).count();
+			if (count > 0) {
+				throw new BizException("删除失败: 存在已缴费的学员");
+			}
 		}
 		List<Long> musicGroupPaymentCalenderDetailIdList = new ArrayList<Long>();
 		for(String s : musicGroupPaymentCalenderDetailIds.split(",")){
@@ -517,12 +526,6 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			throw new BizException("删除失败:存在已排课的学员");
 		}
 		
-		Long musicGroupPaymentCalenderId = details.get(0).getMusicGroupPaymentCalenderId();
-		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
-		
-		if(musicGroupPaymentCalender == null){
-			throw new BizException("查询缴费项目失败[{}]", musicGroupPaymentCalender);
-		}
 		int currentNum = musicGroupPaymentCalender.getExpectNum() - details.size();
 		musicGroupPaymentCalender.setExpectNum(currentNum < 0 ? 0 : currentNum);
 		musicGroupPaymentCalender.setUpdateTime(new Date());