yonge 3 anni fa
parent
commit
14215a83a2

+ 21 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
+import static java.math.BigDecimal.ROUND_DOWN;
+
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -725,9 +727,18 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         if(teacherDefaultSalary == null){
             throw new BizException("请设置老师课酬");
         }
-        BigDecimal studentSingleCourseCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        BigDecimal studentSingleCourseOriginalCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        for (CourseSchedule courseSchedule : practiceCourses) {
+        
+        BigDecimal studentSingleCourseOriginalCost = price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+
+        //使用优惠券
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), price, true);
+        //实际支付金额,去除优惠券
+        BigDecimal actualPrice = studentPaymentOrder.getExpectAmount();
+        BigDecimal divide = actualPrice.divide(new BigDecimal(practiceCourses.size()), ROUND_DOWN);
+        BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(practiceCourses.size()))).add(divide);
+        
+        for (int i = 0; i < practiceCourses.size(); i++) {
+            CourseSchedule courseSchedule = practiceCourses.get(i);
             //课程与老师薪水表
             CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
             courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
@@ -747,8 +758,13 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
             courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
-            courseScheduleStudentPayment.setExpectPrice(studentSingleCourseCost);
-            courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
+            if(i == 0){
+                courseScheduleStudentPayment.setExpectPrice(firstAmount);
+                courseScheduleStudentPayment.setActualPrice(firstAmount);
+            }else {
+                courseScheduleStudentPayment.setExpectPrice(divide);
+                courseScheduleStudentPayment.setActualPrice(divide);
+            }
             courseScheduleStudentPayment.setOriginalPrice(studentSingleCourseOriginalCost);
             courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
             courseScheduleStudentPayment.setCreateTime(now);
@@ -787,7 +803,6 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
             return BaseController.failed(HttpStatus.FOUND, errMessage);
         }
 
-        StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
         studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
         studentPaymentOrder.setGroupType(GroupType.PRACTICE);
         String orderNo=idGeneratorService.generatorId("payment") + "";

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -3573,7 +3573,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
-            courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());if(i == 0){
+            courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
+            if(i == 0){
                 courseScheduleStudentPayment.setExpectPrice(firstAmount);
                 courseScheduleStudentPayment.setActualPrice(firstAmount);
             }else {

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/education/EduPracticeGroupController.java

@@ -193,7 +193,7 @@ public class EduPracticeGroupController extends BaseController {
         if(Objects.isNull(practiceGroupBuyParams.getType())||PracticeGroupType.CHARGE.equals(practiceGroupBuyParams.getType())){
             return practiceGroupService.buyPracticeGroup(practiceGroupBuyParams, sysUser.getRealName()+"("+sysUser.getId()+")");
         }else{
-            return practiceGroupService.createPackagePracticeGroup(practiceGroupBuyParams, sysUser.getRealName()+"("+sysUser.getId()+")");
+            return eduPracticeGroupService.createPackagePracticeGroup(practiceGroupBuyParams, sysUser.getRealName()+"("+sysUser.getId()+")");
         }
     }