Pārlūkot izejas kodu

fix 特定价格

zoujiajian 3 gadi atpakaļ
vecāks
revīzija
f2ad50e6c0

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

@@ -51,6 +51,12 @@ public class GoodsRecommendViews {
 	@DbField("g.virtual_sold")
 	private Integer virtualSold;
 
+	@DbField("g.specific_price")
+	private BigDecimal specificPrice;
+
+	@DbField("g.specific_goods_ids")
+	private String specificGoodsIds;
+
 	@DbIgnore
 	private Integer sold;
 }

+ 27 - 2
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -20,6 +20,7 @@ import com.cyksj.mapper.RegisterOrderDonMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
+import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.param.Operator;
@@ -33,6 +34,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 
 /**
  * @author chan
@@ -295,11 +297,34 @@ public class GoodsDonController {
      * 获取商品推荐平台
      */
     @GetMapping("/get/recommend/{id}")
-    public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
+    public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id, Boolean isLogin) throws Exception {
         String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
         Object value = redisService.get(key);
+        Long userId = null;
+        if (isLogin) {
+            userId = StpUserUtil.getLoginIdAsLong();
+        }
         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) {
+                        }
+                    }
+                }
+            }
             return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
         }
         if (value == null) {
@@ -311,7 +336,7 @@ public class GoodsDonController {
             if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
                 List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
                 List<GoodsRecommendViews> goodsRecommendViews = beanSearcher.searchAll(GoodsRecommendViews.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
-                goodsRecommendViews.forEach(data->{
+                goodsRecommendViews.forEach(data -> {
                     Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
                             .eq(RegisterOrderDon::getGoodsId, data.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
                     data.setSold(sold + data.getVirtualSold());