Commit c1876224056cb86f650955e04b317d84bc760683
1 parent
9d4411aa
feat(order): 添加订单id字段并优化利润计算
- 在 BusinessProfitDetailVO 和 InnerProfitDetailVO 中添加订单id字段 - 修改 BusinessProfitDetailVO 中的包装费用实际金额为实际跟单单价 - 更新 BusinessProfitInfoVO 中的研发净利率为净利润率 - 在 OrderCostController 中添加分页返回类型 - 优化 OrderCostInfoServiceImpl 和 ProjectBaseInfoServiceImpl 中的利润计算逻辑 - 使用 SystemSettingService 获取实时汇率进行货币转换
Showing
6 changed files
with
31 additions
and
14 deletions
src/main/java/com/order/erp/controller/OrderCostController.java
1 | 1 | package com.order.erp.controller; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
3 | 4 | import com.order.erp.common.constant.ServerResult; |
4 | 5 | import com.order.erp.domain.vo.OrderProfitAnalysisVo; |
5 | 6 | import com.order.erp.domain.vo.order.*; |
... | ... | @@ -35,13 +36,13 @@ public class OrderCostController { |
35 | 36 | |
36 | 37 | @PostMapping("/InnerProfitDetail/listByPage") |
37 | 38 | @ApiOperation("内部生产费用明细表") |
38 | - public ServerResult listInnerProfitDetailByPage(@RequestBody @Validated OrderBaseInfoQueryVO queryVO) { | |
39 | + public ServerResult<Page<InnerProfitDetailVO>> listInnerProfitDetailByPage(@RequestBody @Validated OrderBaseInfoQueryVO queryVO) { | |
39 | 40 | queryVO.setProductionDepartment(Collections.singletonList("内部")); |
40 | 41 | return orderCostInfoService.listInnerProfitDetailByPage(queryVO); |
41 | 42 | } |
42 | 43 | @PostMapping("/BusinessProfitDetail/listByPage") |
43 | 44 | @ApiOperation("包装费用明细表") |
44 | - public ServerResult listBusinessProfitDetailsByPage(@RequestBody @Validated OrderBaseInfoQueryVO queryVO) { | |
45 | + public ServerResult<Page<BusinessProfitDetailVO>> listBusinessProfitDetailsByPage(@RequestBody @Validated OrderBaseInfoQueryVO queryVO) { | |
45 | 46 | return orderCostInfoService.listBusinessProfitDetailByPage(queryVO); |
46 | 47 | } |
47 | 48 | @PostMapping("/edit") | ... | ... |
src/main/java/com/order/erp/domain/vo/order/BusinessProfitDetailVO.java
... | ... | @@ -31,6 +31,12 @@ public class BusinessProfitDetailVO implements Serializable { |
31 | 31 | /** |
32 | 32 | * 项目号 |
33 | 33 | */ |
34 | + @ApiModelProperty(value = "订单id") | |
35 | + private Long orderId; | |
36 | + | |
37 | + /** | |
38 | + * 项目号 | |
39 | + */ | |
34 | 40 | @ApiModelProperty(value = "项目号") |
35 | 41 | private String projectNo; |
36 | 42 | |
... | ... | @@ -83,15 +89,15 @@ public class BusinessProfitDetailVO implements Serializable { |
83 | 89 | private BigDecimal packetActualRmbTotalPrice; |
84 | 90 | |
85 | 91 | /** |
86 | - * 包装费用实际金额¥ | |
92 | + * 实际跟单单价¥ | |
87 | 93 | */ |
88 | - @ApiModelProperty(value = "包装费用实际金额(人民币)") | |
94 | + @ApiModelProperty(value = "实际跟单单价(人民币)") | |
89 | 95 | private BigDecimal packetActualRmbPrice; |
90 | 96 | |
91 | 97 | /** |
92 | - * 包装费用实际金额$ | |
98 | + * 实际跟单单价$ | |
93 | 99 | */ |
94 | - @ApiModelProperty(value = "包装费用实际金额(美元)") | |
100 | + @ApiModelProperty(value = "实际跟单单价(美元)") | |
95 | 101 | private BigDecimal packetActualPrice; |
96 | 102 | |
97 | 103 | /** | ... | ... |
src/main/java/com/order/erp/domain/vo/order/BusinessProfitInfoVO.java
... | ... | @@ -204,9 +204,9 @@ public class BusinessProfitInfoVO implements Serializable { |
204 | 204 | private BigDecimal developmentProfit; |
205 | 205 | |
206 | 206 | /** |
207 | - * 研发净利率 | |
207 | + * 净利润率 | |
208 | 208 | */ |
209 | - @ApiModelProperty(value = "研发净利率") | |
209 | + @ApiModelProperty(value = "净利润率") | |
210 | 210 | private BigDecimal developmentProfitRate; |
211 | 211 | |
212 | 212 | /** | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InnerProfitDetailVO.java
src/main/java/com/order/erp/service/order/impl/OrderCostInfoServiceImpl.java
... | ... | @@ -23,6 +23,7 @@ import com.order.erp.domain.model.OrderCostFieldLockRecord; |
23 | 23 | import com.order.erp.domain.vo.order.*; |
24 | 24 | import com.order.erp.mapper.order.OrderCostInfoMapper; |
25 | 25 | import com.order.erp.service.IOrderCostFieldLockRecordService; |
26 | +import com.order.erp.service.SystemSettingService; | |
26 | 27 | import com.order.erp.service.order.IOrderCostInfoService; |
27 | 28 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
28 | 29 | import com.order.erp.service.order.OrderBaseInfoService; |
... | ... | @@ -61,6 +62,8 @@ public class OrderCostInfoServiceImpl extends ServiceImpl<OrderCostInfoMapper, O |
61 | 62 | private OrderBaseInfoService orderBaseInfoService; |
62 | 63 | @Autowired |
63 | 64 | private IOrderCostFieldLockRecordService orderCostFieldLockRecordService; |
65 | + @Autowired | |
66 | + private SystemSettingService systemSettingService; | |
64 | 67 | |
65 | 68 | @Override |
66 | 69 | public ServerResult edit(OrderCostInfoVO vo) { |
... | ... | @@ -125,6 +128,7 @@ public class OrderCostInfoServiceImpl extends ServiceImpl<OrderCostInfoMapper, O |
125 | 128 | })); |
126 | 129 | List<InnerProfitDetailVO> innerProfitRatioResultVOs = records.stream().map(record -> { |
127 | 130 | InnerProfitDetailVO vo = InnerProfitDetailVO.builder() |
131 | + .orderId(record.getId()) | |
128 | 132 | .customerCode(record.getCustomerCode()) |
129 | 133 | .projectNo(record.getProjectNo()) |
130 | 134 | .productionDepartment(record.getProductionDepartment()) |
... | ... | @@ -199,8 +203,10 @@ public class OrderCostInfoServiceImpl extends ServiceImpl<OrderCostInfoMapper, O |
199 | 203 | throw new RuntimeException(e); |
200 | 204 | } |
201 | 205 | })); |
206 | + BigDecimal exchangeRate = systemSettingService.getExchangeRate(); | |
202 | 207 | List<BusinessProfitDetailVO> innerProfitRatioResultVOs = records.stream().map(record -> { |
203 | 208 | BusinessProfitDetailVO vo = BusinessProfitDetailVO.builder() |
209 | + .orderId(record.getId()) | |
204 | 210 | .customerCode(record.getCustomerCode()) |
205 | 211 | .projectNo(record.getProjectNo()) |
206 | 212 | .productionDepartment(record.getProductionDepartment()) |
... | ... | @@ -214,13 +220,13 @@ public class OrderCostInfoServiceImpl extends ServiceImpl<OrderCostInfoMapper, O |
214 | 220 | .build(); |
215 | 221 | if (Objects.nonNull(vo.getPacketTotalPrice())) { |
216 | 222 | //包装费用合计 = 包装费合计*汇率 |
217 | - vo.setPacketRmbTotalPrice(BigDecimal.valueOf(vo.getPacketTotalPrice()).multiply((new BigDecimal("6.2")).setScale(4, RoundingMode.HALF_UP)).doubleValue()); | |
223 | + vo.setPacketRmbTotalPrice(BigDecimal.valueOf(vo.getPacketTotalPrice()).multiply(exchangeRate.setScale(4, RoundingMode.HALF_UP)).doubleValue()); | |
218 | 224 | } |
219 | 225 | if (Objects.nonNull(vo.getPacketActualRmbTotalPrice()) && Objects.nonNull(vo.getOrderCount())) { |
220 | 226 | //实际跟单单价 = 包装费用实际金额/数量 |
221 | 227 | vo.setPacketActualRmbPrice(vo.getPacketActualRmbTotalPrice().divide(BigDecimal.valueOf(vo.getOrderCount()), 4, RoundingMode.HALF_UP)); |
222 | 228 | //实际跟单单价折算美金$ = 人民币单价/汇率 |
223 | - vo.setPacketActualPrice(vo.getPacketActualRmbPrice().divide(new BigDecimal("6.2"), 4, RoundingMode.HALF_UP)); | |
229 | + vo.setPacketActualPrice(vo.getPacketActualRmbPrice().divide(exchangeRate, 4, RoundingMode.HALF_UP)); | |
224 | 230 | } |
225 | 231 | if (Objects.nonNull(vo.getPacketRmbTotalPrice()) && Objects.nonNull(vo.getPacketActualRmbPrice())) { |
226 | 232 | //包装费用收益¥ = 包装费用合计-包装费用实际金额 | ... | ... |
src/main/java/com/order/erp/service/order/impl/ProjectBaseInfoServiceImpl.java
... | ... | @@ -443,7 +443,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
443 | 443 | throw new RuntimeException(e); |
444 | 444 | } |
445 | 445 | })); |
446 | - | |
446 | + BigDecimal exchangeRate = systemSettingService.getExchangeRate(); | |
447 | 447 | List<BusinessProfitInfoVO> businessProfitInfoVOs = orderBaseInfoDOSGroupByProjectNoPre.entrySet().stream().map(entry -> { |
448 | 448 | List<OrderInfoResultVO> details = entry.getValue(); |
449 | 449 | BusinessProfitInfoVO businessProfitInfoVO = BusinessProfitInfoVO.builder() |
... | ... | @@ -494,7 +494,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
494 | 494 | |
495 | 495 | //包装费用合计¥ |
496 | 496 | businessProfitInfoVO.setPacketRmbTotalPrice(Optional.ofNullable(businessProfitInfoVO.getPacketTotalPrice()) |
497 | - .orElse(0.0) * 6.2); | |
497 | + .orElse(0.0) *exchangeRate.doubleValue()); | |
498 | 498 | //包装费用实际金额 |
499 | 499 | details.stream() |
500 | 500 | .map(OrderInfoResultVO::getOrderCostInfo) |
... | ... | @@ -517,7 +517,7 @@ public class ProjectBaseInfoServiceImpl extends ServiceImpl<ProjectBaseInfoMappe |
517 | 517 | //实际跟单单价 |
518 | 518 | businessProfitInfoVO.setActualOrderRmbPrice(businessProfitInfoVO.getPacketActualRmbTotalPrice().divide(new BigDecimal(businessProfitInfoVO.getOrderCount()), 4, RoundingMode.HALF_UP)); |
519 | 519 | //折换成美金 |
520 | - businessProfitInfoVO.setActualOrderPrice(businessProfitInfoVO.getActualOrderRmbPrice().divide(BigDecimal.valueOf(6.2), 4, RoundingMode.HALF_UP)); | |
520 | + businessProfitInfoVO.setActualOrderPrice(businessProfitInfoVO.getActualOrderRmbPrice().divide(exchangeRate, 4, RoundingMode.HALF_UP)); | |
521 | 521 | } |
522 | 522 | if (Objects.nonNull(businessProfitInfoVO.getPacketActualRmbTotalPrice()) |
523 | 523 | && Objects.nonNull(businessProfitInfoVO.getPacketRmbTotalPrice())) { | ... | ... |