java110 5 gadi atpakaļ
vecāks
revīzija
89797724de

+ 29 - 12
java110-bean/src/main/java/com/java110/dto/productLabel/ProductLabelDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.productLabel;
 
-import com.java110.dto.PageDto;
+import com.java110.dto.product.ProductDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -12,12 +13,13 @@ import java.util.Date;
  * @Version 1.0
  * add by wuxw 2019/4/24
  **/
-public class ProductLabelDto extends PageDto implements Serializable {
+public class ProductLabelDto extends ProductDto implements Serializable {
 
     private String labelId;
-private String productId;
-private String storeId;
-private String labelCd;
+    private String productId;
+    private String storeId;
+    private String labelCd;
+    private String hasProduct;
 
 
     private Date createTime;
@@ -28,25 +30,32 @@ private String labelCd;
     public String getLabelId() {
         return labelId;
     }
-public void setLabelId(String labelId) {
+
+    public void setLabelId(String labelId) {
         this.labelId = labelId;
     }
-public String getProductId() {
+
+    public String getProductId() {
         return productId;
     }
-public void setProductId(String productId) {
+
+    public void setProductId(String productId) {
         this.productId = productId;
     }
-public String getStoreId() {
+
+    public String getStoreId() {
         return storeId;
     }
-public void setStoreId(String storeId) {
+
+    public void setStoreId(String storeId) {
         this.storeId = storeId;
     }
-public String getLabelCd() {
+
+    public String getLabelCd() {
         return labelCd;
     }
-public void setLabelCd(String labelCd) {
+
+    public void setLabelCd(String labelCd) {
         this.labelCd = labelCd;
     }
 
@@ -66,4 +75,12 @@ public void setLabelCd(String labelCd) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getHasProduct() {
+        return hasProduct;
+    }
+
+    public void setHasProduct(String hasProduct) {
+        this.hasProduct = hasProduct;
+    }
 }

+ 78 - 68
java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml

@@ -5,93 +5,103 @@
 <mapper namespace="productLabelServiceDaoImpl">
 
 
-
-
-
     <!-- 保存产品标签信息 add by wuxw 2018-07-03 -->
     <insert id="saveProductLabelInfo" parameterType="Map">
         insert into product_label(
-label_id,product_id,store_id,label_cd
-) values (
-#{labelId},#{productId},#{storeId},#{labelCd}
-)
+        label_id,product_id,store_id,label_cd
+        ) values (
+        #{labelId},#{productId},#{storeId},#{labelCd}
+        )
     </insert>
 
 
-
     <!-- 查询产品标签信息 add by wuxw 2018-07-03 -->
     <select id="getProductLabelInfo" parameterType="Map" resultType="Map">
-        select  t.label_id,t.label_id labelId,t.product_id,t.product_id productId,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.label_cd,t.label_cd labelCd 
-from product_label t 
-where 1 =1 
-<if test="labelId !=null and labelId != ''">
-   and t.label_id= #{labelId}
-</if> 
-<if test="productId !=null and productId != ''">
-   and t.product_id= #{productId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="storeId !=null and storeId != ''">
-   and t.store_id= #{storeId}
-</if> 
-<if test="labelCd !=null and labelCd != ''">
-   and t.label_cd= #{labelCd}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.label_id,t.label_id labelId,p.product_id productId,p.store_id storeId,t.label_cd,t.label_cd labelCd,
+        p.unit_name unitName,p.is_postage isPostage,p.sort,p.bar_code barCode,p.postage,p.prod_name prodName,
+        p.state,p.keyword,p.prod_desc prodDesc,p.category_id categoryId,pc.category_name categoryName,td.name stateName,
+        t.create_time createTime
+        from product p
+        left join product_category pc on pc.category_id = p.category_id and pc.store_id = p.store_id and pc.status_cd = '0'
+        left join t_dict td on p.state = td.status_cd and td.table_name= 'product' and td.table_columns = 'state'
+        left join product_label t on t.product_id = p.product_id and t.store_id = p.store_id and t.status_cd = '0'
+        where 1 =1
+        <if test="labelId !=null and labelId != ''">
+            and t.label_id= #{labelId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            and t.product_id= #{productId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
+        <if test="labelCd !=null and labelCd != ''">
+            and t.label_cd= #{labelCd}
+        </if>
+        <if test="hasProduct !=null and hasProduct == 'N'">
+            and p.product_id is null
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改产品标签信息 add by wuxw 2018-07-03 -->
     <update id="updateProductLabelInfo" parameterType="Map">
-        update  product_label t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="productId !=null and productId != ''">
-, t.product_id= #{productId}
-</if> 
-<if test="storeId !=null and storeId != ''">
-, t.store_id= #{storeId}
-</if> 
-<if test="labelCd !=null and labelCd != ''">
-, t.label_cd= #{labelCd}
-</if> 
- where 1=1 <if test="labelId !=null and labelId != ''">
-and t.label_id= #{labelId}
-</if> 
+        update product_label t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            , t.product_id= #{productId}
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            , t.store_id= #{storeId}
+        </if>
+        <if test="labelCd !=null and labelCd != ''">
+            , t.label_cd= #{labelCd}
+        </if>
+        where 1=1
+        <if test="labelId !=null and labelId != ''">
+            and t.label_id= #{labelId}
+        </if>
 
     </update>
 
     <!-- 查询产品标签数量 add by wuxw 2018-07-03 -->
-     <select id="queryProductLabelsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from product_label t 
-where 1 =1 
-<if test="labelId !=null and labelId != ''">
-   and t.label_id= #{labelId}
-</if> 
-<if test="productId !=null and productId != ''">
-   and t.product_id= #{productId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="storeId !=null and storeId != ''">
-   and t.store_id= #{storeId}
-</if> 
-<if test="labelCd !=null and labelCd != ''">
-   and t.label_cd= #{labelCd}
-</if> 
+    <select id="queryProductLabelsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from product p
+        left join product_category pc on pc.category_id = p.category_id and pc.store_id = p.store_id and pc.status_cd = '0'
+        left join t_dict td on p.state = td.status_cd and td.table_name= 'product' and td.table_columns = 'state'
+        left join product_label t on t.product_id = p.product_id and t.store_id = p.store_id and t.status_cd = '0'
+        where 1 =1
+        <if test="labelId !=null and labelId != ''">
+            and t.label_id= #{labelId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            and t.product_id= #{productId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
+        <if test="labelCd !=null and labelCd != ''">
+            and t.label_cd= #{labelCd}
+        </if>
+        <if test="hasProduct !=null and hasProduct == 'N'">
+            and p.product_id is null
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 3 - 0
service-goods/src/main/java/com/java110/goods/api/ProductApi.java

@@ -818,12 +818,15 @@ public class ProductApi {
      */
     @RequestMapping(value = "/queryProductLabel", method = RequestMethod.GET)
     public ResponseEntity<String> queryProductLabel(@RequestParam(value = "labelCd", required = false) String labelCd,
+                                                    @RequestParam(value = "hasProduct", required = false) String hasProduct,
                                                     @RequestParam(value = "page") int page,
                                                     @RequestParam(value = "row") int row) {
         ProductLabelDto productLabelDto = new ProductLabelDto();
         productLabelDto.setPage(page);
         productLabelDto.setRow(row);
         productLabelDto.setLabelCd(labelCd);
+        productLabelDto.setHasProduct(hasProduct);
         return getProductLabelBMOImpl.get(productLabelDto);
     }
+
 }

+ 84 - 0
service-goods/src/main/java/com/java110/goods/bmo/productLabel/impl/GetProductLabelBMOImpl.java

@@ -1,8 +1,16 @@
 package com.java110.goods.bmo.productLabel.impl;
 
+import com.java110.dto.file.FileRelDto;
+import com.java110.dto.product.ProductDto;
+import com.java110.dto.product.ProductSpecDetailDto;
+import com.java110.dto.productDetail.ProductDetailDto;
 import com.java110.dto.productLabel.ProductLabelDto;
+import com.java110.dto.productSpecValue.ProductSpecValueDto;
 import com.java110.goods.bmo.productLabel.IGetProductLabelBMO;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
 import com.java110.intf.goods.IProductLabelInnerServiceSMO;
+import com.java110.intf.goods.IProductSpecDetailInnerServiceSMO;
+import com.java110.intf.goods.IProductSpecValueInnerServiceSMO;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -18,6 +26,15 @@ public class GetProductLabelBMOImpl implements IGetProductLabelBMO {
     @Autowired
     private IProductLabelInnerServiceSMO productLabelInnerServiceSMOImpl;
 
+    @Autowired
+    private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
+
+    @Autowired
+    private IProductSpecValueInnerServiceSMO productSpecValueInnerServiceSMOImpl;
+
+    @Autowired
+    private IProductSpecDetailInnerServiceSMO productSpecDetailInnerServiceSMOImpl;
+
     /**
      * @param productLabelDto
      * @return 订单服务能够接受的报文
@@ -30,6 +47,7 @@ public class GetProductLabelBMOImpl implements IGetProductLabelBMO {
         List<ProductLabelDto> productLabelDtos = null;
         if (count > 0) {
             productLabelDtos = productLabelInnerServiceSMOImpl.queryProductLabels(productLabelDto);
+            freshProductDtos(productLabelDtos,productLabelDto);
         } else {
             productLabelDtos = new ArrayList<>();
         }
@@ -41,4 +59,70 @@ public class GetProductLabelBMOImpl implements IGetProductLabelBMO {
         return responseEntity;
     }
 
+
+    private void freshProductDtos(List<ProductLabelDto> productDtos, ProductDto productDto) {
+
+        if (productDtos == null || productDtos.size() < 1) {
+            return;
+        }
+
+        //输入
+        List<String> productIds = new ArrayList<>();
+
+        for (ProductDto tmpProductDto : productDtos) {
+            productIds.add(tmpProductDto.getProductId());
+        }
+
+        FileRelDto fileRelDto = new FileRelDto();
+        fileRelDto.setObjIds(productIds.toArray(new String[productIds.size()]));
+        fileRelDto.setRelTypeCd(FileRelDto.REL_TYPE_CD_GOODS_COVER);
+        List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
+
+        //刷入图片信息
+        List<String> photoVos = null;
+        String url = null;
+        for (ProductDto tmpProductDto : productDtos) {
+            for (FileRelDto tmpFileRelDto : fileRelDtos) {
+                if (tmpProductDto.getProductId().equals(tmpFileRelDto.getObjId())) {
+                    url = "/callComponent/download/getFile/file?fileId=" + tmpFileRelDto.getFileRealName() + "&communityId=-1";
+                    tmpProductDto.setCoverPhoto(url);
+                }
+            }
+        }
+        freshProductSpecValue(productDtos);
+
+    }
+
+    private void freshProductSpecValue(List<ProductLabelDto> productDtos) {
+        ProductSpecValueDto productSpecValueDto = new ProductSpecValueDto();
+        productSpecValueDto.setProductId(productDtos.get(0).getProductId());
+        productSpecValueDto.setStoreId(productDtos.get(0).getStoreId());
+        List<ProductSpecValueDto> productSpecValueDtos = productSpecValueInnerServiceSMOImpl.queryProductSpecValues(productSpecValueDto);
+
+        if (productSpecValueDtos == null || productSpecValueDtos.size() < 1) {
+            return;
+        }
+        productDtos.get(0).setProductSpecValues(productSpecValueDtos);
+
+        List<String> specIds = new ArrayList<>();
+        for (ProductSpecValueDto productSpecValue : productSpecValueDtos) {
+            specIds.add(productSpecValue.getSpecId());
+        }
+
+        ProductSpecDetailDto productSpecDetailDto = new ProductSpecDetailDto();
+        productSpecDetailDto.setSpecIds(specIds.toArray(new String[specIds.size()]));
+        productSpecDetailDto.setStoreId(productDtos.get(0).getStoreId());
+        List<ProductSpecDetailDto> productSpecDetailDtos = productSpecDetailInnerServiceSMOImpl.queryProductSpecDetails(productSpecDetailDto);
+        List<ProductSpecDetailDto> tmpProductSpecDetailDtos = null;
+        for (ProductSpecValueDto productSpecValue : productSpecValueDtos) {
+            tmpProductSpecDetailDtos = new ArrayList<>();
+            for (ProductSpecDetailDto tmpProductSpecDetailDto : productSpecDetailDtos) {
+                if (productSpecValue.getSpecId().equals(tmpProductSpecDetailDto.getSpecId())) {
+                    tmpProductSpecDetailDtos.add(tmpProductSpecDetailDto);
+                }
+            }
+            productSpecValue.setProductSpecDetails(tmpProductSpecDetailDtos);
+        }
+    }
+
 }