puhanshu
2021-09-27 a5b5a3569f673661f74089f157aefb3c7d683adb
修复bug
5个文件已修改
30 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductSpecificationDAO.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductSpecificationMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientServiceCategoryMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductSpecificationDAO.java
@@ -27,9 +27,10 @@
    /**
     * 删除传入ID以外的关联
     * @param notNeedDelIds
     * @param productId
     * @return
     */
    int deleteLoseRelationSpecifications(@Param("notNeedDelIds") List<Long> notNeedDelIds);
    int deleteLoseRelationSpecifications(@Param("notNeedDelIds") List<Long> notNeedDelIds, @Param("productId") Long productId);
    /**
     * 通过产品ID删除相关规格
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
@@ -106,8 +106,7 @@
        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());
        List<Long> notNeedDelIds = new ArrayList<>();
        productSpecificationDTOList.forEach(specificationDTO -> {
            Long specificationId = specificationDTO.getId();
            if (isNull(specificationId)) {
@@ -118,16 +117,18 @@
                convenientProductSpecificationDO.setCreatedAt(nowDate);
                convenientProductSpecificationDO.setCreatedBy(updatedBy);
                convenientProductSpecificationDAO.insert(convenientProductSpecificationDO);
                notNeedDelIds.add(convenientProductSpecificationDO.getId());
            } else {
                //更新
                ConvenientProductSpecificationDO convenientProductSpecificationDO = convenientProductSpecificationDAO.selectById(specificationId);
                BeanUtils.copyProperties(specificationDTO, convenientProductSpecificationDO);
                convenientProductSpecificationDO.setUpdatedBy(updatedBy);
                convenientProductSpecificationDAO.updateById(convenientProductSpecificationDO);
                notNeedDelIds.add(specificationId);
            }
        });
        //删除已失去关联的规格
        convenientProductSpecificationDAO.deleteLoseRelationSpecifications(notNeedDelIds);
        convenientProductSpecificationDAO.deleteLoseRelationSpecifications(notNeedDelIds, productId);
        return R.ok();
    }
@@ -215,6 +216,7 @@
        List<ConvenientProductVO> productVOList = this.baseMapper.getMerchantProduct(merchantId);
        List<ConvenientProductSpecificationVO> specificationVOList = this.baseMapper.getProductSpecifications(merchantId);
        List<ConvenientProductLevelInfoVO> levelInfoVOList = new ArrayList<>();
        List<String> categoryList = new ArrayList<>();
        if (!productVOList.isEmpty()) {
            productVOList.forEach(productVO -> {
                List<ConvenientProductSpecificationVO> currentProductSpecificationVOList = new ArrayList<>();
@@ -224,22 +226,22 @@
                    }
                });
                productVO.setProductSpecificationVOList(currentProductSpecificationVOList);
                if (!categoryList.contains(productVO.getCategoryName())) {
                    categoryList.add(productVO.getCategoryName());
                }
            });
            //分类
            Map<String, List<ConvenientProductVO>> levelGroup = productVOList.stream()
                    .collect(Collectors.groupingBy(ConvenientProductVO::getCategoryName));
            Set<String> categoryNames = levelGroup.keySet();
            Iterator<String> iterator = categoryNames.iterator();
            while (iterator.hasNext()) {
                String categoryName = iterator.next();
            categoryList.forEach(category -> {
                ConvenientProductLevelInfoVO levelInfoVOLevelInfoVO = new ConvenientProductLevelInfoVO();
                levelInfoVOLevelInfoVO.setCategoryName(categoryName);
                List<ConvenientProductVO> productVOS = levelGroup.get(categoryName);
                levelInfoVOLevelInfoVO.setCategoryName(category);
                List<ConvenientProductVO> productVOS = levelGroup.get(category);
                List<ConvenientProductVO> sortedProductVOS = productVOS.stream()
                        .sorted(Comparator.comparing(ConvenientProductVO::getOnShelfAt).reversed()).collect(Collectors.toList());
                levelInfoVOLevelInfoVO.setProductVOList(sortedProductVOS);
                levelInfoVOList.add(levelInfoVOLevelInfoVO);
            }
            });
        }
        return R.ok(levelInfoVOList);
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductMapper.xml
@@ -56,6 +56,7 @@
        <if test="pageConvenientProductDTO.onShelf != null">
            AND ccp.on_shelf = #{pageConvenientProductDTO.onShelf}
        </if>
        ORDER BY ccp.created_at DESC
    </select>
    <select id="getMerchantProduct" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO">
        SELECT  ccp.id, ccp.name, ccp.category_id, ccp.on_shelf_at, ccp.introduction, ccpc.name AS categoryName
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductSpecificationMapper.xml
@@ -29,7 +29,7 @@
    </insert>
    <update id="deleteLoseRelationSpecifications" parameterType="java.util.List">
        UPDATE com_convenient_product_specifications SET is_del = 1
        WHERE id NOT IN
        WHERE product_id = #{productId} AND id NOT IN
        <foreach collection="notNeedDelIds" open="(" separator="," close=")" index="index" item="item">
            #{item}
        </foreach>
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientServiceCategoryMapper.xml
@@ -50,6 +50,6 @@
        FROM com_convenient_service_categories ccsc
        INNER JOIN com_convenient_service_scope ccss ON ccsc.id = ccss.service_category_id
        LEFT JOIN com_convenient_merchants ccm ON ccss.merchant_id = ccm.id
        WHERE ccsc.is_del = 0 AND ccm.is_del = 0 AND ccm.community_id = #{communityId} AND ccm.business_status = 1 GROUP BY ccsc.id
        WHERE ccsc.is_del = 0 AND ccm.is_del = 0 AND ccm.community_id = #{communityId} AND ccm.business_status = 1 GROUP BY ccsc.id ORDER BY ccsc.weight desc
    </select>
</mapper>