소스 검색

总商品库有的商品不允许重新添加,通过商品名称判断

Guos 3 주 전
부모
커밋
cf23a53ed9

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/IFsPlatformProductScrmMapper.java

@@ -70,4 +70,11 @@ public interface IFsPlatformProductScrmMapper {
      * @return 结果
      */
     int updateFsPlatformProduct(FsPlatformProductScrm product);
+
+    /**
+     * 商品名称是否存在
+     * @param productName
+     * @return
+     */
+    Boolean productNameExist(@Param("productName") String productName);
 }

+ 3 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -1323,13 +1323,14 @@ private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsS
         if(auditDTO.getIsAudit() == 1){
             //复制一份到平台商品库
             for(Long storeProductId : auditDTO.getProductIds()){
+                //原商品库
+                FsStoreProductScrm fsStoreProductScrm = fsStoreProductMapper.selectFsStoreProductById(storeProductId);
                 //存在的商品不用一直添加到总库
-                Boolean flag = iFsPlatformProductScrmMapper.selectByStoreProductId(storeProductId);
+                Boolean flag = iFsPlatformProductScrmMapper.productNameExist(fsStoreProductScrm.getProductName());
                 if(flag){
                     continue;
                 }
                 //复制商品
-                FsStoreProductScrm fsStoreProductScrm = fsStoreProductMapper.selectFsStoreProductById(storeProductId);
                 FsPlatformProductScrm fsPlatformProductScrm = new FsPlatformProductScrm();
                 BeanUtils.copyProperties(fsStoreProductScrm, fsPlatformProductScrm); //copy
 //                Long storeProductId = fsPlatformProductScrm.getProductId();//店铺商品id

+ 5 - 0
fs-service/src/main/resources/mapper/hisStore/FsPlatformProductScrmMapper.xml

@@ -296,6 +296,11 @@
             fs_platform_product_scrm p where p.store_product_id = #{storeProductId}
     </select>
 
+    <select id="productNameExist" resultType="java.lang.Boolean">
+        select count(product_id)
+        from fs_platform_product_scrm p where p.product_name = #{productName}
+    </select>
+
     <delete id="deleteFsPlatFormProductByIds">
         delete from fs_platform_product_scrm where product_id in
         <foreach item="productId" collection="array" open="(" separator="," close=")">