fix(sales): 修复销售出库单实付金额计算逻辑- 移除了测试代码片段- 添加了实付金额的计算逻辑,根据应收金额、请求数量和实发数量进行计算

- 增加了对请求数量和实发数量的非零校验
-优化了实付金额的精度处理,使用 BigDecimal 进行精确计算
This commit is contained in:
liuy 2024-11-06 17:01:36 +08:00
parent 78bacc9833
commit 9bb677bf79
1 changed files with 15 additions and 6 deletions

View File

@ -1094,11 +1094,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>(); List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto); saleorderRequestDtoList.add(saleorderRequestDto);
//TODO 测试
if (true) {
continue;
}
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>(); Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList); stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
@ -1708,7 +1703,21 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
} }
Assert.notNull(totalPayAmount, "应收金额不能为空(应收金额=实付金额+达人优惠+支付优惠+平台优惠) 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId()); Assert.notNull(totalPayAmount, "应收金额不能为空(应收金额=实付金额+达人优惠+支付优惠+平台优惠) 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId()); Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");
//O实付金额=O应收金额/O请求数量*O实发数量
if (!"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) {
//O应收金额/O请求数量
Assert.notNull(sonDetailsDto.getRequestQty(), "请求数量不能为空!");
if ("0".equals(new BigDecimal(sonDetailsDto.getRequestQty()).stripTrailingZeros().toPlainString())) {
Assert.state(false, "请求数量不能为0");
}
if ("0".equals(new BigDecimal(sonDetailsDto.getShipQty()).stripTrailingZeros().toPlainString())) {
Assert.state(false, "实发数量不能为空!");
}
BigDecimal divide = new BigDecimal(totalPayAmount).divide(new BigDecimal(sonDetailsDto.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
totalPayAmountBigDecimal = divide.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
}
BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty()); BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty());
groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal); groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal);