|
|
@@ -1654,229 +1654,233 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
pjpfFundingItemService.save(item);
|
|
|
}*/
|
|
|
if (ObjectUtils.isNotNull(status) && "1".equals(status)) {
|
|
|
- List<ShipItemsRecord> recordList = shipItemsRecordService.list(new LambdaQueryWrapper<ShipItemsRecord>()
|
|
|
- .eq(ShipItemsRecord::getIsDeleted, 0)
|
|
|
- .eq(ShipItemsRecord::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ShipItemsRecord::getPid, ship.getId()));
|
|
|
- if (!recordList.isEmpty()) {
|
|
|
- shipItemsRecordService.removeByIds(recordList.stream().map(ShipItemsRecord::getId).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- String firstProportion = sysClient.getParamService("first.month.proportion");
|
|
|
- String secondProportion = sysClient.getParamService("second.month.proportion");
|
|
|
- PjpfFunding pjpfFunding = pjpfFundingService.getOne(new LambdaQueryWrapper<PjpfFunding>()
|
|
|
- .eq(PjpfFunding::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjpfFunding::getIsDeleted, 0));
|
|
|
- if (pjpfFunding == null) {
|
|
|
- throw new RuntimeException("未找到融资总账");
|
|
|
- }
|
|
|
- List<String> srcFinancingList = itemsList.stream().map(PjShipItems::getSrcFinancing).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- List<FinancingShipItemDto> financingShipItemDtoList = new ArrayList<>();
|
|
|
- for (String item : srcFinancingList) {
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
- try {
|
|
|
- List<FinancingShipItemDto> entities = mapper.readValue(item, new TypeReference<List<FinancingShipItemDto>>() {
|
|
|
- });
|
|
|
- if (!entities.isEmpty()) {
|
|
|
- financingShipItemDtoList.addAll(entities);
|
|
|
+ BigDecimal sendNumFinancing = itemsList.stream().map(PjShipItems::getSendNumFinancing).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if (new BigDecimal("0.00").compareTo(sendNumFinancing) != 0) {
|
|
|
+ List<ShipItemsRecord> recordList = shipItemsRecordService.list(new LambdaQueryWrapper<ShipItemsRecord>()
|
|
|
+ .eq(ShipItemsRecord::getIsDeleted, 0)
|
|
|
+ .eq(ShipItemsRecord::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(ShipItemsRecord::getPid, ship.getId()));
|
|
|
+ if (!recordList.isEmpty()) {
|
|
|
+ shipItemsRecordService.removeByIds(recordList.stream().map(ShipItemsRecord::getId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ String firstProportion = sysClient.getParamService("first.month.proportion");
|
|
|
+ String secondProportion = sysClient.getParamService("second.month.proportion");
|
|
|
+ PjpfFunding pjpfFunding = pjpfFundingService.getOne(new LambdaQueryWrapper<PjpfFunding>()
|
|
|
+ .eq(PjpfFunding::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjpfFunding::getIsDeleted, 0));
|
|
|
+ if (pjpfFunding == null) {
|
|
|
+ throw new RuntimeException("未找到融资总账");
|
|
|
+ }
|
|
|
+ List<String> srcFinancingList = itemsList.stream().map(PjShipItems::getSrcFinancing).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<FinancingShipItemDto> financingShipItemDtoList = new ArrayList<>();
|
|
|
+ for (String item : srcFinancingList) {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ List<FinancingShipItemDto> entities = mapper.readValue(item, new TypeReference<List<FinancingShipItemDto>>() {
|
|
|
+ });
|
|
|
+ if (!entities.isEmpty()) {
|
|
|
+ financingShipItemDtoList.addAll(entities);
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
- List<PjOrder> orderList = orderMapper.selectList(new LambdaQueryWrapper<PjOrder>()
|
|
|
- .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjOrder::getIsDeleted, 0)
|
|
|
- .eq(PjOrder::getWhetherFinancing, "1")
|
|
|
- .eq(PjOrder::getBsType, "RZCG")
|
|
|
- .orderByAsc(PjOrder::getBusinesDate)
|
|
|
- );
|
|
|
- List<Long> ordIds = orderList.stream().map(PjOrder::getId).collect(Collectors.toList());
|
|
|
- List<PjOrderItems> orderItemsList = new ArrayList<>();
|
|
|
- if (!ordIds.isEmpty()) {
|
|
|
- List<Long> ids = financingShipItemDtoList.stream().map(FinancingShipItemDto::getId).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- if (!ids.isEmpty()) {
|
|
|
- orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
- .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
- .eq(PjOrderItems::getBizType, "RZCG")
|
|
|
- .in(PjOrderItems::getPid, ordIds)
|
|
|
- .in(PjOrderItems::getId, ids)
|
|
|
- .orderByAsc(PjOrderItems::getCreateTime)
|
|
|
- );
|
|
|
}
|
|
|
- }
|
|
|
- BigDecimal amount = new BigDecimal("0.00");
|
|
|
- for (PjShipItems item : itemsList) {
|
|
|
- if (new BigDecimal("0").compareTo(item.getSendNumFinancing()) != 0) {
|
|
|
- BigDecimal costprie = item.getSendNumFinancing().multiply(item.getCostpriePrice());
|
|
|
- amount = amount.add(costprie);
|
|
|
+ List<PjOrder> orderList = orderMapper.selectList(new LambdaQueryWrapper<PjOrder>()
|
|
|
+ .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrder::getIsDeleted, 0)
|
|
|
+ .eq(PjOrder::getWhetherFinancing, "1")
|
|
|
+ .eq(PjOrder::getBsType, "RZCG")
|
|
|
+ .orderByAsc(PjOrder::getBusinesDate)
|
|
|
+ );
|
|
|
+ List<Long> ordIds = orderList.stream().map(PjOrder::getId).collect(Collectors.toList());
|
|
|
+ List<PjOrderItems> orderItemsList = new ArrayList<>();
|
|
|
+ if (!ordIds.isEmpty()) {
|
|
|
+ List<Long> ids = financingShipItemDtoList.stream().map(FinancingShipItemDto::getId).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
+ .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
+ .eq(PjOrderItems::getBizType, "RZCG")
|
|
|
+ .in(PjOrderItems::getPid, ordIds)
|
|
|
+ .in(PjOrderItems::getId, ids)
|
|
|
+ .orderByAsc(PjOrderItems::getCreateTime)
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (amount.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
- for (PjOrderItems items : orderItemsList) {
|
|
|
- FinancingShipItemDto pjOrderItems = financingShipItemDtoList.stream().filter(e -> e.getId().equals(items.getId())).findFirst().orElse(null);
|
|
|
- if (pjOrderItems != null) {
|
|
|
- items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(pjOrderItems.getNum()));
|
|
|
- items.setThisOutGoodsTotalShipNum(pjOrderItems.getNum());
|
|
|
- items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(pjOrderItems.getAmount()));
|
|
|
- items.setThisOutGoodsTotalShipAmount(pjOrderItems.getAmount());
|
|
|
+ BigDecimal amount = new BigDecimal("0.00");
|
|
|
+ for (PjShipItems item : itemsList) {
|
|
|
+ if (new BigDecimal("0").compareTo(item.getSendNumFinancing()) != 0) {
|
|
|
+ BigDecimal costprie = item.getSendNumFinancing().multiply(item.getCostpriePrice());
|
|
|
+ amount = amount.add(costprie);
|
|
|
}
|
|
|
}
|
|
|
- orderItemsService.updateBatchById(orderItemsList);
|
|
|
- pjpfFunding.setAvailableAmount(pjpfFunding.getAvailableAmount().add(amount));
|
|
|
- BigDecimal bondAmountSum = new BigDecimal("0.00");
|
|
|
- BigDecimal fundingAmountSum = new BigDecimal("0.00");
|
|
|
- BigDecimal availableAmountSum = new BigDecimal("0.00");
|
|
|
- List<Long> orderIdsList = financingShipItemDtoList.stream().map(FinancingShipItemDto::getPid).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- for (PjOrder items : orderList) {
|
|
|
- List<PjOrderItems> pjOrderItems = orderItemsList.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjOrderItems.isEmpty()) {
|
|
|
- BigDecimal thisSendSum = pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal thisSendAmount = pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(thisSendSum));
|
|
|
- items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(thisSendAmount));
|
|
|
- if (ObjectUtils.isNotNull(items.getSalesAmount()) && new BigDecimal("0.00").compareTo(items.getSalesAmount()) != 0) {
|
|
|
- if (orderIdsList.contains(items.getId())) {
|
|
|
- if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
- Date currentDate = new Date();
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(currentDate);
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, -60);
|
|
|
- Date thirtyDayAgo = calendar.getTime();
|
|
|
- List<Long> itemIdList = financingShipItemDtoList.stream().filter(e -> e.getPid().equals(items.getId())).map(FinancingShipItemDto::getItemId).collect(Collectors.toList());
|
|
|
- List<PjShipItems> shipItems = new ArrayList<>();
|
|
|
- if (!itemIdList.isEmpty()) {
|
|
|
- shipItems = itemsList.stream().filter(e -> itemIdList.contains(e.getId())).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (currentDate.compareTo(thirtyDayAgo) > 0) {
|
|
|
- String secondProportionOld = "";
|
|
|
- if (!shipItems.isEmpty() && ObjectUtils.isNotNull(shipItems.get(0).getProportion())) {
|
|
|
- secondProportionOld = shipItems.get(0).getProportion();
|
|
|
- } else {
|
|
|
- throw new RuntimeException("未找到出库融资比例");
|
|
|
+ if (amount.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
+ for (PjOrderItems items : orderItemsList) {
|
|
|
+ FinancingShipItemDto pjOrderItems = financingShipItemDtoList.stream().filter(e -> e.getId().equals(items.getId())).findFirst().orElse(null);
|
|
|
+ if (pjOrderItems != null) {
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(pjOrderItems.getNum()));
|
|
|
+ items.setThisOutGoodsTotalShipNum(pjOrderItems.getNum());
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(pjOrderItems.getAmount()));
|
|
|
+ items.setThisOutGoodsTotalShipAmount(pjOrderItems.getAmount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderItemsService.updateBatchById(orderItemsList);
|
|
|
+ pjpfFunding.setAvailableAmount(pjpfFunding.getAvailableAmount().add(amount));
|
|
|
+ BigDecimal bondAmountSum = new BigDecimal("0.00");
|
|
|
+ BigDecimal fundingAmountSum = new BigDecimal("0.00");
|
|
|
+ BigDecimal availableAmountSum = new BigDecimal("0.00");
|
|
|
+ List<Long> orderIdsList = financingShipItemDtoList.stream().map(FinancingShipItemDto::getPid).filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ for (PjOrder items : orderList) {
|
|
|
+ List<PjOrderItems> pjOrderItems = orderItemsList.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!pjOrderItems.isEmpty()) {
|
|
|
+ BigDecimal thisSendSum = pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal thisSendAmount = pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(thisSendSum));
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(thisSendAmount));
|
|
|
+ if (ObjectUtils.isNotNull(items.getSalesAmount()) && new BigDecimal("0.00").compareTo(items.getSalesAmount()) != 0) {
|
|
|
+ if (orderIdsList.contains(items.getId())) {
|
|
|
+ if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
+ Date currentDate = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(currentDate);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -60);
|
|
|
+ Date thirtyDayAgo = calendar.getTime();
|
|
|
+ List<Long> itemIdList = financingShipItemDtoList.stream().filter(e -> e.getPid().equals(items.getId())).map(FinancingShipItemDto::getItemId).collect(Collectors.toList());
|
|
|
+ List<PjShipItems> shipItems = new ArrayList<>();
|
|
|
+ if (!itemIdList.isEmpty()) {
|
|
|
+ shipItems = itemsList.stream().filter(e -> itemIdList.contains(e.getId())).collect(Collectors.toList());
|
|
|
}
|
|
|
- String[] arr = secondProportionOld.split(":");
|
|
|
- BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
- items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
- items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
- bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
- fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
- } else {
|
|
|
- String firstProportionOld = "";
|
|
|
- if (!shipItems.isEmpty() && ObjectUtils.isNotNull(shipItems.get(0).getProportion())) {
|
|
|
- firstProportionOld = shipItems.get(0).getProportion();
|
|
|
+ if (currentDate.compareTo(thirtyDayAgo) > 0) {
|
|
|
+ String secondProportionOld = "";
|
|
|
+ if (!shipItems.isEmpty() && ObjectUtils.isNotNull(shipItems.get(0).getProportion())) {
|
|
|
+ secondProportionOld = shipItems.get(0).getProportion();
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未找到出库融资比例");
|
|
|
+ }
|
|
|
+ String[] arr = secondProportionOld.split(":");
|
|
|
+ BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
+ items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
+ items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
+ bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
+ fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
} else {
|
|
|
- throw new RuntimeException("未找到出库融资比例");
|
|
|
+ String firstProportionOld = "";
|
|
|
+ if (!shipItems.isEmpty() && ObjectUtils.isNotNull(shipItems.get(0).getProportion())) {
|
|
|
+ firstProportionOld = shipItems.get(0).getProportion();
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未找到出库融资比例");
|
|
|
+ }
|
|
|
+ String[] arr = firstProportionOld.split(":");
|
|
|
+ BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
+ items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
+ items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
+ bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
+ fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
}
|
|
|
- String[] arr = firstProportionOld.split(":");
|
|
|
- BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
- items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
- items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
- bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
- fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
- Date currentDate = new Date();
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(currentDate);
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, -60);
|
|
|
- Date thirtyDayAgo = calendar.getTime();
|
|
|
- List<Long> itemIdList = financingShipItemDtoList.stream().filter(e -> e.getPid().equals(items.getId())).map(FinancingShipItemDto::getId).collect(Collectors.toList());
|
|
|
- List<PjShipItems> shipItems = new ArrayList<>();
|
|
|
- if (!itemIdList.isEmpty()) {
|
|
|
- shipItems = itemsList.stream().filter(e -> itemIdList.contains(e.getId())).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (currentDate.compareTo(thirtyDayAgo) > 0) {
|
|
|
- if (!shipItems.isEmpty()) {
|
|
|
- for (PjShipItems shipItems1 : itemsList) {
|
|
|
- shipItems1.setProportion(firstProportion);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
+ Date currentDate = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(currentDate);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -60);
|
|
|
+ Date thirtyDayAgo = calendar.getTime();
|
|
|
+ List<Long> itemIdList = financingShipItemDtoList.stream().filter(e -> e.getPid().equals(items.getId())).map(FinancingShipItemDto::getId).collect(Collectors.toList());
|
|
|
+ List<PjShipItems> shipItems = new ArrayList<>();
|
|
|
+ if (!itemIdList.isEmpty()) {
|
|
|
+ shipItems = itemsList.stream().filter(e -> itemIdList.contains(e.getId())).collect(Collectors.toList());
|
|
|
}
|
|
|
- String[] arr = firstProportion.split(":");
|
|
|
- BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
- items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
- items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
- bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
- fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
- } else {
|
|
|
- if (!shipItems.isEmpty()) {
|
|
|
- for (PjShipItems shipItems1 : shipItems) {
|
|
|
- shipItems1.setProportion(secondProportion);
|
|
|
+ if (currentDate.compareTo(thirtyDayAgo) > 0) {
|
|
|
+ if (!shipItems.isEmpty()) {
|
|
|
+ for (PjShipItems shipItems1 : itemsList) {
|
|
|
+ shipItems1.setProportion(firstProportion);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] arr = firstProportion.split(":");
|
|
|
+ BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
+ items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
+ items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
+ bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
+ fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
+ } else {
|
|
|
+ if (!shipItems.isEmpty()) {
|
|
|
+ for (PjShipItems shipItems1 : shipItems) {
|
|
|
+ shipItems1.setProportion(secondProportion);
|
|
|
+ }
|
|
|
}
|
|
|
+ String[] arr = secondProportion.split(":");
|
|
|
+ BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
+ (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)));
|
|
|
+ availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
+ items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
+ items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
+ bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
+ fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
}
|
|
|
- String[] arr = secondProportion.split(":");
|
|
|
- BigDecimal bondAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[0]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- BigDecimal fundingAmount = thisSendAmount.multiply(
|
|
|
- (new BigDecimal(arr[1]).divide(new BigDecimal("10"), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP)));
|
|
|
- availableAmountSum = availableAmountSum.add(bondAmount);
|
|
|
- items.setBondAmount(items.getBondAmount().add(bondAmount));
|
|
|
- items.setFundingAmount(items.getFundingAmount().add(fundingAmount));
|
|
|
- bondAmountSum = bondAmountSum.add(bondAmount);
|
|
|
- fundingAmountSum = fundingAmountSum.add(fundingAmount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ orderMapper.updateById(items);
|
|
|
}
|
|
|
- orderMapper.updateById(items);
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ //可用金额 = 原可用金额 + 本次释放金额
|
|
|
+ pjpfFunding.setAvailableAmount(pjpfFunding.getAvailableAmount().subtract(availableAmountSum));
|
|
|
+ pjpfFunding.setSurplusFundingAmount(pjpfFunding.getSurplusFundingAmount().add(fundingAmountSum));
|
|
|
+ pjpfFunding.setPaidAlreadyBondAmount(pjpfFunding.getPaidAlreadyBondAmount().add(bondAmountSum));
|
|
|
+ pjpfFunding.setBondAmount(pjpfFunding.getBondAmount().add(bondAmountSum));
|
|
|
+ //总金额 = 保证金 + 在库融资金额
|
|
|
+ pjpfFunding.setAmount(pjpfFunding.getAmount().add(amount));
|
|
|
+ //融资金额 = 原融资金额 + (本次出库金额-本次释放金额)
|
|
|
+ pjpfFunding.setFundingAmount(pjpfFunding.getFundingAmount().subtract(fundingAmountSum));
|
|
|
+ pjpfFunding.setProportion(pjpfFunding.getBondAmount().divide(pjpfFunding.getAmount(), MathContext.DECIMAL32)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP));
|
|
|
+ pjpfFundingService.updateById(pjpfFunding);
|
|
|
+ PjpfFundingItem item = new PjpfFundingItem();
|
|
|
+ item.setPid(pjpfFunding.getId());
|
|
|
+ item.setTenantId(AuthUtil.getTenantId());
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ item.setCreateDept(pjpfFunding.getCreateDept());
|
|
|
+ item.setCreateDeptName(pjpfFunding.getCreateDeptName());
|
|
|
+ item.setType("撤销出库");
|
|
|
+ item.setSrcId(ship.getId());
|
|
|
+ item.setSrcNo(ship.getBillno());
|
|
|
+ item.setAmount(amount);
|
|
|
+ item.setFundingAmount(fundingAmountSum);
|
|
|
+ item.setBondAmount(bondAmountSum);
|
|
|
+ pjpfFundingItemService.save(item);
|
|
|
}
|
|
|
- //可用金额 = 原可用金额 + 本次释放金额
|
|
|
- pjpfFunding.setAvailableAmount(pjpfFunding.getAvailableAmount().subtract(availableAmountSum));
|
|
|
- pjpfFunding.setSurplusFundingAmount(pjpfFunding.getSurplusFundingAmount().add(fundingAmountSum));
|
|
|
- pjpfFunding.setPaidAlreadyBondAmount(pjpfFunding.getPaidAlreadyBondAmount().add(bondAmountSum));
|
|
|
- pjpfFunding.setBondAmount(pjpfFunding.getBondAmount().add(bondAmountSum));
|
|
|
- //总金额 = 保证金 + 在库融资金额
|
|
|
- pjpfFunding.setAmount(pjpfFunding.getAmount().add(amount));
|
|
|
- //融资金额 = 原融资金额 + (本次出库金额-本次释放金额)
|
|
|
- pjpfFunding.setFundingAmount(pjpfFunding.getFundingAmount().subtract(fundingAmountSum));
|
|
|
- pjpfFunding.setProportion(pjpfFunding.getBondAmount().divide(pjpfFunding.getAmount(), MathContext.DECIMAL32)
|
|
|
- .setScale(2, RoundingMode.HALF_UP));
|
|
|
- pjpfFundingService.updateById(pjpfFunding);
|
|
|
- PjpfFundingItem item = new PjpfFundingItem();
|
|
|
- item.setPid(pjpfFunding.getId());
|
|
|
- item.setTenantId(AuthUtil.getTenantId());
|
|
|
- item.setCreateTime(new Date());
|
|
|
- item.setCreateUser(AuthUtil.getUserId());
|
|
|
- item.setCreateUserName(AuthUtil.getUserName());
|
|
|
- item.setCreateDept(pjpfFunding.getCreateDept());
|
|
|
- item.setCreateDeptName(pjpfFunding.getCreateDeptName());
|
|
|
- item.setType("撤销出库");
|
|
|
- item.setSrcId(ship.getId());
|
|
|
- item.setSrcNo(ship.getBillno());
|
|
|
- item.setAmount(amount);
|
|
|
- item.setFundingAmount(fundingAmountSum);
|
|
|
- item.setBondAmount(bondAmountSum);
|
|
|
- pjpfFundingItemService.save(item);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
//生成出库工单历史记录
|
|
|
saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|