Jelajahi Sumber

原有的业务逻辑不支持同一笔订单明细分润导多个账户,所以这里先比较金额大小,如果有更复杂的分润情况出现,这里无法满足

zouxuan 1 tahun lalu
induk
melakukan
e51b5b4ba8

+ 23 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -3214,7 +3214,9 @@ public class ExportServiceImpl implements ExportService {
 
     public @PostConstruct
     void initOrderDetailTypeServiceConsumerMap() {
-        BiConsumer<StudentPaymentOrderExportDto, StudentPaymentOrderDetail> con1 = (orderDto, detail) -> orderDto.setMusicGroupCourseFee(orderDto.getMusicGroupCourseFee().add(detail.getPrice()));
+        BiConsumer<StudentPaymentOrderExportDto, StudentPaymentOrderDetail> con1 =
+                (orderDto, detail) -> orderDto.setMusicGroupCourseFee(orderDto.getMusicGroupCourseFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getMusicGroupCourseFee().add(detail.getPrice()));
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.COURSE, con1);
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.CLASSROOM, con1);
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.SINGLE, con1);
@@ -3227,17 +3229,30 @@ public class ExportServiceImpl implements ExportService {
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.HIGH, con1);
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.HIGH_ONLINE, con1);
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.HIGH_ONLINE_COURSE, con1);
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.DEGREE_REGISTRATION, (orderDto, detail) -> orderDto.setDegreeFee(orderDto.getDegreeFee().add(detail.getPrice())));
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.MAINTENANCE, (orderDto, detail) -> orderDto.setMaintenanceFee(orderDto.getMaintenanceFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.DEGREE_REGISTRATION,
+                (orderDto, detail) -> orderDto.setDegreeFee(orderDto.getDegreeFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getDegreeFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.MAINTENANCE,
+                (orderDto, detail) -> orderDto.setMaintenanceFee(orderDto.getMaintenanceFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getMaintenanceFee().add(detail.getPrice())));
         //原有的业务逻辑不支持同一笔订单明细分润导多个账户,所以这里先比较金额大小,会有bug
         BiConsumer<StudentPaymentOrderExportDto, StudentPaymentOrderDetail> con2 =
-                (orderDto, detail) -> orderDto.setCloudTeacherFee(orderDto.getCloudTeacherFee().add(detail.getPrice()).compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getCloudTeacherFee().add(detail.getPrice()));
+                (orderDto, detail) -> orderDto.setCloudTeacherFee(orderDto.getCloudTeacherFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getCloudTeacherFee().add(detail.getPrice()));
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.CLOUD_TEACHER, con2);
         orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS, con2);
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.THEORY_COURSE, (orderDto, detail) -> orderDto.setTheoryCourseFee(orderDto.getTheoryCourseFee().add(detail.getPrice())));
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.PRACTICE, (orderDto, detail) -> orderDto.setPracticeCourseFee(orderDto.getPracticeCourseFee().add(detail.getPrice())));
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.VIP, (orderDto, detail) -> orderDto.setVipCourseFee(orderDto.getVipCourseFee().add(detail.getPrice())));
-        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.REPAIR, (orderDto, detail) -> orderDto.setRepairFee(orderDto.getRepairFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.THEORY_COURSE,
+                (orderDto, detail) -> orderDto.setTheoryCourseFee(orderDto.getTheoryCourseFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getTheoryCourseFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.PRACTICE,
+                (orderDto, detail) -> orderDto.setPracticeCourseFee(orderDto.getPracticeCourseFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getPracticeCourseFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.VIP,
+                (orderDto, detail) -> orderDto.setVipCourseFee(orderDto.getVipCourseFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getVipCourseFee().add(detail.getPrice())));
+        orderDetailTypeServiceConsumerMap.put(OrderDetailTypeEnum.REPAIR,
+                (orderDto, detail) -> orderDto.setRepairFee(orderDto.getRepairFee().add(detail.getPrice())
+                        .compareTo(orderDto.getServiceAmount()) > 0 ? orderDto.getServiceAmount() : orderDto.getRepairFee().add(detail.getPrice())));
     }
 
     //计算订单详情实际支付金额(按比例)