Commit c1876224056cb86f650955e04b317d84bc760683

Authored by 曾国涛
1 parent 9d4411aa

feat(order): 添加订单id字段并优化利润计算

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