Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/developer' into developerL

kaick 1 rok pred
rodič
commit
bb9cb14bae

+ 26 - 0
src/main/java/com/caimei365/commodity/controller/ShopApi.java

@@ -1,14 +1,22 @@
 package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.PaginationVo;
 import com.caimei365.commodity.model.vo.ProductShoplVo;
 import com.caimei365.commodity.service.ShopOrderService;
+import com.caimei365.commodity.service.ShopService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -23,6 +31,8 @@ public class ShopApi {
 
     @Autowired private ShopOrderService shopOrderService;
 
+    @Resource private ShopService shopService;
+
     /**
      * 供应商商品数据
      * @param shopId
@@ -38,4 +48,20 @@ public class ShopApi {
         }
         return shopOrderService.getShopProductList(shopId, name, pageNum, pageSize);
     }
+
+    /**
+     * 供应商-主推商品
+     */
+    @ApiOperation("供应商主页--产品展示")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id"),
+            @ApiImplicitParam(required = false, name = "categoryId", value = "供应商商品分类Id")
+    })
+    @GetMapping("/getCategoryProducts")
+    public ResponseJson<List<ProductListVo>> getCategoryProducts(Integer shopId, Integer categoryId) {
+        if (null == shopId) {
+            return ResponseJson.error(-1, "供应商Id不能为空", null);
+        }
+        return shopService.getCategoryProducts(shopId, categoryId);
+    }
 }

+ 8 - 0
src/main/java/com/caimei365/commodity/mapper/ShopMapper.java

@@ -22,6 +22,14 @@ public interface ShopMapper {
      */
     List<ProductListVo> getMainProducts(Integer shopId, List<Integer> visibilityList);
 
+    /**
+     * 供应商分类商品
+     * @param shopId
+     * @param categoryId
+     * @return
+     */
+    List<ProductListVo> getCategoryProductList(@Param("shopId") Integer shopId,@Param("categoryId") Integer categoryId);
+
     /**
      * 上架费过期数量
      */

+ 7 - 0
src/main/java/com/caimei365/commodity/service/ShopService.java

@@ -30,6 +30,13 @@ public interface ShopService {
      */
     ResponseJson<List<ProductListVo>> getMainProducts(Integer shopId, Integer identity);
 
+    /**
+     * 供应商分类商品
+     * @param shopId
+     * @param categoryId
+     * @return
+     */
+    ResponseJson<List<ProductListVo>> getCategoryProducts(Integer shopId, Integer categoryId);
     /**
      * 供应商-我的商品列表
      *

+ 1 - 1
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -429,7 +429,7 @@ public class SearchProductServiceImpl implements SearchProductService {
         if (productList.size() > 0) {
             return ResponseJson.success(pageObj.toString());
         } else {
-            return ResponseJson.error("未查询到文档记录(数据库)", null);
+            return ResponseJson.error( 0,"未查询到文档记录(数据库)", null);
         }
     }
 

+ 17 - 0
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -88,6 +88,23 @@ public class ShopServiceImpl implements ShopService {
         return ResponseJson.success(list);
     }
 
+    /**
+     * 供应商分类商品
+     * @param shopId
+     * @param categoryId
+     * @return
+     */
+    @Override
+    public ResponseJson<List<ProductListVo>> getCategoryProducts(Integer shopId, Integer categoryId) {
+        List<ProductListVo> list = shopMapper.getCategoryProductList(shopId, categoryId);
+        // 设置价格等级 及 老图片路径
+        list.forEach(product -> {
+            product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
+            product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+        });
+        return ResponseJson.success(list);
+    }
+
     /**
      * 供应商-我的商品列表
      *

+ 3 - 1
src/main/java/com/caimei365/commodity/utils/AppletsLinkUtil.java

@@ -205,7 +205,7 @@ public class AppletsLinkUtil {
                 return 16;
             } else if (pattern29.matcher(link).find() || pattern30.matcher(link).find()) {
                 return 17;
-            } else if (pattern46.matcher(link).find() || pattern31.matcher(link).find()) {
+            } else if (pattern31.matcher(link).find()) {
                 return 18;
             } else if (pattern32.matcher(link).find()) {
                 return 19;
@@ -232,6 +232,8 @@ public class AppletsLinkUtil {
                 return 29;
             } else if (pattern47.matcher(link).find()) {
                 return 30;
+            }  else if (pattern46.matcher(link).find()) {
+                return 31;
             } else {
                 return -1;
             }

+ 1 - 1
src/main/resources/mapper/PageMapper.xml

@@ -501,7 +501,6 @@
             and crmEnabledStatus = 1
         </if>
         order by -sort desc,createDate desc
-        limit 8
     </select>
     <select id="getHelpPageTypes" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
         select c_helpPageTypeID   as id,
@@ -721,6 +720,7 @@
         select id
         from cm_product_archive
         where productId = #{productId}
+        order by addTime desc limit 1
     </select>
 
     <select id="findBeansHistoryByArchiveId" resultType="java.lang.Integer">

+ 28 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -478,6 +478,34 @@
         and copi.validFlag = 2 and p.featuredFlag=1
         order by p.productID desc limit 4
     </select>
+
+    <select id="getCategoryProductList" resultType="com.caimei365.commodity.model.search.ProductListVo">
+        SELECT
+            p.productId,
+            p.actStatus,
+            p.shopID AS shopId,
+            p.name AS NAME,
+            p.mainImage AS image,
+            (SELECT price FROM cm_sku WHERE productId=p.productID AND organizeId = 0 ORDER BY price ASC LIMIT 1) AS price,
+            (SELECT unit FROM cm_sku WHERE productId=p.productID AND organizeId = 0 ORDER BY price ASC LIMIT 1) AS unit,
+            p.priceFlag AS priceFlag,
+            IFNULL(p.visibility,3) AS visibility,
+            p.productType
+            <if test="categoryId != null">
+                ,cscp.categoryId
+            </if>
+        FROM product p
+                 LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productID AND copi.organizeId = 0
+        <if test="categoryId != null">
+                 LEFT JOIN cm_shop_category_product cscp ON p.productId = cscp.productId
+        </if>
+            WHERE copi.validFlag = 2 and p.shopId = #{shopId}
+              <if test="categoryId != null">
+                and cscp.delFlag = 0
+                AND cscp.categoryId = #{categoryId}
+              </if>
+    </select>
+
     <select id="getShopProductsSelect" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select DISTINCT
         p.productID as productId,