ソースを参照

fix 特定价格展示

zoujiajian 3 年 前
コミット
ffae4b0a32

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsFrontListView.java

@@ -101,6 +101,12 @@ public class GoodsFrontListView {
 	@JsonIgnore
 	private Integer virtualSold;
 
+	@DbField("g.specific_price")
+	private BigDecimal specificPrice;
+
+	@DbField("g.specific_goods_ids")
+	private String specificGoodsIds;
+
 	/**
 	 * 购买通知信息
 	 */

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/GoodsHomePageView.java

@@ -96,6 +96,12 @@ public class GoodsHomePageView {
 	@DbField("g.pay_desc")
 	private String payDesc;
 
+	@DbField("g.specific_price")
+	private BigDecimal specificPrice;
+
+	@DbField("g.specific_goods_ids")
+	private String specificGoodsIds;
+
 	/**
 	 * 购买通知信息
 	 */

+ 82 - 20
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -15,8 +15,8 @@ import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.OrderDonMapper;
-import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.mapper.RegisterOrderDonMapper;
+import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
@@ -157,17 +157,31 @@ public class GoodsDonController {
      * 官网首页 平台列表
      */
     @GetMapping("/get/list")
-    public Result<List<GoodsFrontListView>> getGoodsList() {
+    public Result<List<GoodsFrontListView>> getGoodsList(Boolean isLogin) {
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
             pcCacheKey += ":hz-ip";
         }
+        Long userId = null;
+        if (isLogin != null && isLogin) {
+            userId = StpUserUtil.getLoginIdAsLong();
+        }
+        final Long fUid = userId;
         Object value = redisService.get(pcCacheKey);
         if (value != null) {
             try {
                 List<GoodsFrontListView> list = Jsons.parseObject(value, List.class);
                 if (CollUtil.isNotEmpty(list)) {
+                    if (fUid != null) {
+                        list.forEach(data -> {
+                            String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                            if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                                data.setSpecificGoodsIds(null);
+                                data.setSpecificPrice(null);
+                            }
+                        });
+                    }
                     return GatewayResponse.SUCCESS.newBuilder().toResult(list);
                 }
             } catch (Exception e) {
@@ -198,6 +212,13 @@ public class GoodsDonController {
                     .build());
             data.setComments(comments);
 	        data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
+            if (fUid != null) {
+                String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                    data.setSpecificGoodsIds(null);
+                    data.setSpecificPrice(null);
+                }
+            }
         });
         redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         return GatewayResponse.SUCCESS.newBuilder().toResult(list);
@@ -207,17 +228,31 @@ public class GoodsDonController {
      * h5 银河首页平台展示
      */
     @GetMapping("/get/homePage")
-    public Result<List<GoodsHomePageView>> getGoodsHomePage() {
+    public Result<List<GoodsHomePageView>> getGoodsHomePage(Boolean isLogin) {
         List<Long> filter_goodsIds = getFilterGoodsIds();
         String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
             h5CacheKey += ":hz-ip";
         }
+        Long userId = null;
+        if (isLogin != null && isLogin) {
+            userId = StpUserUtil.getLoginIdAsLong();
+        }
+        final Long fUid = userId;
         Object value = redisService.get(h5CacheKey);
         if (value != null) {
             try {
                 List<GoodsHomePageView> list = Jsons.parseObject(value, List.class);
                 if (CollUtil.isNotEmpty(list)) {
+                    if (fUid != null) {
+                        list.forEach(data -> {
+                            String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                            if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                                data.setSpecificGoodsIds(null);
+                                data.setSpecificPrice(null);
+                            }
+                        });
+                    }
                     return GatewayResponse.SUCCESS.newBuilder().toResult(list);
                 }
             } catch (Exception e) {
@@ -234,6 +269,14 @@ public class GoodsDonController {
                     .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
             data.setSold(sold + data.getVirtualSold());
             data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
+
+            if (fUid != null) {
+                String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                    data.setSpecificGoodsIds(null);
+                    data.setSpecificPrice(null);
+                }
+            }
         });
         redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
         return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
@@ -304,26 +347,17 @@ public class GoodsDonController {
         if (isLogin) {
             userId = StpUserUtil.getLoginIdAsLong();
         }
+        final Long fUid = userId;
         if (value != null) {
             List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
-            if (userId != null) {
-                for (GoodsRecommendViews goodsRecommendView : goodsRecommendViews) {
-                    String specificGoodsIdsStr = goodsRecommendView.getSpecificGoodsIds();
-                    if (StrUtil.isNotBlank(specificGoodsIdsStr)) {
-                        try {
-                            Set<Long> specificGoodsIds = Jsons.parseSet(specificGoodsIdsStr, Long.class);
-                            Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
-                                    .field(OrderDon::getUserId, userId)
-                                    .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
-                                    .build());
-                            if (number.intValue() == 0) {
-                                goodsRecommendView.setSpecificPrice(null);
-                                goodsRecommendView.setSpecificGoodsIds(null);
-                            }
-                        } catch (Exception e) {
-                        }
+            if (fUid != null) {
+                goodsRecommendViews.forEach(data -> {
+                    String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                    if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                        data.setSpecificGoodsIds(null);
+                        data.setSpecificPrice(null);
                     }
-                }
+                });
             }
             return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
         }
@@ -340,6 +374,13 @@ public class GoodsDonController {
                     Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
                             .eq(RegisterOrderDon::getGoodsId, data.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
                     data.setSold(sold + data.getVirtualSold());
+                    if (fUid != null) {
+                        String specificGoodsIdsStr = data.getSpecificGoodsIds();
+                        if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                            data.setSpecificGoodsIds(null);
+                            data.setSpecificPrice(null);
+                        }
+                    }
                 });
                 redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
                 return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
@@ -443,4 +484,25 @@ public class GoodsDonController {
 	    notifyMsg.append("前有人购买");
 	    return notifyMsg.toString();
     }
+
+    /**
+     * 是否购买过特定平台
+     */
+    public Boolean isPaySpecificGoodsIds(String specificGoodsIdsStr, Long userId) {
+        if (StrUtil.isNotBlank(specificGoodsIdsStr)) {
+            try {
+                Set<Long> specificGoodsIds = Jsons.parseSet(specificGoodsIdsStr, Long.class);
+                Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
+                        .field(OrderDon::getUserId, userId)
+                        .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
+                        .build());
+                if (number.intValue() == 0) {
+                    return false;
+                }
+                return true;
+            } catch (Exception e) {
+            }
+        }
+        return false;
+    }
 }