zouxuan il y a 3 ans
Parent
commit
1af4de5b1e

+ 12 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1206,11 +1206,18 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
             //销售订单详情
             if (orderDetails.size() > 0) {
-                BigDecimal musicRemitFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
-                        || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
-                        .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
-                        .reduce(BigDecimal.ZERO, BigDecimal::add);
-                sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, musicGroup,musicRemitFee);
+                BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
+                if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+                    BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
+                            || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
+                            .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                    BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
+                    //获取比例
+                    BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                    //获取分配的减免金额
+                    couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, musicGroup,couponRemitFee);
             }
 
             //课程处理

+ 12 - 5
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -897,11 +897,18 @@ public class StudentOrderController extends BaseController {
         //销售订单详情
         if (orderDetails.size() > 0) {
             MusicGroup musicGroup = musicGroupService.get(order.getMusicGroupId());
-            BigDecimal musicRemitFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
-                    || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
-                    .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
-                    .reduce(BigDecimal.ZERO, BigDecimal::add);
-            sellOrders = sellOrderService.addOrderDetail2SellOrder(orderDetails, order, musicGroup,musicRemitFee);
+            BigDecimal couponRemitFee = order.getCouponRemitFee();
+            if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+                BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
+                        || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
+                        .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal expectAmount = order.getExpectAmount();
+                //获取比例
+                BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                //获取分配的减免金额
+                couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+            }
+            sellOrders = sellOrderService.addOrderDetail2SellOrder(orderDetails, order, musicGroup,couponRemitFee);
         }
         return succeed(sellOrders);