Procházet zdrojové kódy

update:商品缺货搜索

liujunchi před 3 roky
rodič
revize
61709e3223

+ 6 - 0
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dao/PmsProductDao.java

@@ -1,9 +1,13 @@
 package com.yonge.cooleshow.admin.dao;
 
 import com.yonge.cooleshow.admin.dto.HomeStatistical;
+import com.yonge.cooleshow.admin.dto.PmsProductQueryParam;
 import com.yonge.cooleshow.admin.dto.PmsProductResult;
+import com.yonge.cooleshow.mbg.model.PmsProduct;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 
 /**
  * 商品管理自定义Dao
@@ -18,4 +22,6 @@ public interface PmsProductDao {
     HomeStatistical selectLowStockCount();
 
     HomeStatistical selectProductShowStatusCount();
+
+    List<PmsProduct> list(@Param("param") PmsProductQueryParam productQueryParam);
 }

+ 11 - 0
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/PmsProductQueryParam.java

@@ -21,6 +21,17 @@ public class PmsProductQueryParam {
     @ApiModelProperty("商品品牌编号")
     private Long brandId;
 
+    @ApiModelProperty("是否缺货 0:否,1;是")
+    private Integer stock;
+
+    public Integer getStock() {
+        return stock;
+    }
+
+    public void setStock(Integer stock) {
+        this.stock = stock;
+    }
+
     public Integer getPublishStatus() {
         return publishStatus;
     }

+ 14 - 5
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderServiceImpl.java

@@ -184,18 +184,27 @@ public class OmsOrderServiceImpl implements OmsOrderService {
 
     @Override
     public HomeStatistical countStatistical() {
-        HomeStatistical  homeStatistical = new HomeStatistical();
         // 订单状态
-        homeStatistical = orderDao.selectOrderStatusNum();
+        HomeStatistical homeStatistical = orderDao.selectOrderStatusNum();
 
         // 缺货登记   库存紧张
-        homeStatistical = productService.countLowStockCount();
+        HomeStatistical stock = productService.countLowStockCount();
+
+        homeStatistical.setOutStock(stock.getOutStock());
+        homeStatistical.setOutStockProduct(stock.getOutStockProduct());
 
         // 待处理退款申请  待处理退货订单
-        homeStatistical = orderReturnApplyService.countReturnStatus();
+        HomeStatistical returnInfo = orderReturnApplyService.countReturnStatus();
+
+        homeStatistical.setWaitDisposeRefund(returnInfo.getWaitDisposeRefund());
+        homeStatistical.setWaitDisposeRefundOrder(returnInfo.getWaitDisposeRefundOrder());
 
         // 已下架 已上架 全部商品
-        homeStatistical = productService.countProductShowStatus();
+        HomeStatistical product = productService.countProductShowStatus();
+
+        homeStatistical.setShelves(product.getShelves());
+        homeStatistical.setDelisted(product.getDelisted());
+        homeStatistical.setProductNum(product.getProductNum());
 
         Date endTime = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
         LocalDateTime localDateTime = LocalDateTime.now().plusDays(-1);

+ 3 - 22
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java

@@ -209,28 +209,9 @@ public class PmsProductServiceImpl implements PmsProductService {
     @Override
     public List<PmsProduct> list(PmsProductQueryParam productQueryParam, Integer pageSize, Integer pageNum) {
         PageHelper.startPage(pageNum, pageSize);
-        PmsProductExample productExample = new PmsProductExample();
-        PmsProductExample.Criteria criteria = productExample.createCriteria();
-        criteria.andDeleteStatusEqualTo(0);
-        if (productQueryParam.getPublishStatus() != null) {
-            criteria.andPublishStatusEqualTo(productQueryParam.getPublishStatus());
-        }
-        if (productQueryParam.getVerifyStatus() != null) {
-            criteria.andVerifyStatusEqualTo(productQueryParam.getVerifyStatus());
-        }
-        if (!StringUtils.isEmpty(productQueryParam.getKeyword())) {
-            criteria.andNameLike("%" + productQueryParam.getKeyword() + "%");
-        }
-        if (!StringUtils.isEmpty(productQueryParam.getProductSn())) {
-            criteria.andProductSnEqualTo(productQueryParam.getProductSn());
-        }
-        if (productQueryParam.getBrandId() != null) {
-            criteria.andBrandIdEqualTo(productQueryParam.getBrandId());
-        }
-        if (productQueryParam.getProductCategoryId() != null) {
-            criteria.andProductCategoryIdEqualTo(productQueryParam.getProductCategoryId());
-        }
-        return productMapper.selectByExample(productExample);
+
+        return productDao.list(productQueryParam);
+
     }
 
     @Override

+ 40 - 0
cooleshow-mall/mall-admin/src/main/resources/config/mybatis/PmsProductDao.xml

@@ -65,4 +65,44 @@
         from pms_product where delete_status = 0
 
     </select>
+
+    <select id="list" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductMapper.BaseResultMap">
+        select DISTINCT pp.*
+        from
+        pms_product  pp
+        <if test="param.stock  != null">
+            left join
+            (select DISTINCT pss.product_id
+            from  pms_sku_stock pss
+            where pss.stock &lt;= pss.low_stock) b
+            on b.product_id = pp.id
+        </if>
+
+        <where>
+            <if test="param.publishStatus != null">
+                and pp.publish_status = #{param.publishStatus}
+            </if>
+            <if test="param.verifyStatus != null">
+                and pp.verify_status = #{param.verifyStatus}
+            </if>
+            <if test="param.keyword != null">
+                and pp.name like concat('%',#{param.keyword},'%')
+            </if>
+            <if test="param.productSn != null">
+                and pp.product_sn = #{param.productSn}
+            </if>
+            <if test="param.brandId != null">
+                and pp.brand_id = #{param.brandId}
+            </if>
+            <if test="param.productCategoryId != null">
+                and pp.product_category_id = #{param.productCategoryId}
+            </if>
+            <if test="param.stock == 1">
+                and (pp.stock &lt;= pp.low_stock or b.product_id is not null)
+            </if>
+            <if test="param.stock == 0">
+                and (pp.stock &gt; pp.low_stock and b.product_id is null)
+            </if>
+        </where>
+    </select>
 </mapper>