zoujiajian 3 tahun lalu
induk
melakukan
20642b37f7

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

@@ -136,4 +136,10 @@ public class GoodsDonViews {
 
     @DbIgnore
     private GoodsDonSpecFrontView specs;
+
+    @DbIgnore
+    private BigDecimal skuSpecificPrice;
+
+    @DbIgnore
+    private Long specificSkuId;
 }

+ 2 - 3
netflix-dao/src/main/java/com/cyksj/model/views/GoodsFrontListView.java

@@ -1,7 +1,6 @@
 package com.cyksj.model.views;
 
 import com.cyksj.model.entity.GoodsDon;
-import com.cyksj.model.entity.GoodsDonSpec;
 import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
@@ -22,7 +21,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don g",
-		where = "g.deleted is true and g.status is true and g.type = 1",
+		where = "g.deleted is true and g.status is true",
 		orderBy = "g.sort_by desc, g.id")
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class GoodsFrontListView {
@@ -128,7 +127,7 @@ public class GoodsFrontListView {
 	private List<GoodsDonSkuFrontView> skuList;
 
 	@DbIgnore
-	private GoodsDonSpec specs;
+	private GoodsDonSpecFrontView specs;
 
 	@DbIgnore
 	private OrderCommentFrontView comments;

+ 106 - 1
netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementFrontView.java

@@ -1,12 +1,19 @@
 package com.cyksj.model.views;
 
+import com.cyksj.model.entity.GoodsDon;
+import com.cyksj.model.entity.GoodsDonSpec;
 import com.cyksj.model.entity.HomeManagementConfig;
 import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /*
  *项目名: netflix
  *文件名: HomeManagementFrontView
@@ -21,7 +28,7 @@ import lombok.Setter;
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class HomeManagementFrontView {
 	@DbField("hc.id")
-	private Long id;
+	private Long homeManageConfigId;
 
 	@DbField("hc.title")
 	private String title;
@@ -46,4 +53,102 @@ public class HomeManagementFrontView {
 
 	@DbField("hc.tag")
 	private String tag;
+
+	/**
+	 * 商品标签
+	 */
+	@DbField("g.tags")
+	private String goodsTags;
+
+	/**
+	 * 缩略图
+	 */
+	@DbField("g.logo")
+	private String goodsLogo;
+
+	/**
+	 * 背景图
+	 */
+	@DbField("g.img")
+	private String goodsImg;
+
+	/**
+	 * 类型
+	 */
+	@DbField("g.type")
+	private Integer goodsType;
+
+	/**
+	 * 分类
+	 * 1、AI  2、流媒体
+	 */
+	@DbField("g.category")
+	private Long category;
+
+	@DbField("g.second_type")
+	private Integer secondType;
+
+	@DbField("g.special_type")
+	private GoodsDon.SpecialType specialType;
+
+	/**
+	 * 最低规格价格
+	 */
+	@DbField("g.min_price")
+	private BigDecimal price;
+
+	/**
+	 * 最低规格月份
+	 */
+	@DbField("g.min_months")
+	private Integer months;
+
+	/**
+	 * 最低规格天数
+	 */
+	@DbField("g.min_days")
+	private Integer days;
+
+	/**
+	 * 已售
+	 */
+	@DbIgnore
+	private Integer sold;
+
+	/**
+	 * 虚拟销量
+	 */
+	@DbField("g.virtual_sold")
+	@JsonIgnore
+	private Integer virtualSold;
+
+	@DbIgnore
+	private BigDecimal specificPrice;
+
+	@DbIgnore
+	private Long specificSkuId;
+
+	@DbField("g.pay_desc")
+	private String payDesc;
+
+	/**
+	 * 是否是特定价格平台
+	 */
+	@DbField("g.is_sp")
+	private Boolean isSp;
+
+	/**
+	 * 购买通知信息
+	 */
+	@DbIgnore
+	private String notifyMsg;
+
+	@DbIgnore
+	private List<GoodsDonSkuFrontView> skuList;
+
+	@DbIgnore
+	private GoodsDonSpec specs;
+
+	@DbIgnore
+	private OrderCommentFrontView comments;
 }

+ 148 - 67
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -69,7 +69,7 @@ public class GoodsDonController {
      */
     @GetMapping("/get/category")
     public Result<List<GoodsDonCategoryFrontView>> getCategory() {
-        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category";
+        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category";
         Object o = redisService.get(key);
         List<GoodsDonCategoryFrontView> list;
         if (o == null) {
@@ -212,10 +212,11 @@ public class GoodsDonController {
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
             builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
         }
+        builder.field(GoodsFrontListView::getType, 1);
         List<GoodsFrontListView> list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
         DateTime now = DateTime.now();
         list.forEach(data -> {
-            data.setSpecs(beanSearcher.searchFirst(GoodsDonSpec.class, MapUtils.builder().field(GoodsDonSpec::getGoodsId, data.getId()).build()));
+            data.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, data.getId()).build()));
             data.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, MapUtils.builder().field(GoodsDonSkuFrontView::getGoodsId, data.getId()).field(GoodsDonSkuFrontView::getStatus, true).orderBy(GoodsDonSkuFrontView::getPrice).asc().build()));
             data.getSkuList().forEach(sku -> {
                 if (sku.getIsDp()) {
@@ -267,6 +268,7 @@ public class GoodsDonController {
         if (CollUtil.isNotEmpty(filter_goodsIds)) {
             builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
         }
+        builder.field(GoodsFrontListView::getType, 1);
         List<GoodsFrontListView> dataList = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
         DateTime now = DateTime.now();
         dataList.forEach(data -> {
@@ -315,9 +317,10 @@ public class GoodsDonController {
      * 获取商品详情
      */
     @GetMapping("/get/{id}")
-    public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
+    public Result<GoodsFrontListView> getDetail(@PathVariable Long id) {
         Long fUid = StpUserUtil.getUserIdAfterLogin();
-        GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
+        GoodsFrontListView views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsDonViews::getId, id)
+                .build());
 
         Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
                 .eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
@@ -346,6 +349,18 @@ public class GoodsDonController {
                 if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
                     sku.setSpecificGoodsIds(null);
                     sku.setSpecificPrice(null);
+                } else {
+                    BigDecimal specificPrice = views.getSpecificPrice();
+
+                    BigDecimal skuSpecificPrice = sku.getSpecificPrice();
+                    Long specificSkuId = sku.getId();
+                    if (specificPrice == null) {
+                        views.setSpecificPrice(skuSpecificPrice);
+                        views.setSpecificSkuId(specificSkuId);
+                    } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
+                        views.setSpecificPrice(skuSpecificPrice);
+                        views.setSpecificSkuId(specificSkuId);
+                    }
                 }
             }
         });
@@ -414,42 +429,6 @@ public class GoodsDonController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
 
-    /**
-     * 获取首页配置列表
-     */
-    @GetMapping("/get/homeManage")
-    public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage() {
-        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage";
-        Object o = redisService.get(key);
-        if (o == null) {
-            String condition = "g.deleted is true and g.status is true";
-            Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
-            Stream.of(HomeManagementConfig.Type.values())
-                    .forEach(type -> {
-                        MapBuilder builder = MapUtils.builder()
-                                .field(HomeManagementConfig::getType, type.name());
-                        if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
-                            builder.put("condition", condition);
-                        }
-                        List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
-                        map.putIfAbsent(type.name(), homeManagementFrontViews);
-                    });
-            redisService.setNx(key, map, 50 * 60l);
-            return GatewayResponse.SUCCESS.newBuilder().toResult(map);
-        }
-        return GatewayResponse.SUCCESS.newBuilder().toResult(Jsons.parseObject(o, Map.class));
-    }
-
-    /**
-     * 首页点击 记录
-     */
-    @PostMapping("/homePage/click")
-    public Result<String> homeManageClick(@RequestBody ClickRecordReq request) {
-        Long userId = StpUserUtil.getUserIdAfterLogin();
-        clickRecordFrontService.click(userId, request);
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
-
     public List<Long> getFilterGoodsIds() {
         //过滤杭州Ai ChatGPT平台
         //获取当前ip地址
@@ -521,47 +500,77 @@ public class GoodsDonController {
     }
 
     /**
-     * 是否购买过特定平台
+     * 获取首页配置列表
      */
-    public Boolean isPaySpecificGoodsIds(String specificGoodsIdsStr, Long userId) {
-        if (StrUtil.isNotBlank(specificGoodsIdsStr)) {
+    @GetMapping("/get/homeManage")
+    public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage() throws Exception {
+        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "homeManage";
+        Long fUid = StpUserUtil.getUserIdAfterLogin();
+        Object o = redisService.get(key);
+        if (o == null) {
+            String condition = "g.deleted is true and g.status is true";
+            Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
+            Stream.of(HomeManagementConfig.Type.values())
+                    .forEach(type -> {
+                        MapBuilder builder = MapUtils.builder()
+                                .field(HomeManagementConfig::getType, type.name());
+                        if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
+                            builder.put("condition", condition);
+                        }
+                        List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
+                        if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
+                            DateTime now = DateTime.now();
+                            homeManagementFrontViews.forEach(data -> {
+                                Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+                                        .eq(OrderDon::getGoodsId, data.getGoodsId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+                                data.setSold(sold + data.getVirtualSold());
+                                data.setNotifyMsg(getPayMsgTime(data.getGoodsId(), now, 1));
+                            });
+                        }
+                        map.putIfAbsent(type.name(), homeManagementFrontViews);
+                    });
+            redisService.setNx(key, map, 50 * 60l);
+            o = redisService.get(key);
+        }
+        Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
+        if (map.containsKey(HomeManagementConfig.Type.ex.name()) || map.containsKey(HomeManagementConfig.Type.vg.name())) {
             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;
+                //设置特定价格
+                List<HomeManagementFrontView> exList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.ex.name())), HomeManagementFrontView.class);
+                if (CollUtil.isNotEmpty(exList)) {
+                    setHomeManageSpecific(exList, fUid);
+                    map.put(HomeManagementConfig.Type.ex.name(), exList);
+                }
+                //设置特定价格
+                List<HomeManagementFrontView> vgList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.vg.name())), HomeManagementFrontView.class);
+                if (CollUtil.isNotEmpty(vgList)) {
+                    setHomeManageSpecific(vgList, fUid);
+                    map.put(HomeManagementConfig.Type.vg.name(), vgList);
                 }
-                return true;
             } catch (Exception e) {
             }
         }
