diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ConsStockFlowServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ConsStockFlowServiceImpl.java index 9f59766ed..c7f678c54 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ConsStockFlowServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ConsStockFlowServiceImpl.java @@ -86,30 +86,32 @@ List entityList = BeanUtil.copyToList(param.getBodyList(), ConsStockFlow.class); List insertList = new ArrayList<>(); List updateStockList = new ArrayList<>(); - for (ConsStockFlow entity : entityList) { + for (ConsInOutStockBodyParam entity : param.getBodyList()) { + ConsStockFlow consStockFlow = BeanUtil.copyProperties(entity, ConsStockFlow.class); BeanUtil.copyProperties(head, entity, CopyOptions.create().ignoreNullValue()); - entity.setShopId(shopId); - entity.setInOutType(InOutTypeEnum.IN.value()); - entity.setInOutItem(InOutItemEnum.MANUAL_IN.value()); - entity.setCreateUserId(createUserId); - entity.setCreateUserName(createUserName); - Long conId = entity.getConId(); + consStockFlow.setShopId(shopId); + consStockFlow.setInOutType(InOutTypeEnum.IN.value()); + consStockFlow.setInOutItem(InOutItemEnum.MANUAL_IN.value()); + consStockFlow.setCreateUserId(createUserId); + consStockFlow.setCreateUserName(createUserName); + String conId = entity.getConId(); ConsInfo consInfo; - if (entity.getId() == null) { + if (entity.getConId() == null) { consInfo = consInfoMapper.selectOneByQuery(new QueryWrapper().like(ConsInfo::getConName, entity.getConName()) .eq(ConsInfo::getShopId, shopId).limit(1)); - entity.setConId(consInfo == null ? null : consInfo.getId()); + entity.setConId(consInfo == null ? null : consInfo.getId().toString()); + consStockFlow.setConId(consInfo == null ? null : consInfo.getId()); }else { consInfo = consInfoMapper.selectOneById(conId); } if (consInfo == null) { continue; } - entity.setBeforeNumber(consInfo.getStockNumber()); - entity.setAfterNumber(NumberUtil.add(entity.getBeforeNumber(), entity.getInOutNumber())); - insertList.add(entity); - consInfo.setStockNumber(entity.getAfterNumber()); + consStockFlow.setBeforeNumber(consInfo.getStockNumber()); + consStockFlow.setAfterNumber(NumberUtil.add(consStockFlow.getBeforeNumber(), entity.getInOutNumber())); + insertList.add(consStockFlow); + consInfo.setStockNumber(consStockFlow.getAfterNumber()); updateStockList.add(consInfo); } super.saveBatch(insertList);