Browse Source

Merge branch 'practice_1129' of http://git.dayaedu.com/yonge/mec into practice_1129

yonge 3 years ago
parent
commit
f8cf3f2727

+ 23 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -2870,7 +2870,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 */
         Date now = new Date();
 
-        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId(),"2021-03-09 00:00:00");
+//        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId(),"2021-03-09 00:00:00");
 
         LocalDate courseStartDay = LocalDate.now();
         LocalDate tempCourseLocalDate = LocalDate.parse("2020-03-01", DateUtil.dateFormatter);
@@ -3096,13 +3096,18 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if(teacherDefaultSalary == null){
         	throw new BizException("请设置教师课酬");
         }
-        BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
+//        BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
 
-        BigDecimal oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
-        BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
-        BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
+//        BigDecimal oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
+//        BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
+//        BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
 
-        for (CourseSchedule courseSchedule : practiceCourses) {
+        //实际支付金额,去除优惠券
+        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());
@@ -3122,8 +3127,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
             courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
-            courseScheduleStudentPayment.setExpectPrice(oneMonthPrice);
-            courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
+            if(i == 0){
+                courseScheduleStudentPayment.setExpectPrice(firstAmount);
+                courseScheduleStudentPayment.setActualPrice(firstAmount);
+            }else {
+                courseScheduleStudentPayment.setExpectPrice(divide);
+                courseScheduleStudentPayment.setActualPrice(divide);
+            }
+//            courseScheduleStudentPayment.setExpectPrice(oneMonthPrice);
+//            courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
             courseScheduleStudentPayment.setOriginalPrice(oneMonthPrice);
             courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
             courseScheduleStudentPayment.setCreateTime(now);
@@ -3169,12 +3181,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 throw new BizException("用户账户找不到");
             }
             studentPaymentOrder.setPaymentChannel("BALANCE");
-            if (userCashAccount.getBalance().subtract(studentPaymentOrder.getExpectAmount().subtract(studentPaymentOrder.getCouponRemitFee())).doubleValue() >= 0) {
+            if (userCashAccount.getBalance().subtract(studentPaymentOrder.getExpectAmount()).doubleValue() >= 0) {
                 studentPaymentRouteOrderService.addRouteOrder(orderNo, practiceGroupBuyParams.getOrganId(), amount);
 
                 // 更新订单信息
                 studentPaymentOrder.setActualAmount(new BigDecimal(0));
-                studentPaymentOrder.setBalancePaymentAmount(studentPaymentOrder.getExpectAmount().subtract(studentPaymentOrder.getCouponRemitFee()));
+                studentPaymentOrder.setBalancePaymentAmount(studentPaymentOrder.getExpectAmount());
                 studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
                 studentPaymentOrder.setUpdateTime(now);
                 studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
@@ -3193,7 +3205,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 if (userCashAccount.getBalance().doubleValue() > 0) {
                     balance = userCashAccount.getBalance();
                     sysUserCashAccountService.updateBalance(practiceGroupBuyParams.getStudentId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "网管课购买");
-                    amount = studentPaymentOrder.getExpectAmount().subtract(userCashAccount.getBalance()).subtract(studentPaymentOrder.getCouponRemitFee());
+                    amount = studentPaymentOrder.getExpectAmount().subtract(userCashAccount.getBalance());
                     studentPaymentOrder.setActualAmount(amount);
                     studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
                 } else {

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

@@ -164,7 +164,6 @@ public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCod
 	@Transactional(rollbackFor = Exception.class)
     public StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount,Boolean useFlag) {
 		StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-		studentPaymentOrder.setExpectAmount(amount);
 		if(couponIdList != null && couponIdList.size() > 0){
 			Date date = new Date();
 			List<SysCouponCodeDto> couponCodeDtoList = sysCouponCodeDao.findByIdList(couponIdList);
@@ -210,6 +209,7 @@ public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCod
 			studentPaymentOrder.setCouponCodeId(StringUtils.join(couponIdList,","));
 			studentPaymentOrder.setCouponRemitFee(faceAmount);
 		}
+		studentPaymentOrder.setExpectAmount(amount);
 		studentPaymentOrder.setActualAmount(amount);
 		return studentPaymentOrder;
     }