Commit 32e5b9d54e324c9697ea402faac92db88583fb3e
1 parent
6865caeb
refactor(order): 优化订单利润计算精度
- 将包装实际人民币总价、包装利润人民币价等字段的精度统一设置为2位
Showing
1 changed file
with
11 additions
and
10 deletions
src/main/java/com/order/erp/service/order/impl/ProjectBaseInfoServiceImpl.java
... | ... | @@ -632,7 +632,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
632 | 632 | .filter(Objects::nonNull) |
633 | 633 | .reduce(BigDecimal::add) |
634 | 634 | .ifPresent(packetActualRmbTotalPrice -> { |
635 | - businessProfitInfoVO.setPacketActualRmbTotalPrice(packetActualRmbTotalPrice.setScale(4, RoundingMode.HALF_UP)); | |
635 | + businessProfitInfoVO.setPacketActualRmbTotalPrice(packetActualRmbTotalPrice.setScale(2, RoundingMode.HALF_UP)); | |
636 | 636 | }); |
637 | 637 | //订单数 |
638 | 638 | details.stream() |
... | ... | @@ -651,7 +651,8 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
651 | 651 | if (Objects.nonNull(businessProfitInfoVO.getPacketActualRmbTotalPrice()) |
652 | 652 | && Objects.nonNull(businessProfitInfoVO.getPacketRmbTotalPrice())) { |
653 | 653 | //包装费用收益¥ |
654 | - businessProfitInfoVO.setPacketProfitRmbPrice(BigDecimal.valueOf(businessProfitInfoVO.getPacketRmbTotalPrice()).subtract(businessProfitInfoVO.getPacketActualRmbTotalPrice())); | |
654 | + businessProfitInfoVO.setPacketProfitRmbPrice(BigDecimal.valueOf(businessProfitInfoVO.getPacketRmbTotalPrice()) | |
655 | + .subtract(businessProfitInfoVO.getPacketActualRmbTotalPrice()).setScale(2, RoundingMode.HALF_UP)); | |
655 | 656 | } |
656 | 657 | |
657 | 658 | //hod时间差 |
... | ... | @@ -709,27 +710,27 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
709 | 710 | } |
710 | 711 | } |
711 | 712 | //固定成本 |
712 | - businessProfitInfoVO.setFixedCost(BigDecimal.valueOf((between+1) * Double.parseDouble(fixCostValue))); | |
713 | + businessProfitInfoVO.setFixedCost(BigDecimal.valueOf((between+1) * Double.parseDouble(fixCostValue)).setScale(2, RoundingMode.HALF_UP)); | |
713 | 714 | if (Objects.nonNull(spainRatio) |
714 | 715 | && Objects.nonNull(businessProfitInfoVO.getCustomerRmbTotalPrice())) { |
715 | 716 | //西班牙提成 |
716 | - businessProfitInfoVO.setSpainRmbCommission(BigDecimal.valueOf(businessProfitInfoVO.getCustomerRmbTotalPrice()).multiply(BigDecimal.valueOf(Double.parseDouble(spainRatio)))); | |
717 | + businessProfitInfoVO.setSpainRmbCommission(BigDecimal.valueOf(businessProfitInfoVO.getCustomerRmbTotalPrice()).multiply(BigDecimal.valueOf(Double.parseDouble(spainRatio))).setScale(2, RoundingMode.HALF_UP)); | |
717 | 718 | } |
718 | 719 | if (Objects.nonNull(businessProfitInfoVO.getSpainRmbCommission()) |
719 | 720 | && Objects.nonNull(projectBaseInfoDO.getSpainPaidRmbCommission())) { |
720 | 721 | //西班牙未发提成 |
721 | - businessProfitInfoVO.setSpainUnpaidRmbCommission(businessProfitInfoVO.getSpainRmbCommission().subtract(projectBaseInfoDO.getSpainPaidRmbCommission())); | |
722 | + businessProfitInfoVO.setSpainUnpaidRmbCommission(businessProfitInfoVO.getSpainRmbCommission().subtract(projectBaseInfoDO.getSpainPaidRmbCommission()).setScale(2, RoundingMode.HALF_UP)); | |
722 | 723 | } |
723 | 724 | |
724 | 725 | if (Objects.nonNull(ratio) |
725 | 726 | && Objects.nonNull(businessProfitInfoVO.getCustomerRmbTotalPrice())) { |
726 | 727 | //中国团队提成 |
727 | - businessProfitInfoVO.setRmbCommission(BigDecimal.valueOf(businessProfitInfoVO.getCustomerRmbTotalPrice()).multiply(BigDecimal.valueOf(Double.parseDouble(ratio)))); | |
728 | + businessProfitInfoVO.setRmbCommission(BigDecimal.valueOf(businessProfitInfoVO.getCustomerRmbTotalPrice()).multiply(BigDecimal.valueOf(Double.parseDouble(ratio))).setScale(2, RoundingMode.HALF_UP)); | |
728 | 729 | } |
729 | 730 | if (Objects.nonNull(businessProfitInfoVO.getRmbCommission()) |
730 | 731 | && Objects.nonNull(projectBaseInfoDO.getPaidRmbCommission())) { |
731 | 732 | //未发提成 |
732 | - businessProfitInfoVO.setUnpaidRmbCommission(businessProfitInfoVO.getRmbCommission().subtract(projectBaseInfoDO.getPaidRmbCommission())); | |
733 | + businessProfitInfoVO.setUnpaidRmbCommission(businessProfitInfoVO.getRmbCommission().subtract(projectBaseInfoDO.getPaidRmbCommission()).setScale(2, RoundingMode.HALF_UP)); | |
733 | 734 | } |
734 | 735 | } |
735 | 736 | if (Objects.nonNull(businessProfitInfoVO.getActualExchangeRate()) |
... | ... | @@ -744,7 +745,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
744 | 745 | .add(Optional.ofNullable(businessProfitInfoVO.getFixedCost()).orElse(BigDecimal.ZERO)) |
745 | 746 | .add(Optional.ofNullable(businessProfitInfoVO.getDevelopmentCopyRmbTotalPrice()).orElse(BigDecimal.ZERO)) |
746 | 747 | .add(BigDecimal.valueOf(Optional.ofNullable(businessProfitInfoVO.getPacketRmbTotalPrice()).orElse(0.0))) |
747 | - .add(BigDecimal.valueOf(Optional.ofNullable(businessProfitInfoVO.getProductionDepartmentTotalPrice()).orElse(0.0)))); | |
748 | + .add(BigDecimal.valueOf(Optional.ofNullable(businessProfitInfoVO.getProductionDepartmentTotalPrice()).orElse(0.0))).setScale(2, RoundingMode.HALF_UP)); | |
748 | 749 | if (Objects.nonNull(businessProfitInfoVO.getCustomerRmbTotalPrice()) |
749 | 750 | && Objects.nonNull(businessProfitInfoVO.getProductionDepartmentTotalPrice()) |
750 | 751 | && Objects.nonNull(businessProfitInfoVO.getPacketRmbTotalPrice())) { |
... | ... | @@ -763,7 +764,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
763 | 764 | && Objects.nonNull(businessProfitInfoVO.getRmbTotalExpense())) { |
764 | 765 | //研发贸易净利润 |
765 | 766 | businessProfitInfoVO.setDevelopmentProfit(BigDecimal.valueOf(businessProfitInfoVO.getCustomerRmbTotalPrice()) |
766 | - .subtract(businessProfitInfoVO.getRmbTotalExpense()) | |
767 | + .subtract(businessProfitInfoVO.getRmbTotalExpense().setScale(2, RoundingMode.HALF_UP)) | |
767 | 768 | ); |
768 | 769 | //研发贸易净利润率 |
769 | 770 | businessProfitInfoVO.setDevelopmentProfitRate(businessProfitInfoVO.getDevelopmentProfit() |
... | ... | @@ -772,7 +773,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
772 | 773 | //综合收益 |
773 | 774 | businessProfitInfoVO.setComprehensiveProfit(Optional.ofNullable(businessProfitInfoVO.getDevelopmentProfit()).orElse(BigDecimal.ZERO) |
774 | 775 | .add(Optional.ofNullable(businessProfitInfoVO.getExchangeRateProfit()).orElse(BigDecimal.ZERO)) |
775 | - .add(Optional.ofNullable(businessProfitInfoVO.getActualOrderRmbPrice()).orElse(BigDecimal.ZERO))); | |
776 | + .add(Optional.ofNullable(businessProfitInfoVO.getActualOrderRmbPrice()).orElse(BigDecimal.ZERO)).setScale(2, RoundingMode.HALF_UP)); | |
776 | 777 | return businessProfitInfoVO; |
777 | 778 | }).collect(Collectors.toList()); |
778 | 779 | } | ... | ... |