-        return false;
+        return GatewayResponse.SUCCESS.newBuilder().toResult(map);
     }
 
+    /**
+     * 首页点击 记录
+     */
+    @PostMapping("/homePage/click")
+    public Result<String> homeManageClick(@RequestBody ClickRecordReq request) {
+        Long userId = StpUserUtil.getUserIdAfterLogin();
+        clickRecordFrontService.click(userId, request);
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
     /**
      * 设置平台 特定价格
      */
     public void setSpecificPrice(List<GoodsFrontListView> list, Long fUid) {
-        if (fUid != null) {
+        if (fUid != null && CollUtil.isNotEmpty(list)) {
             list.forEach(data -> {
                 if (data.getIsSp()) {
                     //查找所有特定规格最小价格 满足条件
-                    String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + data.getId();
-                    Object speciObj = redisService.get(specificGoodsKey);
-                    List<GoodsDonSku> specificSkus = null;
-                    if (speciObj != null) {
-                        specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
-                    } else {
-                        specificSkus = goodsDonSkuMapper.selectList(
-                                Wrappers.lambdaQuery(GoodsDonSku.class)
-                                        .eq(GoodsDonSku::getGoodsId, data.getId())
-                                        .eq(GoodsDonSku::getStatus, true)
-                                        .gt(GoodsDonSku::getSpecificPrice, 0));
-                        redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
-                    }
+                    List<GoodsDonSku> specificSkus = getSpecificSku(data.getId());
                     specificSkus.forEach(specificSku -> {
                         String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
                         if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
@@ -579,7 +588,7 @@ public class GoodsDonController {
                     });
                     List<GoodsDonSkuFrontView> skuList = data.getSkuList();
                     if (CollUtil.isNotEmpty(skuList)) {
-                        skuList.forEach(sku->{
+                        skuList.forEach(sku -> {
                             //设置特定价格
                             if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
                                 sku.setSpecificGoodsIds(null);
@@ -591,4 +600,76 @@ public class GoodsDonController {
             });
         }
     }
+
+    /**
+     * 是否购买过特定平台
+     */
+    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;
+    }
+
+    /**
+     * 获取特定规格
+     */
+    public List<GoodsDonSku> getSpecificSku(Long goodsId) {
+        //查找所有特定规格最小价格 满足条件
+        String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "specific:" + goodsId;
+        Object speciObj = redisService.get(specificGoodsKey);
+        List<GoodsDonSku> specificSkus = null;
+        if (speciObj != null) {
+            specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
+        } else {
+            specificSkus = goodsDonSkuMapper.selectList(
+                    Wrappers.lambdaQuery(GoodsDonSku.class)
+                            .eq(GoodsDonSku::getGoodsId, goodsId)
+                            .eq(GoodsDonSku::getStatus, true)
+                            .gt(GoodsDonSku::getSpecificPrice, 0));
+            redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
+        }
+        specificSkus = Optional.ofNullable(specificSkus).orElse(new ArrayList<>());
+        return specificSkus;
+    }
+
+    /**
+     * 设置首页配置 涉及平台特定价格
+     */
+    public void setHomeManageSpecific(List<HomeManagementFrontView> list, Long fUid) {
+        if (fUid != null && CollUtil.isNotEmpty(list)) {
+            list.forEach(data -> {
+                if (data.getIsSp() != null && data.getIsSp()) {
+                    //查找所有特定规格最小价格 满足条件
+                    List<GoodsDonSku> specificSkus = getSpecificSku(data.getGoodsId());
+                    specificSkus.forEach(specificSku -> {
+                        String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
+                        if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+                            BigDecimal specificPrice = data.getSpecificPrice();
+                            BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
+                            Long specificSkuId = specificSku.getId();
+                            if (specificPrice == null) {
+                                data.setSpecificPrice(skuSpecificPrice);
+                                data.setSpecificSkuId(specificSkuId);
+                            } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
+                                data.setSpecificPrice(skuSpecificPrice);
+                                data.setSpecificSkuId(specificSkuId);
+                            }
+                        }
+                    });
+                }
+            });
+        }
+    }
 }