فهرست منبع

feat:12月活动

Joburgess 4 سال پیش
والد
کامیت
b97a83b37d

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -309,5 +309,5 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      * @param operatorId:
      * @return boolean
      */
-    boolean updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId);
+    BigDecimal updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId);
 }

+ 2 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -682,11 +682,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			List<CourseScheduleStudentPaymentDto> notStartCourses = statusCoursesMap.get(CourseStatusEnum.OVER);
 			notStartCourses.sort(Comparator.comparing(CourseScheduleStudentPaymentDto::getCourseStartTime));
 			for (CourseScheduleStudentPaymentDto notStartCourse : notStartCourses) {
-				boolean isUpdate = studentRegistrationService.updateUserSurplusCourseFee(notStartCourse.getUserId(), notStartCourse.getMusicGroupId(), notStartCourse.getExpectPrice().negate(), StringUtils.join("课程结束,扣除课程费用:", notStartCourse.getCourseScheduleId()), null);
-				if(!isUpdate){
-					continue;
-				}
-				notStartCourse.setActualPrice(notStartCourse.getExpectPrice());
+				BigDecimal deductAmount = studentRegistrationService.updateUserSurplusCourseFee(notStartCourse.getUserId(), notStartCourse.getMusicGroupId(), notStartCourse.getExpectPrice().negate(), StringUtils.join("课程结束,扣除课程费用:", notStartCourse.getCourseScheduleId()), null);
+				notStartCourse.setActualPrice(deductAmount.abs());
 				needUpdates.add(notStartCourse);
 			}
 		}

+ 11 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1433,22 +1433,26 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public boolean updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId) {
+    public BigDecimal updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId) {
         StudentRegistration studentRegistration = studentRegistrationDao.lockWithUserAndMusic(userId, musicGroupId);
         if(Objects.isNull(studentRegistration)){
             throw new BizException("学员注册信息不存在");
         }
 
         if(BigDecimal.ZERO.compareTo(amount)==0){
-            return true;
+            return BigDecimal.ZERO;
         }
 
-        studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(amount));
-
-        if(BigDecimal.ZERO.compareTo(studentRegistration.getSurplusCourseFee())>0){
-            return false;
+        if(amount.abs().compareTo(studentRegistration.getSurplusCourseFee())>0){
+            if(BigDecimal.ZERO.compareTo(amount)>0){
+                amount = studentRegistration.getSurplusCourseFee().negate();
+            }else{
+                amount = studentRegistration.getSurplusCourseFee();
+            }
         }
 
+        studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(amount));
+
         StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
         studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
         studentCourseFeeDetail.setAmount(amount);
@@ -1458,6 +1462,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
 
         studentRegistrationDao.update(studentRegistration);
-        return true;
+        return amount;
     }
 }