ソースを参照

财务管理增加 淘器微信的过滤

周箭河 4 年 前
コミット
f11f740014

+ 33 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -659,7 +659,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }*/
         Date date = new Date();
         String musicGroupId = studentRegistration.getMusicGroupId();
-        
+
         studentRegistration.setCreateTime(date);
         studentRegistration.setUpdateTime(date);
 
@@ -838,21 +838,21 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void insertStudent(String studentIds,String oldMusicGroupId,String newMusicGroupId,BigDecimal masterTotalPrice){
+    public void insertStudent(String studentIds, String oldMusicGroupId, String newMusicGroupId, BigDecimal masterTotalPrice) {
         SysUser sysUser1 = sysUserFeignService.queryUserInfo();
         //获取旧乐团学员注册信息
-        List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds,oldMusicGroupId);
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds, oldMusicGroupId);
         List<StudentCourseFeeDetail> studentCourseFeeDetails = new ArrayList<>();
         BigDecimal amount = BigDecimal.ZERO;
         for (StudentRegistration studentRegistration : studentRegistrations) {
             //记录课程余额消费日志
-            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
+            if (studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d) {
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
-                if(studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()){
+                if (studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()) {
                     amount = masterTotalPrice;
                     studentCourseFeeDetail.setAmount(masterTotalPrice.negate());
                     studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().subtract(masterTotalPrice));
-                }else {
+                } else {
                     amount = studentRegistration.getSurplusCourseFee();
                     studentCourseFeeDetail.setAmount(studentRegistration.getSurplusCourseFee().negate());
                     studentCourseFeeDetail.setSurplusCourseFee(BigDecimal.ZERO);
@@ -871,7 +871,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //修改剩余课程余额
                 registration.setSurplusCourseFee(registration.getSurplusCourseFee().add(amount));
                 studentRegistrationDao.update(registration);
-            }else {
+            } else {
                 //生成学员乐团注册表
                 studentRegistration.setOrganId(musicGroupDao.get(newMusicGroupId).getOrganId());
                 studentRegistration.setSurplusCourseFee(amount);
@@ -882,16 +882,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //增加报名学生数
                 musicGroupSubjectPlanService.addApplyStudentNum(newMusicGroupId, studentRegistration.getSubjectId(), 1);
                 //新增Fee表
-                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),newMusicGroupId);
-                if(musicGroupStudentFee == null){
+                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), newMusicGroupId);
+                if (musicGroupStudentFee == null) {
                     musicGroupStudentFee = new MusicGroupStudentFee(newMusicGroupId,
-                            studentRegistration.getUserId(), studentRegistration.getSubjectId(),BigDecimal.ZERO,
-                            null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus()==YES?PAID_COMPLETED:NON_PAYMENT);
+                            studentRegistration.getUserId(), studentRegistration.getSubjectId(), BigDecimal.ZERO,
+                            null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus() == YES ? PAID_COMPLETED : NON_PAYMENT);
                     musicGroupStudentFeeDao.insert(musicGroupStudentFee);
                 }
             }
             //主班新增余额日志
-            if(amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d){
+            if (amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d) {
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
                 studentCourseFeeDetail.setAmount(amount);
                 studentCourseFeeDetail.setSurplusCourseFee(registration.getSurplusCourseFee());
@@ -901,7 +901,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentCourseFeeDetails.add(studentCourseFeeDetail);
             }
         }
-        if(studentCourseFeeDetails.size() > 0){
+        if (studentCourseFeeDetails.size() > 0) {
             studentCourseFeeDetailDao.batchInsert(studentCourseFeeDetails);
         }
     }
@@ -1390,7 +1390,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional
     public StudentRegistration updateStudent(StudentRegistration studentRegistration) {
-        if(StringUtils.isBlank(studentRegistration.getCertificateType())){
+        if (StringUtils.isBlank(studentRegistration.getCertificateType())) {
             studentRegistration.setCertificateType(CertificateTypeEnum.IDENTITY.getCode());
         }
         StudentRegistration student = get(studentRegistration.getId());
@@ -1402,7 +1402,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         update(student);
         studentRegistrationDao.updateUser(student.getUserId(), student.getParentsName(), student.getIdCardNo(), studentRegistration.getCertificateType());
         // 添加用户电子签章账户
-        if(CertificateTypeEnum.IDENTITY.getCode().equals(studentRegistration.getCertificateType())){
+        if (CertificateTypeEnum.IDENTITY.getCode().equals(studentRegistration.getCertificateType())) {
             contractService.register(student.getUserId(), student.getParentsName(), student.getIdCardNo(), student.getParentsPhone());
         }
         return student;
@@ -1590,8 +1590,22 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         return amount;
     }
 
-	@Override
-	public List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId) {
-		return studentRegistrationDao.queryStudentMusicGroupInfo(userId);
-	}
+    @Override
+    public List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId) {
+        return studentRegistrationDao.queryStudentMusicGroupInfo(userId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean delReg(Long id) {
+        StudentRegistration studentRegistration = studentRegistrationDao.get(id);
+        MusicGroupSubjectPlan subjectPlan = musicGroupSubjectPlanDao.findSubjectPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
+        int delNum = studentRegistrationDao.delete(id);
+        subjectPlan.setApplyStudentNum(subjectPlan.getApplyStudentNum() - 1);
+        int updateNum = musicGroupSubjectPlanDao.update(subjectPlan);
+        if (delNum <= 0 || updateNum <= 0) {
+            throw new BizException("删除失败,请重试");
+        }
+        return true;
+    }
 }