Ver Fonte

fix 店铺官网平台展示

zoujiajian há 2 anos atrás
pai
commit
485809a8fc

+ 2 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java

@@ -187,7 +187,8 @@ public class GoodsDon extends BaseEntity {
     @Getter
     public enum SpecialType {
         recharge("代充"),
-        courseware("课件")
+        courseware("课件"),
+        giftCard("礼品卡")
         ;
 
         private String desc;

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/YhShopGoodsSku.java

@@ -16,6 +16,8 @@ public class YhShopGoodsSku extends BaseEntity{
 
     private Long userId;
 
+    private Long yhsId;
+
     /**
      * 价格
      */

+ 15 - 1
netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopGoodsSkuServiceImpl.java

@@ -1,8 +1,12 @@
 package com.cyksj.service.shop.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.shop.YhShopGoodsSkuMapper;
+import com.cyksj.mapper.shop.YhShopMapper;
+import com.cyksj.model.entity.YhShop;
 import com.cyksj.model.entity.YhShopGoodsSku;
 import com.cyksj.service.shop.YhShopGoodsSkuService;
 import lombok.RequiredArgsConstructor;
@@ -19,10 +23,20 @@ import java.util.List;
 public class YhShopGoodsSkuServiceImpl extends ServiceImpl<YhShopGoodsSkuMapper, YhShopGoodsSku> implements YhShopGoodsSkuService {
 
     private final GoodsDonSkuMapper goodsDonSkuMapper;
+
+    private final YhShopMapper yhShopMapper;
     @Override
     public void saveGoods(List<Long> goodsIds, Long userId) {
+        YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+                .eq(YhShop::getUserId, userId).last("limit 1"));
+        if (yhShop == null) {
+            throw BusinessRuntimeException.getInstance("您的店铺不存在");
+        }
         List<YhShopGoodsSku> skuShops = goodsDonSkuMapper.selectSkuShops(goodsIds);
-        skuShops.forEach(skuShop->skuShop.setUserId(userId));
+        skuShops.forEach(skuShop->{
+            skuShop.setYhsId(yhShop.getId());
+            skuShop.setUserId(userId);
+        });
         this.saveOrUpdateBatch(skuShops);
     }
 }

+ 17 - 6
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -20,6 +20,7 @@ import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
+import com.cyksj.service.shop.YhShopFrontService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -61,6 +62,8 @@ public class GoodsDonController {
 
     private final SysConfigMapper sysConfigMapper;
 
+    private final YhShopFrontService yhShopFrontService;
+
     /**
      * 获取商品列表
      */
@@ -159,7 +162,11 @@ public class GoodsDonController {
      * 官网首页 平台列表
      */
     @GetMapping("/get/list")
-    public Result<List<GoodsFrontListView>> getGoodsList() {
+    public Result<Object> getGoodsList(String customId) {
+        if (StrUtil.isNotBlank(customId)) {
+            Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
+            return GatewayResponse.SUCCESS.newBuilder().toResult(shopGoods);
+        }
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
@@ -173,7 +180,7 @@ public class GoodsDonController {
                 if (CollUtil.isNotEmpty(list)) {
                     //设置特定价格
                     setSpecificPrice(list, fUid);
-                    return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+                    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.ofNullable(list));
                 }
             } catch (Exception e) {
             }
@@ -201,7 +208,7 @@ public class GoodsDonController {
         redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         //设置特定价格
         setSpecificPrice(list, fUid);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
     }
 
     /**
@@ -209,7 +216,11 @@ public class GoodsDonController {
      */
     @GetMapping("/get/homePage")
     @Deprecated
-    public Result<List<GoodsFrontListView>> getGoodsHomePage() {
+    public Result<Object> getGoodsHomePage(String customId) {
+        if (StrUtil.isNotBlank(customId)) {
+            Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
+            return GatewayResponse.SUCCESS.newBuilder().toResult(shopGoods);
+        }
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
@@ -223,7 +234,7 @@ public class GoodsDonController {
                 if (CollUtil.isNotEmpty(list)) {
                     //设置特定价格
                     setSpecificPrice(list, fUid);
-                    return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+                    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.ofNullable(list));
                 }
             } catch (Exception e) {
             }
@@ -243,7 +254,7 @@ public class GoodsDonController {
         redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         //设置特定价格
         setSpecificPrice(dataList, fUid);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(dataList));
     }
 
     /**