|
|
@@ -1000,58 +1000,66 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
//获取出库明细商品对应融资采购商品明细
|
|
|
List<PjOrderItems> orderItemList = orderItemsList.stream().filter(e -> e.getGoodsId().equals(shipItems.getGoodsId())).collect(Collectors.toList());
|
|
|
List<FinancingShipItemDto> mapList = new ArrayList<>();
|
|
|
- //采购商品明细循环
|
|
|
- for (PjOrderItems orderItems1 : orderItemList) {
|
|
|
- if (number.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
- //记录出库明细对应融资采购单据
|
|
|
- ShipItemsRecord shipItemsRecord = new ShipItemsRecord();
|
|
|
- shipItemsRecord.setBillNo(ship.getBillno());
|
|
|
- shipItemsRecord.setPid(shipItems.getPid());
|
|
|
- shipItemsRecord.setItemId(shipItems.getId());
|
|
|
- shipItemsRecord.setSrcId(orderItems1.getPid());
|
|
|
- shipItemsRecord.setSrcItemId(orderItems1.getId());
|
|
|
- shipItemsRecord.setSrcOrd(orderItems1.getBillNo());
|
|
|
- shipItemsRecord.setCreateUser(AuthUtil.getUserId());
|
|
|
- shipItemsRecord.setCreateUserName(AuthUtil.getUserName());
|
|
|
- shipItemsRecord.setCreateTime(new Date());
|
|
|
- //记录具体出库数量,来源融资采购明细
|
|
|
- FinancingShipItemDto financingShipItemDto = new FinancingShipItemDto();
|
|
|
- financingShipItemDto.setId(orderItems1.getId());
|
|
|
- financingShipItemDto.setPid(orderItems1.getPid());
|
|
|
- financingShipItemDto.setItemId(shipItems.getId());
|
|
|
- BigDecimal subNum = orderItems1.getSendNum().subtract(orderItems1.getOutGoodsTotalShipNum());
|
|
|
- //剩余数量 = 入库数量-已出数量
|
|
|
- //修改明细出库数量
|
|
|
- if (number.compareTo(subNum) > 0) {
|
|
|
- financingShipItemDto.setNum(subNum);
|
|
|
- financingShipItemDto.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
- shipItemsRecord.setNum(subNum);
|
|
|
- shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
- //本次出库数量大于剩余数量 融资采购明细出库数量=入库数量
|
|
|
- orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
- orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
- number = number.subtract(subNum);
|
|
|
- } else if (number.compareTo(subNum) == 0) {
|
|
|
- financingShipItemDto.setNum(subNum);
|
|
|
- financingShipItemDto.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
- shipItemsRecord.setNum(subNum);
|
|
|
- shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
- //本次出库数量等于剩余数量 融资采购明细出库数量=入库数量
|
|
|
- orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
- orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
- number = new BigDecimal("0.00");
|
|
|
- } else {
|
|
|
- financingShipItemDto.setNum(number);
|
|
|
- financingShipItemDto.setAmount(number.multiply(orderItems1.getPrice()));
|
|
|
- shipItemsRecord.setNum(number);
|
|
|
- shipItemsRecord.setAmount(number.multiply(orderItems1.getPrice()));
|
|
|
- //本次出库数量小于剩余数量 融资采购明细出库数量=入库数量-本次出库数量
|
|
|
- orderItems1.setOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum().add(number));
|
|
|
- orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
- number = new BigDecimal("0.00");
|
|
|
+ if (number.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ //采购商品明细循环
|
|
|
+ for (PjOrderItems orderItems1 : orderItemList) {
|
|
|
+ if (orderItems1.getGoodsId().equals(shipItems.getGoodsId())) {
|
|
|
+ //记录出库明细对应融资采购单据
|
|
|
+ ShipItemsRecord shipItemsRecord = new ShipItemsRecord();
|
|
|
+ shipItemsRecord.setBillNo(ship.getBillno());
|
|
|
+ shipItemsRecord.setPid(shipItems.getPid());
|
|
|
+ shipItemsRecord.setItemId(shipItems.getId());
|
|
|
+ shipItemsRecord.setSrcId(orderItems1.getPid());
|
|
|
+ shipItemsRecord.setSrcItemId(orderItems1.getId());
|
|
|
+ shipItemsRecord.setSrcOrd(orderItems1.getBillNo());
|
|
|
+ shipItemsRecord.setCreateUser(AuthUtil.getUserId());
|
|
|
+ shipItemsRecord.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ shipItemsRecord.setCreateTime(new Date());
|
|
|
+ //记录具体出库数量,来源融资采购明细
|
|
|
+ FinancingShipItemDto financingShipItemDto = new FinancingShipItemDto();
|
|
|
+ financingShipItemDto.setId(orderItems1.getId());
|
|
|
+ financingShipItemDto.setPid(orderItems1.getPid());
|
|
|
+ financingShipItemDto.setItemId(shipItems.getId());
|
|
|
+ BigDecimal subNum = orderItems1.getSendNum().subtract(orderItems1.getOutGoodsTotalShipNum());
|
|
|
+ //剩余数量 = 入库数量-已出数量
|
|
|
+ //修改明细出库数量
|
|
|
+ if (number.compareTo(subNum) > 0) {
|
|
|
+ financingShipItemDto.setNum(subNum);
|
|
|
+ financingShipItemDto.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
+ shipItemsRecord.setNum(subNum);
|
|
|
+ shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
+ //本次出库数量大于剩余数量 融资采购明细出库数量=入库数量
|
|
|
+ orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum());
|
|
|
+ orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipAmount());
|
|
|
+ number = number.subtract(subNum);
|
|
|
+ } else if (number.compareTo(subNum) == 0) {
|
|
|
+ financingShipItemDto.setNum(subNum);
|
|
|
+ financingShipItemDto.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
+ shipItemsRecord.setNum(subNum);
|
|
|
+ shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
+ //本次出库数量等于剩余数量 融资采购明细出库数量=入库数量
|
|
|
+ orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum());
|
|
|
+ orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipAmount());
|
|
|
+ number = new BigDecimal("0.00");
|
|
|
+ } else {
|
|
|
+ financingShipItemDto.setNum(number);
|
|
|
+ financingShipItemDto.setAmount(number.multiply(orderItems1.getPrice()));
|
|
|
+ shipItemsRecord.setNum(number);
|
|
|
+ shipItemsRecord.setAmount(number.multiply(orderItems1.getPrice()));
|
|
|
+ //本次出库数量小于剩余数量 融资采购明细出库数量=入库数量-本次出库数量
|
|
|
+ orderItems1.setOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum().add(number));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(number);
|
|
|
+ orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(number.multiply(orderItems1.getPrice()));
|
|
|
+ number = new BigDecimal("0.00");
|
|
|
+ }
|
|
|
+ mapList.add(financingShipItemDto);
|
|
|
+ recordList.add(shipItemsRecord);
|
|
|
}
|
|
|
- mapList.add(financingShipItemDto);
|
|
|
- recordList.add(shipItemsRecord);
|
|
|
orderItemList1.add(orderItems1);
|
|
|
}
|
|
|
}
|
|
|
@@ -1084,9 +1092,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.collect(Collectors.toList());
|
|
|
//重新合计融资采购已出数量,金额
|
|
|
if (!pjOrderItems.isEmpty()) {
|
|
|
- items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().add(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipNum)
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().add(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
- items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().add(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipAmount)
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().add(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
}
|
|
|
//重新计算所有未赎回融资采购,保证金,融资金额
|
|
|
@@ -1431,7 +1439,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
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);
|
|
|
@@ -1447,10 +1457,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
List<PjOrderItems> pjOrderItems = orderItemsList.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
.collect(Collectors.toList());
|
|
|
if (!pjOrderItems.isEmpty()) {
|
|
|
- items.setOutGoodsTotalShipNum(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipNum)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- items.setOutGoodsTotalShipAmount(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipAmount)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
}
|
|
|
if (orderIdsList.contains(items.getId())) {
|
|
|
if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
@@ -2127,7 +2137,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
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);
|
|
|
@@ -2144,10 +2156,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
List<PjOrderItems> pjOrderItems = orderItemsList.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
.collect(Collectors.toList());
|
|
|
if (!pjOrderItems.isEmpty()) {
|
|
|
- items.setOutGoodsTotalShipNum(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipNum)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- items.setOutGoodsTotalShipAmount(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipAmount)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().subtract(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().subtract(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
}
|
|
|
if (!"1".equals(items.getWhetherRedeem())) {
|
|
|
Date currentDate = new Date();
|
|
|
@@ -2771,6 +2783,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
List<FinancingShipItemDto> allList = new ArrayList<>();
|
|
|
List<ShipItemsRecord> recordList = new ArrayList<>();
|
|
|
+ List<PjOrderItems> orderItemList1 = new ArrayList<>();
|
|
|
for (PjShipItems shipItems : ship.getShipItemsList()) {
|
|
|
if (ObjectUtils.isNotNull(financingBrand) && financingBrand.contains(shipItems.getBrandName())) {
|
|
|
BigDecimal number1 = shipItems.getSendNum();
|
|
|
@@ -2800,6 +2813,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum());
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipAmount());
|
|
|
number1 = number1.subtract(subNum);
|
|
|
} else if (number1.compareTo(subNum) == 0) {
|
|
|
financingShipItemDto.setNum(subNum);
|
|
|
@@ -2808,6 +2823,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsRecord.setAmount(subNum.multiply(orderItems1.getPrice()));
|
|
|
orderItems1.setOutGoodsTotalShipNum(orderItems1.getSendNum());
|
|
|
orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum());
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipAmount());
|
|
|
number1 = new BigDecimal("0.00");
|
|
|
} else {
|
|
|
financingShipItemDto.setNum(number1);
|
|
|
@@ -2816,10 +2833,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsRecord.setAmount(number1.multiply(orderItems1.getPrice()));
|
|
|
orderItems1.setOutGoodsTotalShipNum(orderItems1.getOutGoodsTotalShipNum().add(number1));
|
|
|
orderItems1.setOutGoodsTotalShipAmount(orderItems1.getOutGoodsTotalShipNum().multiply(orderItems1.getPrice()));
|
|
|
+ orderItems1.setThisOutGoodsTotalShipNum(number1);
|
|
|
+ orderItems1.setThisOutGoodsTotalShipAmount(number1.multiply(orderItems1.getPrice()));
|
|
|
number1 = new BigDecimal("0.00");
|
|
|
}
|
|
|
mapList.add(financingShipItemDto);
|
|
|
recordList.add(shipItemsRecord);
|
|
|
+ orderItemList1.add(orderItems1);
|
|
|
}
|
|
|
}
|
|
|
if (!mapList.isEmpty()) {
|
|
|
@@ -2845,12 +2865,12 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
BigDecimal fundingAmountSum = new BigDecimal("0.00");
|
|
|
BigDecimal availableAmountSum = new BigDecimal("0.00");
|
|
|
for (PjOrder items : orderList) {
|
|
|
- List<PjOrderItems> pjOrderItems = orderItemsList.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
+ List<PjOrderItems> pjOrderItems = orderItemList1.stream().filter(e -> items.getId().equals(e.getPid()))
|
|
|
.collect(Collectors.toList());
|
|
|
if (!pjOrderItems.isEmpty()) {
|
|
|
- items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().add(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipNum)
|
|
|
+ items.setOutGoodsTotalShipNum(items.getOutGoodsTotalShipNum().add(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipNum)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
- items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().add(pjOrderItems.stream().map(PjOrderItems::getOutGoodsTotalShipAmount)
|
|
|
+ items.setOutGoodsTotalShipAmount(items.getOutGoodsTotalShipAmount().add(pjOrderItems.stream().map(PjOrderItems::getThisOutGoodsTotalShipAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
}
|
|
|
if (!"1".equals(items.getWhetherRedeem())) {
|