罗元桥
2021-09-27 faae303cd25f90b1c732b6bc737ede8b8ab714a0
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
@@ -66,6 +66,9 @@
        ConvenientProductDO convenientProductDO = new ConvenientProductDO();
        BeanUtils.copyProperties(convenientProductDTO, convenientProductDO);
        Date nowDate = new Date();
        if (convenientProductDTO.getOnShelf()) {
            convenientProductDO.setOnShelfAt(nowDate);
        }
        convenientProductDO.setCreatedAt(nowDate);
        this.baseMapper.insert(convenientProductDO);
        Long productId = convenientProductDO.getId();
@@ -91,16 +94,20 @@
        Long productId = convenientProductDTO.getId();
        Long updatedBy = convenientProductDTO.getUpdatedBy();
        ConvenientProductDO convenientProductDO = this.baseMapper.selectById(productId);
        Boolean isOnShelf = convenientProductDO.getOnShelf();
        if (isNull(convenientProductDO)) {
            return R.fail("产品不存在");
        }
        BeanUtils.copyProperties(convenientProductDTO, convenientProductDO);
        Date nowDate = new Date();
        if (!isOnShelf && convenientProductDTO.getOnShelf()) {
            convenientProductDO.setOnShelfAt(nowDate);
        }
        convenientProductDO.setUpdatedBy(updatedBy);
        this.baseMapper.updateById(convenientProductDO);
        List<ConvenientProductSpecificationDTO> productSpecificationDTOList = convenientProductDTO.getProductSpecificationDTOList();
        List<Long> notNeedDelIds = productSpecificationDTOList.stream().filter(specificationDTO -> nonNull(specificationDTO.getId()))
                .map(ConvenientProductSpecificationDTO::getId).collect(Collectors.toList());
        Date nowDate = new Date();
        productSpecificationDTOList.forEach(specificationDTO -> {
            Long specificationId = specificationDTO.getId();
            if (isNull(specificationId)) {