Bläddra i källkod

商品推荐2,bugfix

chao 3 år sedan
förälder
incheckning
d8f953571e

+ 7 - 4
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -540,6 +540,9 @@ public class PageServiceImpl implements PageService {
      */
     @Override
     public ResponseJson<List<ProductListVo>> getProductDetailRecommends(Integer productId, Integer recommendType, Integer userId) {
+        if (null == productId) {
+            return ResponseJson.error("商品Id不能为空!", null);
+        }
         // 根据用户Id查询用户身份
         Integer identity = 0;
         if (null != userId && userId > 0) {
@@ -547,11 +550,11 @@ public class PageServiceImpl implements PageService {
             if (null == identity){identity = 0;}
         }
         List<ProductListVo> list = null;
-        //相关推荐类型 0自动选择; 1手动推荐
-        if (1 == recommendType) {
-            list = pageMapper.getProductRecommendsById(productId);
-        } else {
+        //相关推荐类型 0自动选择(默认); 1手动推荐
+        if (null == recommendType || 1 != recommendType) {
             list = pageMapper.getAutoProductRecommends(productId);
+        } else {
+            list = pageMapper.getProductRecommendsById(productId);
         }
         if (null != list && list.size()>0) {
             // identity: 0个人,1协销,2会员机构,3供应商,4普通机构