瀏覽代碼

平台多分类功能;分类兼容店铺功能

zoujiajian 2 年之前
父節點
當前提交
3d2a3d0489
共有 40 個文件被更改,包括 743 次插入449 次删除
  1. 21 0
      netflix-dao/src/main/java/com/cyksj/mapper/GoodsDonCategoryRelateMapper.java
  2. 10 1
      netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java
  3. 18 0
      netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDonCategoryRelate.java
  4. 5 0
      netflix-dao/src/main/java/com/cyksj/model/manage/request/ReqGoodsSpuInsert.java
  5. 3 4
      netflix-dao/src/main/java/com/cyksj/model/manage/views/GoodsDonViewer.java
  6. 2 1
      netflix-dao/src/main/java/com/cyksj/model/views/CpsUserDistributeDetailView.java
  7. 5 6
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryDetailView.java
  8. 5 2
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryFrontView.java
  9. 6 4
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryGoodsView.java
  10. 2 1
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryView.java
  11. 5 9
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonViews.java
  12. 8 16
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsFrontListView.java
  13. 0 7
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsHomePageView.java
  14. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/GoodsRecommendViews.java
  15. 5 3
      netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementAvailableGoodsView.java
  16. 1 16
      netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementFrontView.java
  17. 0 3
      netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java
  18. 7 2
      netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeRateView.java
  19. 2 8
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsFrontView.java
  20. 4 6
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsRateView.java
  21. 7 7
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsView.java
  22. 2 1
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeDetailView.java
  23. 9 4
      netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeRateView.java
  24. 19 0
      netflix-dao/src/main/resources/mapper/GoodsDonCategoryRelateMapper.xml
  25. 1 1
      netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml
  26. 27 13
      netflix-dao/src/main/resources/mapper/StatisticsExportMapper.xml
  27. 1 0
      netflix-service/src/main/java/com/cyksj/redis/RedisService.java
  28. 1 1
      netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardGoodsSkuServiceImpl.java
  29. 14 0
      netflix-service/src/main/java/com/cyksj/service/mange/GoodsDonCategoryService.java
  30. 69 0
      netflix-service/src/main/java/com/cyksj/service/mange/goods/GoodsDonCategoryServiceImpl.java
  31. 21 39
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
  32. 4 1
      netflix-web/src/main/java/com/cyksj/web/controller/cps/CpsBackLoginController.java
  33. 372 262
      netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java
  34. 1 1
      netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java
  35. 14 9
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonCategoryController.java
  36. 20 4
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java
  37. 4 4
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonSkuController.java
  38. 10 7
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopGoodsController.java
  39. 7 1
      netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopUserController.java
  40. 30 4
      netflix-web/src/main/java/com/cyksj/web/controller/manage/home/HomeManageConfigController.java

+ 21 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GoodsDonCategoryRelateMapper.java

@@ -0,0 +1,21 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.GoodsDonCategory;
+import com.cyksj.model.entity.GoodsDonCategoryRelate;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: GoodsDonCategoryRelateMapper
+ * 创建者: JavaZou
+ * 创建时间:2023/10/7 18:14
+ */
+public interface GoodsDonCategoryRelateMapper extends BaseMapper<GoodsDonCategoryRelate> {
+
+	List<GoodsDonCategory> getCateGoryViewByGoodsId(Long goodsId);
+
+	void saveBatchGoodsRelate(@Param("goodsId") Long goodsId, @Param("list") List<Long> categoryList);
+}

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

@@ -18,7 +18,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don",
-		where = ":condition:")
+        where = ":condition:")
 public class GoodsDon extends BaseEntity {
 
 
@@ -76,6 +76,10 @@ public class GoodsDon extends BaseEntity {
      */
     private Long category;
 
+    @DbIgnore
+    @TableField(exist = false)
+    private List<Long> categoryList;
+
     /**
      * 二级分类
      * 虚物品 1邀请制 2非邀请制
@@ -184,6 +188,11 @@ public class GoodsDon extends BaseEntity {
      */
     private Boolean isSp;
 
+    /**
+     * 是否参与分销 默认参与
+     */
+    private Boolean isDistribute;
+
     @AllArgsConstructor
     @Getter
     public enum SpecialType {

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDonCategoryRelate.java

@@ -0,0 +1,18 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: GoodsDonCategoryRelate
+ * 创建者: JavaZou
+ * 创建时间:2023/10/7 18:14
+ */
+@Getter
+@Setter
+public class GoodsDonCategoryRelate extends BaseEntity{
+	private Long goodsId;
+
+	private Long category;
+}

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/request/ReqGoodsSpuInsert.java

@@ -72,6 +72,11 @@ public class ReqGoodsSpuInsert {
      */
     private Long category;
 
+    /**
+     * 多分类
+     */
+    private List<Long> categoryList;
+
     /**
      *  轮播图
      */

+ 3 - 4
netflix-dao/src/main/java/com/cyksj/model/manage/views/GoodsDonViewer.java

@@ -107,11 +107,10 @@ public class GoodsDonViewer {
     private Integer type;
 
     /**
-     * 分类
-     * 1、AI  2、流媒体
+     * 平台分类展示
      */
-    @DbField("g.category")
-    private Long category;
+    @DbIgnore
+    private List<Long> categoryList;
 
     /**
      * banner

+ 2 - 1
netflix-dao/src/main/java/com/cyksj/model/views/CpsUserDistributeDetailView.java

@@ -5,6 +5,7 @@ import lombok.Setter;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /*
  *项目名: netflix
@@ -39,5 +40,5 @@ public class CpsUserDistributeDetailView {
 	/**
 	 * 各平台分销比例
 	 */
-	private List<UserDistributeRateView> rateViews;
+	private Map<String, List<UserDistributeRateView>> rateViews;
 }

+ 5 - 6
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryDetailView.java

@@ -15,7 +15,9 @@ import java.util.Date;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don g left join goods_don_category gc on gc.id = g.category")
+@SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category",
+		groupBy = "g.id,g.title,g.status,g.deleted,g.logo,g.type,g.sort_by,g.virtual_sold,g.created_time,g.update_time")
 public class GoodsDonCategoryDetailView {
 	@DbField("g.id")
 	private Long id;
@@ -41,15 +43,12 @@ public class GoodsDonCategoryDetailView {
 	@DbField("g.type")
 	private Integer type;
 
-	@DbField("g.category")
-	private Long category;
-
 	/**
 	 * 分类
 	 * 1、AI  2、流媒体
 	 */
-	@DbField("gc.name")
-	private String categoryTitle;
+	@DbField("group_concat(gc.name)")
+	private String categoryName;
 
 	/**
 	 * 排序

+ 5 - 2
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryFrontView.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.views;
 
+import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.SearchBean;
 import lombok.Getter;
 import lombok.Setter;
@@ -12,11 +13,13 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don_category"
-		, where = "status is true"
+@SearchBean(tables = "goods_don_category gc"
+		, where = "status is true :condition:"
 		, orderBy = "sorted asc")
 public class GoodsDonCategoryFrontView {
+	@DbField("gc.id")
 	private Long id;
 
+	@DbField("gc.name")
 	private String name;
 }

+ 6 - 4
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryGoodsView.java

@@ -14,15 +14,17 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don g",
-		where = "g.deleted is true")
+@SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category",
+		where = "g.deleted is true :category:",
+		groupBy = "g.id,g.title,g.status,g.sort_by")
 public class GoodsDonCategoryGoodsView {
 
 	@DbField("g.id")
 	private Long goodsId;
 
-	@DbField("g.category")
-	private Long category;
+	@DbField("group_concat(gc.name)")
+	private String categoryName;
 
 	@DbField("g.title")
 	private String title;

+ 2 - 1
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonCategoryView.java

@@ -16,7 +16,8 @@ import java.util.Date;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don_category gc left join goods_don g on g.category = gc.id and g.deleted is true",
+@SearchBean(tables = "goods_don_category gc left join goods_don_category_relate gcr on gcr.category = gc.id" +
+		" left join goods_don g on g.id = gcr.goods_id and g.deleted is true",
 		groupBy = "gc.id,gc.name,gc.sorted,gc.update_time")
 public class GoodsDonCategoryView {
 	@DbField("gc.id")

+ 5 - 9
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonViews.java

@@ -3,7 +3,6 @@ package com.cyksj.model.views;
 import com.cyksj.model.entity.GoodsDon;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -125,12 +124,6 @@ public class GoodsDonViews {
 
     private Boolean isSp;
 
-    @DbIgnore
-    private Integer sold;
-
-    @JsonIgnore
-    private Integer virtualSold;
-
     @DbIgnore
     private List<GoodsDonSkuFrontView> skuList;
 
@@ -138,11 +131,14 @@ public class GoodsDonViews {
     private GoodsDonSpecFrontView specs;
 
     @DbIgnore
-    private String giftCards;
+    private BigDecimal skuSpecificPrice;
+
+    @DbIgnore
+    private Long specificSkuId;
 
     @DbIgnore
     private List<GoodsSkuGiftCardView> giftCardsView;
 
     @DbIgnore
     private OrderCommentFrontView comments;
-}
+}

+ 8 - 16
netflix-dao/src/main/java/com/cyksj/model/views/GoodsFrontListView.java

@@ -4,7 +4,6 @@ import com.cyksj.model.entity.GoodsDon;
 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;
@@ -21,7 +20,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don g",
-		where = "g.deleted is true and g.status is true",
+		where = "g.deleted is true and g.status is true :condition:",
 		orderBy = "g.sort_by asc, g.id")
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class GoodsFrontListView {
@@ -52,12 +51,6 @@ public class GoodsFrontListView {
 	@DbField("g.img")
 	private String img;
 
-	/**
-	 * 类型
-	 */
-	@DbField("g.type")
-	private Integer type;
-
 	/**
 	 * 分类
 	 * 1、AI  2、流媒体
@@ -65,6 +58,12 @@ public class GoodsFrontListView {
 	@DbField("g.category")
 	private Long category;
 
+	/**
+	 * 类型
+	 */
+	@DbField("g.type")
+	private Integer type;
+
 	@DbField("g.second_type")
 	private Integer secondType;
 
@@ -92,15 +91,8 @@ public class GoodsFrontListView {
 	/**
 	 * 已售
 	 */
-	@DbIgnore
-	private Integer sold;
-
-	/**
-	 * 虚拟销量
-	 */
 	@DbField("g.virtual_sold")
-	@JsonIgnore
-	private Integer virtualSold;
+	private Integer sold;
 
 	@DbIgnore
 	private BigDecimal specificPrice;

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

@@ -53,13 +53,6 @@ public class GoodsHomePageView {
 	@DbField("g.type")
 	private Integer type;
 
-	/**
-	 * 分类
-	 * 1、AI  2、流媒体
-	 */
-	@DbField("g.category")
-	private Long category;
-
 	/**
 	 * 最低规格价格
 	 */

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

@@ -18,7 +18,7 @@ import java.math.BigDecimal;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don g",
-		where = "g.deleted is true and g.status is true")
+		where = "g.deleted is true and g.status is true :condition:")
 public class GoodsRecommendViews {
 	@DbField("g.id")
 	private Long goodsId;

+ 5 - 3
netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementAvailableGoodsView.java

@@ -13,14 +13,16 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don g left join (select * from home_management_config where :type: deleted is true) hc on hc.goods_id = g.id"
+@SearchBean(tables = "goods_don g left join (select * from home_management_config where :type: deleted is true) hc on hc.goods_id = g.id" +
+		" left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category"
 		, where = "g.deleted is true and hc.id is null")
 public class HomeManagementAvailableGoodsView {
 	@DbField("g.id")
 	private Long goodsId;
 
-	@DbField("g.category")
-	private Long category;
+	@DbField("group_concat(gc.name)")
+	private String categoryName;
 
 	@DbField("g.type")
 	private Long goodsType;

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

@@ -6,7 +6,6 @@ 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;
@@ -78,13 +77,6 @@ public class HomeManagementFrontView {
 	@DbField("g.type")
 	private Integer goodsType;
 
-	/**
-	 * 分类
-	 * 1、AI  2、流媒体
-	 */
-	@DbField("g.category")
-	private Long category;
-
 	@DbField("g.second_type")
 	private Integer secondType;
 
@@ -112,15 +104,8 @@ public class HomeManagementFrontView {
 	/**
 	 * 已售
 	 */
-	@DbIgnore
-	private Integer sold;
-
-	/**
-	 * 虚拟销量
-	 */
 	@DbField("g.virtual_sold")
-	@JsonIgnore
-	private Integer virtualSold;
+	private Integer sold;
 
 	@DbIgnore
 	private BigDecimal specificPrice;

+ 0 - 3
netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java

@@ -65,9 +65,6 @@ public class RenewalView {
     @DbField("g.img")
     private String img;
 
-    @DbField("g.category")
-    private Long category;
-
     @DbField("g.type")
     @JsonIgnore
     private Integer goodsType;

+ 7 - 2
netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeRateView.java

@@ -13,13 +13,18 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don g left join user_plat_distribute_rate upr on upr.goods_id = g.id :distribute_id:",
+@SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category" +
+		"left join user_plat_distribute_rate upr on upr.goods_id = g.id :distribute_id:",
 		where = "g.type = 1 and g.deleted is true and g.status is true and upr.rate > 0")
 public class UserDistributeRateView {
 
-	@DbField("g.category")
+	@DbField("gcr.category")
 	private Long category;
 
+	@DbField("gc.name")
+	private String categoryName;
+
 	@DbField("g.title")
 	private String title;
 

+ 2 - 8
netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsFrontView.java

@@ -21,7 +21,7 @@ import java.util.List;
 @Setter
 @SearchBean(tables = "(select ys.goods_id,min(ys.price) as price from yh_shop_goods_sku ys left join goods_don_sku sku on sku.id = ys.sku_id where sku.status is true and ys.status is true and ys.deleted is true :condition: group by ys.goods_id) yg" +
 		" inner join goods_don g on g.id = yg.goods_id",
-		where = "g.deleted is true and g.status is true",
+		where = "g.deleted is true and g.status is true and g.is_distribute is true",
 		orderBy = "g.sort_by asc, g.id")
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class YhShopGoodsFrontView {
@@ -92,14 +92,8 @@ public class YhShopGoodsFrontView {
 	/**
 	 * 已售
 	 */
-	@DbIgnore
-	private Integer sold;
-
-	/**
-	 * 虚拟销量
-	 */
 	@DbField("g.virtual_sold")
-	private Integer vs;
+	private Integer sold;
 
 	@DbIgnore
 	private BigDecimal specificPrice;

+ 4 - 6
netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsRateView.java

@@ -13,8 +13,9 @@ import java.util.List;
  * @date 2023/9/14 14:20
  */
 @Data
-@SearchBean(tables = "goods_don g left join goods_don_category gc on gc.id = g.category",
-        where = "g.type = 1 and g.status = true and g.deleted = true")
+@SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id left join goods_don_category gc on gc.id = gcr.category",
+		where = "g.type = 1 and g.status = true and g.deleted = true",
+		groupBy = "g.id,g.title")
 public class YhShopGoodsRateView {
     @DbField("g.id")
     private Long goodsId;
@@ -22,10 +23,7 @@ public class YhShopGoodsRateView {
     @DbField("g.title")
     private String title;
 
-    @DbField("g.category")
-    private Long category;
-
-    @DbField("gc.name")
+    @DbField("group_concat(gc.name)")
     private String categoryName;
 
     @DbIgnore

+ 7 - 7
netflix-dao/src/main/java/com/cyksj/model/views/YhShopGoodsView.java

@@ -16,8 +16,8 @@ import java.util.List;
 @Data
 @SearchBean(tables = "yh_shop_goods_sku ysgs left join goods_don g on g.id = ysgs.goods_id" +
         " left join goods_don_sku sku on sku.id = ysgs.sku_id",
-        where = "ysgs.deleted is true and g.status = true and g.deleted = true and sku.status is true"
-        , groupBy = "g.id,g.title,g.category,ysgs.status,ysgs.user_id,ysgs.created_time,ysgs.update_time")
+        where = "ysgs.deleted is true and g.status is true and g.deleted is true and sku.status is true and g.is_distribute is true"
+        , groupBy = "g.id,g.title,g.category,ysgs.status,ysgs.user_id")
 public class YhShopGoodsView {
     @DbField("g.id")
     private Long goodsId;
@@ -25,8 +25,8 @@ public class YhShopGoodsView {
     @DbField("g.title")
     private String title;
 
-    @DbField("g.category")
-    private Integer category;
+    @DbField("select group_concat(gc.name) from goods_don_category_relate gcr left join goods_don_category gc on gc.id = gcr.category where goods_id = g.id")
+    private String categoryName;
 
     @DbField("ysgs.status")
     private Boolean status;
@@ -37,17 +37,17 @@ public class YhShopGoodsView {
     @DbField("group_concat(sku.spec_val,cast((ysgs.price/100) as decimal(10,2)),'元')")
     private String skuDetail;
 
-    @DbField("ysgs.created_time")
+    @DbField("any_value(ysgs.created_time)")
     private Date createdTime;
 
-    @DbField("ysgs.update_time")
+    @DbField("any_value(ysgs.update_time)")
     private Date updateTime;
 
     @DbIgnore
     private List<YhShopGoodsSkuView> list;
 
     @Data
-    @SearchBean(tables = "goods_don_sku gs left join yh_shop_goods_rate ysgr on gs.id = ysgr.sku_id left join yh_shop_goods_sku ysgs on gs.id = ysgs.sku_id and ysgs.deleted is true :uid:",
+    @SearchBean(tables = "goods_don_sku gs inner join yh_shop_goods_rate ysgr on gs.id = ysgr.sku_id left join yh_shop_goods_sku ysgs on gs.id = ysgs.sku_id and ysgs.deleted is true :uid:",
             where = "gs.status = true",
             orderBy = "gs.months")
     public static class YhShopGoodsSkuView{

+ 2 - 1
netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeDetailView.java

@@ -5,6 +5,7 @@ import lombok.Setter;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /*
  *项目名: yhlxj
@@ -38,5 +39,5 @@ public class YhShopUserDistributeDetailView {
 	/**
 	 * 各平台分销比例
 	 */
-	private List<YhShopUserDistributeRateView> rateViews;
+	private Map<String, List<YhShopUserDistributeRateView>> rateViews;
 }

+ 9 - 4
netflix-dao/src/main/java/com/cyksj/model/views/YhShopUserDistributeRateView.java

@@ -13,13 +13,18 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don g left join yh_shop_user_plat_distribute_rate upr on upr.goods_id = g.id and upr.rate > 0 :uid:" +
+@SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
+		" left join goods_don_category gc on gc.id = gcr.category" +
+		" left join yh_shop_user_plat_distribute_rate upr on upr.goods_id = g.id and upr.rate > 0 :uid:" +
 		" left join yh_shop_general_goods_rate ygr on ygr.goods_id = g.id",
-		where = "g.type = 1 and g.deleted is true and g.status is true")
+		where = "g.type = 1 and g.deleted is true and g.status is true and g.is_distribute is true")
 public class YhShopUserDistributeRateView {
 
-	@DbField("g.category")
-	private Integer category;
+	@DbField("gcr.category")
+	private Long category;
+
+	@DbField("gc.name")
+	private String categoryName;
 
 	@DbField("g.title")
 	private String title;

+ 19 - 0
netflix-dao/src/main/resources/mapper/GoodsDonCategoryRelateMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.cyksj.mapper.GoodsDonCategoryRelateMapper">
+
+    <insert id="saveBatchGoodsRelate">
+        insert
+        ignore into goods_don_category_relate(`goods_id`,`category`,`created_time`,`update_time`)
+        values
+        <foreach collection="list" item="item" separator=",">
+            (#{goodsId},#{item},now(),now())
+        </foreach>
+    </insert>
+
+
+    <select id="getCateGoryViewByGoodsId" resultType="com.cyksj.model.entity.GoodsDonCategory">
+        select gc.* from goods_don_category gc left join goods_don_category_relate gcr on gcr.category = gc.id
+        where gcr.goods_id = #{goodsId}
+    </select>
+</mapper>

+ 1 - 1
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -211,7 +211,7 @@
         <if test="!isPayNf">
             and type = 1
         </if>
-        and deleted is true and status is true) s order by s.sorted desc,sort_by desc
+        and deleted is true and status is true) s order by s.sorted desc,sort_by asc
     </select>
 
     <select id="getOutSideGroupsTripsRelationByGoodsId" resultType="java.lang.Long">

+ 27 - 13
netflix-dao/src/main/resources/mapper/StatisticsExportMapper.xml

@@ -120,8 +120,8 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id
-                     from `goods_don`
+                    (select goods_id
+                     from `goods_don_category_relate`
                      where category = 2)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
@@ -139,8 +139,8 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id
-                     from `goods_don`
+                    (select goods_id
+                     from `goods_don_category_relate`
                      where category = 2)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
@@ -165,8 +165,8 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id
-                     from `goods_don`
+                    (select goods_id
+                     from `goods_don_category_relate`
                      where category = 2)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
@@ -184,7 +184,9 @@
                              and od.user_id = s.user_id
                              and od.created_time between #{thisMonth} and #{nextMonth}
                            order by od.created_time limit 1,1) s
-                     where s.goods_id in (select id from goods_don where category = 1))
+                     where s.goods_id in (select goods_id
+                                          from `goods_don_category_relate`
+                                          where category = 1))
     </select>
 
     <select id="getMonthAiNewNumOfUser" resultType="java.lang.Integer">
@@ -192,7 +194,9 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id from goods_don where category = 1)
+                    (select goods_id
+                     from `goods_don_category_relate`
+                     where category = 1)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
                   #{thisMonth} and #{nextMonth}) s
@@ -209,7 +213,9 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id from goods_don where category = 1)
+                    (select goods_id
+                     from `goods_don_category_relate`
+                     where category = 1)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
                   #{thisMonth} and #{nextMonth}) s
@@ -232,7 +238,9 @@
         from (select user_id, created_time
               from `order_don`
               where goods_id in
-                    (select id from goods_don where category = 1)
+                    (select goods_id
+                     from `goods_don_category_relate`
+                     where category = 1)
                 and status not in ('close', 'refund', 'noPayment')
                 and created_time BETWEEN
                   #{thisMonth} and #{nextMonth}) s
@@ -249,7 +257,9 @@
                              and od.user_id = s.user_id
                              and od.created_time between #{thisMonth} and #{nextMonth}
                            order by od.created_time limit 1,1) s
-                     where s.goods_id in (select id from goods_don where category = 2))
+                     where s.goods_id in (select goods_id
+                                          from `goods_don_category_relate`
+                                          where category = 2))
     </select>
 
     <select id="getMonthPrivateCorpNumOfUser" resultType="java.lang.Integer">
@@ -316,7 +326,9 @@
         select count(distinct o.user_id)
         from `order_don` o
                  left join goods_don g on g.id = o.goods_id
-        where g.category = 1
+        where g.id in (select goods_id
+                       from `goods_don_category_relate`
+                       where category = 1)
           and o.status not in ('close', 'noPayment', 'refund')
     </select>
 
@@ -328,7 +340,9 @@
         where o.goods_id = #{goodsId}
           and o.status not in ('close', 'noPayment', 'refund')
           and o2.status not in ('close', 'noPayment', 'refund')
-          and g.category = 1
+          and g.id in (select goods_id
+                       from `goods_don_category_relate`
+                       where category = 1)
     </select>
 
     <select id="getMonthAmountOfOrderByType" resultType="java.math.BigDecimal">

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -625,6 +625,7 @@ public class RedisService {
         PC_WEB_CACHE("pc_web_cache", "首页平台缓存", 10 * 60),
         H5_WEB_CACHE("h5_web_cache", "h5首页平台缓存", 10 * 60),
         YH_HOME_PAGHE_CACHE("yh_home_paghe_cache:", "银河首页缓存", 30 * 60),
+        YH_HOME_PAGHE_CACHE_SHOP("yh_home_paghe_cache:shop:", "银河首页店铺缓存", 40 * 60),
         REGISTER_HOME_PAGE_CACHE("register_home_page_cache:", "注册首页缓存", 10 * 60),
         CPS_BACK_LOGIN_KEY("cps_back_login:", "cps商务后台登录key", 3 * 60),
         CPS_AUTH_SUCCESS_KEY("cps_auth_success_key:%s", "cps后台微信授权", 60 * 10),

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/giftcard/impl/GiftCardGoodsSkuServiceImpl.java

@@ -118,7 +118,7 @@ public class GiftCardGoodsSkuServiceImpl extends ServiceImpl<GiftCardGoodsSkuMap
 			if (minPrice == null || min.getPrice().compareTo(minPrice) != 0) {
 				goodsDon.setMinPrice(min.getPrice());
 				goodsDonMapper.updateById(goodsDon);
-				Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+				Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
 				redisService.del(keys.toArray(String[]::new));
 			}
 		}

+ 14 - 0
netflix-service/src/main/java/com/cyksj/service/mange/GoodsDonCategoryService.java

@@ -3,6 +3,8 @@ package com.cyksj.service.mange;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.cyksj.model.entity.GoodsDonCategory;
 
+import java.util.List;
+
 /*
  *项目名: netflix
  *文件名: GoodsDonCategoryService
@@ -13,4 +15,16 @@ public interface GoodsDonCategoryService extends IService<GoodsDonCategory> {
 	void saveOrUpdateGoods(GoodsDonCategory category);
 
 	void delById(Long id);
+
+	List<GoodsDonCategory> getCateGoryViewByGoodsId(Long id);
+
+	/**
+	 * 批量保存分类关系
+	 */
+	void saveBatchRelate(Long goodsId, List<Long> categoryList);
+
+	/**
+	 * 平台分类关系处理
+	 */
+	void handleGoodsRelate(Long goodsId, List<Long> categoryList);
 }

+ 69 - 0
netflix-service/src/main/java/com/cyksj/service/mange/goods/GoodsDonCategoryServiceImpl.java

@@ -1,17 +1,25 @@
 package com.cyksj.service.mange.goods;
 
+import cn.hutool.core.collection.CollUtil;
 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.GoodsDonCategoryMapper;
+import com.cyksj.mapper.GoodsDonCategoryRelateMapper;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.GoodsDonCategory;
+import com.cyksj.model.entity.GoodsDonCategoryRelate;
 import com.cyksj.service.mange.GoodsDonCategoryService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 
+import java.util.Comparator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+
 /*
  *项目名: netflix
  *文件名: GoodsDonCategoryServiceImpl
@@ -23,6 +31,8 @@ import org.springframework.stereotype.Service;
 public class GoodsDonCategoryServiceImpl extends ServiceImpl<GoodsDonCategoryMapper, GoodsDonCategory> implements GoodsDonCategoryService {
 	private final GoodsDonMapper goodsDonMapper;
 
+	private final GoodsDonCategoryRelateMapper goodsDonCategoryRelateMapper;
+
 	@Override
 	public void saveOrUpdateGoods(GoodsDonCategory category) {
 		try {
@@ -42,4 +52,63 @@ public class GoodsDonCategoryServiceImpl extends ServiceImpl<GoodsDonCategoryMap
 		}
 		this.removeById(id);
 	}
+
+	@Override
+	public List<GoodsDonCategory> getCateGoryViewByGoodsId(Long goodsId) {
+		List<GoodsDonCategory> categoryList = goodsDonCategoryRelateMapper.getCateGoryViewByGoodsId(goodsId);
+		return categoryList;
+	}
+
+	@Override
+	public void saveBatchRelate(Long goodsId, List<Long> categoryList) {
+		//查询已有的分类
+		categoryList = this.list(Wrappers.lambdaQuery(GoodsDonCategory.class)
+				.in(GoodsDonCategory::getId, categoryList)).stream().map(GoodsDonCategory::getId).collect(Collectors.toList());
+		Long category;
+		if (CollUtil.isNotEmpty(categoryList)) {
+			if (categoryList.size() > 1) {
+				goodsDonCategoryRelateMapper.saveBatchGoodsRelate(goodsId, categoryList);
+				List<Long> sorted = categoryList.stream().sorted(Comparator.comparing((i) -> i)).collect(Collectors.toList());
+				category = sorted.get(0);
+			} else {
+				GoodsDonCategoryRelate goodsDonCategoryRelate = new GoodsDonCategoryRelate();
+				goodsDonCategoryRelate.setGoodsId(goodsId);
+				category = categoryList.get(0);
+				goodsDonCategoryRelate.setCategory(category);
+				goodsDonCategoryRelateMapper.insert(goodsDonCategoryRelate);
+			}
+			goodsDonMapper.update(null, Wrappers.lambdaUpdate(GoodsDon.class)
+					.set(GoodsDon::getCategory, category)
+					.eq(GoodsDon::getId, goodsId));
+		}
+	}
+
+	@Override
+	public void handleGoodsRelate(Long goodsId, List<Long> categoryList) {
+		if (CollUtil.isEmpty(categoryList)) {
+			goodsDonCategoryRelateMapper.delete(Wrappers.lambdaQuery(GoodsDonCategoryRelate.class).eq(GoodsDonCategoryRelate::getGoodsId, goodsId));
+			goodsDonMapper.update(null, Wrappers.lambdaUpdate(GoodsDon.class)
+					.set(GoodsDon::getCategory, 0)
+					.eq(GoodsDon::getId, goodsId));
+			return;
+		}
+		List<GoodsDonCategoryRelate> goodsDonCategoryRelates = goodsDonCategoryRelateMapper.selectList(Wrappers.lambdaQuery(GoodsDonCategoryRelate.class).eq(GoodsDonCategoryRelate::getGoodsId, goodsId));
+		if (goodsDonCategoryRelates.isEmpty()) {
+			saveBatchRelate(goodsId, categoryList);
+			return;
+		}
+		AtomicBoolean ic = new AtomicBoolean(true);
+		//需要删除
+		goodsDonCategoryRelates.forEach(data -> {
+			if (!categoryList.contains(data.getCategory())) {
+				goodsDonCategoryRelateMapper.deleteById(data.getId());
+				categoryList.remove(data.getCategory());
+				ic.set(false);
+			}
+		});
+		if (ic.get() && categoryList.size() == goodsDonCategoryRelates.size()) {
+			return;
+		}
+		saveBatchRelate(goodsId, categoryList);
+	}
 }

+ 21 - 39
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -273,6 +273,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		if (goodsDon == null || !goodsDon.getStatus()) {
 			throw new BusinessRuntimeException("商品已下架");
 		}
+		//是否参与店铺分销
+		if (yhsId > 0 && !goodsDon.getIsDistribute()) {
+			throw new BusinessRuntimeException("系统异常,请刷新页面重试");
+		}
 		if (isGiftCardPay.get() && (goodsDon.getSpecialType() == null || goodsDon.getSpecialType() != GoodsDon.SpecialType.giftCard)) {
 			throw BusinessRuntimeException.getInstance("非礼品卡类型商品");
 		}
@@ -755,7 +759,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						if (groupsRelation.getUserId() != 0) {
 							User user = userMapper.selectById(orderDon.getUserId());
 							if (user != null) {
-								checkIsSameUser(groupsRelation.getUserId(), orderDon.getUserId(), user.getOpenId(), user.getLoginPhone());
+								checkIsSameUser(groupsRelation.getUserId(), user);
 							}
 						}
 						//throw new BusinessRuntimeException("订单用户与车位用户不匹配!");
@@ -763,7 +767,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						if (GroupsRelation.Status.locking == groupsRelation.getStatus() || GroupsRelation.Status.outside == groupsRelation.getStatus()) {
 							log.info("清理用户userId:{}未支付订单", orderDon.getUserId());
 							groupsRelation.setUserId(0L);
-							if (GroupsRelation.Status.outside != groupsRelation.getStatus()) {
+							Long groupsId = groupsRelation.getGroupsId();
+							GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
+							if (groupsRelation.getNum() > groupsTrips.getNum()) {
+								groupsRelation.setStatus(GroupsRelation.Status.outside);
+							} else {
 								groupsRelation.setStatus(GroupsRelation.Status.none);
 							}
 							groupsRelation.setYhsId(0l);
@@ -841,7 +849,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 		//todo 多账号同一用户绑定 续费
 		if (!relation.getUserId().equals(user.getId())) {
-			checkIsSameUser(relation.getUserId(), userId, user.getOpenId(), user.getLoginPhone());
+			checkIsSameUser(relation.getUserId(), user);
 		}
 		GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
 		if (groupsTrips == null) {
@@ -1217,7 +1225,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
 			if (GroupsRelation.Status.locking.equals(relation.getStatus()) || GroupsRelation.Status.validity.equals(relation.getStatus()) || GroupsRelation.Status.outside.equals(relation.getStatus())) {
 				log.info("订单号orderNo:{}开始修改车位:{}状态", order.getOrderNo(), relation.getId());
-				if (relation.getStatus() != GroupsRelation.Status.outside) {
+				if (relation.getNum() > groupsTrips.getNum()) {
+					relation.setStatus(GroupsRelation.Status.outside);
+				} else {
 					relation.setStatus(GroupsRelation.Status.validity);
 				}
 				//续费后,下一次续费意愿状态为false
@@ -1368,6 +1378,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 					log.info("用户{}邀请{},产生分销订单分发积分记录入库", userDistributeShared.getSharedId(), order.getUserId());
 					distributeWaitingSendPoints.setSendStatus(DistributeWaitingSendPoints.Status.waiting);
 					distributeWaitingSendPoints.setSendTime(DateUtil.offsetDay(order.getPayTime(), 3));
+					distributeWaitingSendPoints.setRate(rate);
 					distributeWaitingSendPointsMapper.insert(distributeWaitingSendPoints);
 					//暂定虚物 商务可首单提成
 					if (businessId != null) {
@@ -1747,38 +1758,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		return orderDon.getStatus();
 	}
 
-	public void checkIsSameUser(Long relationUserId, Long userId, String openId, String loginPhone) {
-		//手机用户与微信用户
-		LambdaQueryWrapper<UserBindDetail> wrapper = Wrappers.lambdaQuery(UserBindDetail.class);
-		Boolean isPcUser = false;
-		if (StrUtil.isNotBlank(openId)) {
-			wrapper.eq(UserBindDetail::getUserId, userId);
-		} else {
-			isPcUser = true;
-			wrapper.eq(UserBindDetail::getPhone, loginPhone);
-		}
-		UserBindDetail userBindDetail = userBindDetailMapper.selectOne(wrapper.last("limit 1"));
-		if (userBindDetail == null) {
-			throw new BusinessRuntimeException("");
-		}
-		if (userBindDetail != null) {
-			if (isPcUser) {
-				if (!relationUserId.equals(userBindDetail.getUserId())) {
-					throw new BusinessRuntimeException("");
-				}
-			} else {
-				if (StrUtil.isEmpty(userBindDetail.getPhone())) {
-					throw new BusinessRuntimeException("");
-				}
-				User otherUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
-						.eq(User::getLoginPhone, userBindDetail.getPhone()).last("limit 1"));
-				if (otherUser == null) {
-					throw new BusinessRuntimeException("");
-				}
-				if (!relationUserId.equals(otherUser.getId())) {
-					throw new BusinessRuntimeException("");
-				}
-			}
+	public void checkIsSameUser(Long relationUserId, User renewUser) {
+		List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(renewUser.getId(), renewUser);
+		if (!relationUserIdList.contains(relationUserId)) {
+			throw BusinessRuntimeException.getInstance("");
 		}
 	}
 
@@ -1937,9 +1920,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		//锁定座位
 		setRelation(relation.getId(), relation.getGroupsId(), userId, sku.getGoodsId(), isLoginPopularize, relation.getStatus());
 		relation.setUserId(userId);
-		if (relation.getStatus() != GroupsRelation.Status.outside) {
-			relation.setStatus(GroupsRelation.Status.locking);
-		}
+		//重新置为锁定
+		relation.setStatus(GroupsRelation.Status.locking);
 		relation.setYhsId(yhsId);
 		groupsRelationMapper.updateById(relation);
 		redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relation.getId());

+ 4 - 1
netflix-web/src/main/java/com/cyksj/web/controller/cps/CpsBackLoginController.java

@@ -41,7 +41,9 @@ import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /*
  *项目名: netflix
@@ -190,7 +192,8 @@ public class CpsBackLoginController {
 				.orderBy(UserDistributeRateView::getRate).desc()
 				.build());
 		CpsUserDistributeDetailView detailView = new CpsUserDistributeDetailView();
-		detailView.setRateViews(rateViews);
+		Map<String, List<UserDistributeRateView>> collect = rateViews.stream().filter(ct -> StrUtil.isNotBlank(ct.getCategoryName())).collect(Collectors.groupingBy(UserDistributeRateView::getCategoryName));
+		detailView.setRateViews(collect);
 		detailView.setWMoney(BigDecimal.valueOf(wMoneyPoints.doubleValue()).divide(thresholdPoints, 2, RoundingMode.DOWN));
 		detailView.setReMoney(BigDecimal.valueOf(reMoneyPoints.doubleValue()).divide(thresholdPoints, 2, RoundingMode.DOWN));
 

+ 372 - 262
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
@@ -72,18 +73,30 @@ public class GoodsDonController {
      * 获取平台商品分类
      */
     @GetMapping("/get/category")
-    public Result<List<GoodsDonCategoryFrontView>> getCategory() {
-        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category";
-        Object o = redisService.get(key);
-        List<GoodsDonCategoryFrontView> list;
-        if (o == null) {
-            list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
-                    .build());
-            redisService.setNx(key, list, 30 * 60l);
-            o = redisService.get(key);
-        }
-        list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+    public Result<List<GoodsDonCategoryFrontView>> getCategory(String customId) {
+	    Long yhsId = null;
+	    if (StrUtil.isNotBlank(customId)) {
+		    yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
+	    }
+	    String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category";
+	    Object o = redisService.get(key);
+	    List<GoodsDonCategoryFrontView> list;
+	    MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
+	    String condition = " and (select count(*) from goods_don_category_relate gcr inner join goods_don g on g.id = gcr.goods_id %s where gcr.category = gc.id) > 0";
+	    if (yhsId != null) {
+		    condition = String.format(condition, String.format(" inner join yh_shop_goods_sku ys on ys.goods_id = g.id and ys.status is true and ys.deleted is true and g.is_distribute is true and yhs_id = %s", yhsId));
+	    } else {
+		    condition = String.format(condition, StrUtil.EMPTY);
+	    }
+	    mapBuilder.put("condition", condition);
+	    if (o == null) {
+		    list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, mapBuilder
+				    .build());
+		    redisService.setNx(key, list, 30 * 60l);
+		    o = redisService.get(key);
+	    }
+	    list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
+	    return GatewayResponse.SUCCESS.newBuilder().toResult(list);
     }
 
     /**
@@ -194,53 +207,42 @@ public class GoodsDonController {
      */
     @GetMapping("/get/list")
     public Result<? extends Object> getGoodsList(String customId) {
-        if (StrUtil.isNotBlank(customId)) {
-            Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
-            return shopGoods;
-        }
-        List<Long> filter_goodsIds = getFilterGoodsIds();
-        String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "PC";
-        if (CollUtil.isNotEmpty(filter_goodsIds)) {
-            pcCacheKey += ":hz-ip";
-        }
-        Long fUid = StpUserUtil.getUserIdAfterLogin();
-        Object value = redisService.get(pcCacheKey);
-        if (value != null) {
-            try {
-                List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
-                if (CollUtil.isNotEmpty(list)) {
-                    //设置特定价格
-                    setSpecificPrice(list, fUid);
-                    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.ofNullable(list));
-                }
-            } catch (Exception e) {
-            }
-        }
-        MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
-        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(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()) {
-//                    List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuViews = beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder().field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId()).build());
-//                    sku.setDpSkuViews(dpSkuViews);
-//                }
-//            });
-            Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
-                    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
-            data.setSold(sold + data.getVirtualSold());
-            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
-        });
-        redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
-        //设置特定价格
-        setSpecificPrice(list, fUid);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
+	    if (StrUtil.isNotBlank(customId)) {
+		    Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
+		    return shopGoods;
+	    }
+	    List<Long> filter_goodsIds = getFilterGoodsIds();
+	    String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "PC";
+	    if (CollUtil.isNotEmpty(filter_goodsIds)) {
+		    pcCacheKey += ":hz-ip";
+	    }
+	    Long fUid = StpUserUtil.getUserIdAfterLogin();
+	    Object o = redisService.get(pcCacheKey);
+	    List<GoodsFrontListView> list = null;
+	    if (o == null) {
+		    MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+		    if (CollUtil.isNotEmpty(filter_goodsIds)) {
+			    builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
+		    }
+		    builder.field(GoodsFrontListView::getType, 1);
+		    list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
+		    redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
+		    o = redisService.get(pcCacheKey);
+	    }
+	    if (list == null) {
+		    list = Jsons.parseList(o, GoodsFrontListView.class);
+	    }
+	    DateTime now = DateTime.now();
+	    list.forEach(data -> {
+		    Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+				    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+		    data.setSold(sold + data.getSold());
+		    data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
+
+		    //设置特定价格
+		    setSpecificPrice(data, fUid);
+	    });
+	    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
     }
 
     /**
@@ -249,44 +251,42 @@ public class GoodsDonController {
     @GetMapping("/get/homePage")
     @Deprecated
     public Result<? extends Object> getGoodsHomePage(String customId) {
-        if (StrUtil.isNotBlank(customId)) {
-            Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
-            return shopGoods;
-        }
-        List<Long> filter_goodsIds = getFilterGoodsIds();
-        String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "H5";
-        if (CollUtil.isNotEmpty(filter_goodsIds)) {
-            h5CacheKey += ":hz-ip";
-        }
-        Long fUid = StpUserUtil.getUserIdAfterLogin();
-        Object value = redisService.get(h5CacheKey);
-        if (value != null) {
-            try {
-                List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
-                if (CollUtil.isNotEmpty(list)) {
-                    //设置特定价格
-                    setSpecificPrice(list, fUid);
-                    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.ofNullable(list));
-                }
-            } catch (Exception e) {
-            }
-        }
-        MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
-        if (CollUtil.isNotEmpty(filter_goodsIds)) {
-            builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
-        }
-        List<GoodsFrontListView> dataList = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
-        DateTime now = DateTime.now();
-        dataList.forEach(data -> {
-            Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
-                    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
-            data.setSold(sold + data.getVirtualSold());
-            data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
-        });
-        redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
-        //设置特定价格
-        setSpecificPrice(dataList, fUid);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(dataList));
+	    if (StrUtil.isNotBlank(customId)) {
+		    Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
+		    return shopGoods;
+	    }
+	    List<Long> filter_goodsIds = getFilterGoodsIds();
+	    String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "H5";
+	    if (CollUtil.isNotEmpty(filter_goodsIds)) {
+		    h5CacheKey += ":hz-ip";
+	    }
+	    Long fUid = StpUserUtil.getUserIdAfterLogin();
+	    Object o = redisService.get(h5CacheKey);
+	    List<GoodsFrontListView> list = null;
+	    if (o == null) {
+		    MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+		    if (CollUtil.isNotEmpty(filter_goodsIds)) {
+			    builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
+		    }
+		    list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
+		    redisService.setNx(h5CacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
+		    o = redisService.get(h5CacheKey);
+	    }
+	    if (list == null) {
+		    list = Jsons.parseList(o, GoodsFrontListView.class);
+	    }
+
+	    DateTime now = DateTime.now();
+	    list.forEach(data -> {
+		    Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+				    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+		    data.setSold(sold + data.getSold());
+		    data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
+
+		    //设置特定价格
+		    setSpecificPrice(data, fUid);
+	    });
+	    return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
     }
 
     /**
@@ -319,100 +319,124 @@ public class GoodsDonController {
     }
 
 
-    /**
-     * 获取商品详情
-     */
-    @GetMapping("/get/{id}")
-    public Result<? extends Object> getDetail(@PathVariable Long id, String customId) {
-        if (StrUtil.isNotBlank(customId) && id != 15) {
-            Result<YhShopGoodsFrontView> yhShopGoodsDetail = getGoodsDetailByYhsId(yhShopFrontService.getYhsIdByCustomId(customId), id);
-            return yhShopGoodsDetail;
-        }
-        Long fUid = StpUserUtil.getUserIdAfterLogin();
-        GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
+	/**
+	 * 获取商品详情
+	 */
+	@GetMapping("/get/{id}")
+	public Result<? extends Object> getDetail(@PathVariable Long id, String customId) {
+		if (StrUtil.isNotBlank(customId) && id != 15) {
+			Result<YhShopGoodsFrontView> yhShopGoodsDetail = getGoodsDetailByYhsId(yhShopFrontService.getYhsIdByCustomId(customId), id);
+			return yhShopGoodsDetail;
+		}
+		String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "goods_detail:" + id;
+		Object o = redisService.get(goodsDetailKey);
+		GoodsFrontListView views = null;
+		if (o == null) {
+			views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsFrontListView::getId, id)
+					.build());
 
-        views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
-        MapBuilder builder = MapUtils.builder().field(GoodsDonSku::getGoodsId, views.getId()).field(GoodsDonSku::getStatus, true);
+			views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
+			MapBuilder builder = MapUtils.builder().field(GoodsDonSku::getGoodsId, views.getId()).field(GoodsDonSku::getStatus, true);
 
-        if (views.getType() == 1) {
-            builder.orderBy(GoodsDonSku::getOrderBy).asc();
-        }
-        views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
-        views.getSkuList().forEach(sku -> {
-            if (sku.getIsDp()) {
-                sku.setDpSkuViews(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder()
-                        .field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
-                        .build()));
-            }
-	        if (views.getIsSp()) {
-		        if (fUid == null) {
-			        sku.setSpecificPrice(null);
-			        sku.setSpecificGoodsIds(null);
-			        return;
-		        }
-		        //设置特定价格
-		        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);
-			        }
-		        }
-	        }
-        });
-        //评论
+			if (views.getType() == 1) {
+				builder.orderBy(GoodsDonSku::getOrderBy).asc();
+			}
+			views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
+			redisService.setNx(goodsDetailKey, views, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
+			o = redisService.get(goodsDetailKey);
+		}
+		Long fUid = StpUserUtil.getUserIdAfterLogin();
+		if (views == null) {
+			views = Jsons.parseObject(o, GoodsFrontListView.class);
+		}
+		for (GoodsDonSkuFrontView sku : views.getSkuList()) {
+			if (sku.getIsDp()) {
+				sku.setDpSkuViews(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder()
+						.field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
+						.build()));
+			}
+			if (views.getIsSp()) {
+				if (fUid == null) {
+					sku.setSpecificPrice(null);
+					sku.setSpecificGoodsIds(null);
+					continue;
+				}
+				//设置特定价格
+				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);
+					}
+				}
+			}
+		}
+		Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+				.eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+		views.setSold(sold + views.getSold());
+		//评论
 //        OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
 //                .field(OrderCommentFrontView::getGoodsId, views.getId())
 //                .orderBy(OrderCommentFrontView::getCommentTime).desc()
 //                .orderBy(OrderCommentFrontView::getId).desc()
 //                .build());
 //        views.setComments(comments);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(views);
-    }
+		return GatewayResponse.SUCCESS.newBuilder().toResult(views);
+	}
 
     /**
      * 获取商品推荐平台
      */
     @GetMapping("/get/recommend/{id}")
-    public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
-        String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "recommend:" + id;
-        Object value = redisService.get(key);
-        Long fUid = StpUserUtil.getUserIdAfterLogin();
-        if (value != null) {
-            List<GoodsFrontListView> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsFrontListView.class);
-            setSpecificPrice(goodsRecommendViews, fUid);
-            return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
-        }
-        if (value == null) {
-            GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
-                    .field(GoodsDon::getId, id)
-                    .field(GoodsDon::getStatus, true)
-                    .field(GoodsDon::getDeleted, true)
-                    .build());
-            if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
-                List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
-                List<GoodsFrontListView> goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
-                goodsRecommendViews.forEach(data -> {
-                    Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
-                            .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
-                    data.setSold(sold + data.getVirtualSold());
-                });
-                redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
-                //设置特定价格
-                setSpecificPrice(goodsRecommendViews, fUid);
-                return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
-            }
-        }
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id, String customId) throws Exception {
+	    String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "recommend:" + id;
+	    Long yhsId = null;
+	    if (StrUtil.isNotBlank(customId)) {
+		    yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
+		    key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":recommend:" + id;
+	    }
+	    Object o = redisService.get(key);
+	    Long fUid = StpUserUtil.getUserIdAfterLogin();
+	    List<GoodsFrontListView> goodsRecommendViews = null;
+	    if (o == null) {
+		    GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
+				    .field(GoodsDon::getId, id).field(GoodsDon::getStatus, true)
+				    .field(GoodsDon::getDeleted, true)
+				    .build());
+		    if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
+			    List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
+			    MapBuilder mapBuilder = MapUtils.builder();
+			    if (yhsId != null) {
+				    mapBuilder.put("condition", String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId));
+			    }
+			    mapBuilder.field(GoodsFrontListView::getId, recommend_gidList).op(Operator.InList);
+			    goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, mapBuilder.build());
+			    redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
+			    o = redisService.get(key);
+		    } else {
+			    return GatewayResponse.SUCCESS.newBuilder().toResult();
+		    }
+	    }
+	    if (goodsRecommendViews == null) {
+		    goodsRecommendViews = Jsons.parseList(o.toString(), GoodsFrontListView.class);
+	    }
+	    goodsRecommendViews.forEach(data -> {
+		    Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+				    .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+			data.setSold(data.getSold() + sold);
+		    //设置特定价格
+		    setSpecificPrice(data, fUid);
+	    });
+	    return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
     }
 
     /**
@@ -455,30 +479,30 @@ public class GoodsDonController {
 	 * 获取首页配置列表
 	 */
 	@GetMapping("/get/homeManage")
-	public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage() {
-		String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage";
+	public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId) {
+		String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "homeManage";
+		Long yhsId = null;
+		if (StrUtil.isNotBlank(customId)) {
+			yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
+			key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":homeManage";
+		}
 		Long fUid = StpUserUtil.getUserIdAfterLogin();
 		Object o = redisService.get(key);
 		if (o == null) {
 			String condition = "g.deleted is true and g.status is true";
+			if (yhsId != null) {
+				condition += String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId);
+			}
 			Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
+			final String conditionSql = condition;
 			Stream.of(HomeManagementConfig.Type.values())
 					.forEach(type -> {
 						MapBuilder builder = MapUtils.builder()
-								.field(HomeManagementConfig::getType, type.name());
+								.field(HomeManagementFrontView::getType, type.name());
 						if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
-							builder.put("condition", condition);
+							builder.put("condition", conditionSql);
 						}
 						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);
@@ -610,81 +634,104 @@ public class GoodsDonController {
     /**
      * 设置平台 特定价格
      */
-    public void setSpecificPrice(List<GoodsFrontListView> list, Long fUid) {
-        if (fUid != null) {
-            list.forEach(data -> {
-                if (data.getIsSp()) {
-                    //查找所有特定规格最小价格 满足条件
-                    String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "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());
-                    }
-                    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);
-                            }
-                        }
-                    });
-                    List<GoodsDonSkuFrontView> skuList = data.getSkuList();
-                    if (CollUtil.isNotEmpty(skuList)) {
-                        skuList.forEach(sku->{
-                            //设置特定价格
-                            if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
-                                sku.setSpecificGoodsIds(null);
-                                sku.setSpecificPrice(null);
-                            }
-                        });
-                    }
-                }
-            });
-        }
+    public void setSpecificPrice(GoodsFrontListView data, Long fUid) {
+	    if (fUid != null) {
+		    if (data.getIsSp()) {
+			    //查找所有特定规格最小价格 满足条件
+			    String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "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());
+			    }
+			    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);
+					    }
+				    }
+			    });
+			    List<GoodsDonSkuFrontView> skuList = data.getSkuList();
+			    if (CollUtil.isNotEmpty(skuList)) {
+				    skuList.forEach(sku -> {
+					    //设置特定价格
+					    if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
+						    sku.setSpecificGoodsIds(null);
+						    sku.setSpecificPrice(null);
+					    }
+				    });
+			    }
+		    }
+	    }
     }
 
+	/**
+	 * 获取特定规格
+	 */
+	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);
-							}
+		DateTime now = DateTime.now();
+		list.forEach(data -> {
+			if (data.getIsSp() != null && data.getIsSp() && fUid != null) {
+				//查找所有特定规格最小价格 满足条件
+				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);
 						}
-					});
-				}
-			});
-		}
+					}
+				});
+			}
+			Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+					.eq(OrderDon::getGoodsId, data.getGoodsId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+			data.setSold(sold + data.getSold());
+			data.setNotifyMsg(getPayMsgTime(data.getGoodsId(), now, 1, null));
+		});
 	}
 
     /**
@@ -692,7 +739,7 @@ public class GoodsDonController {
      */
     @GetMapping("/get/shop/goods/{yhsId}")
     public Result<List<YhShopGoodsFrontView>> getShopGoods(@PathVariable Long yhsId) {
-        String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhsId;
+        String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId;
         Object value = redisService.get(yhShopCacheKey);
         List<YhShopGoodsFrontView> list = null;
         if (value != null) {
@@ -710,9 +757,8 @@ public class GoodsDonController {
         DateTime now = DateTime.now();
         list.forEach(data->{
             Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
-                    .eq(OrderDon::getYhsId, yhsId)
                     .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
-            data.setSold(sold + data.getVs());
+            data.setSold(sold + data.getSold());
             data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
         });
         return GatewayResponse.SUCCESS.newBuilder().toResult(list);
@@ -740,4 +786,68 @@ public class GoodsDonController {
         goodsDetailView.setComments(comments);
         return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDetailView);
     }
+
+	/**
+	 * 根据分类获取对应平台
+	 */
+	@GetMapping("/get/categoryGoods")
+	public Result<? extends Object> getGoodsByCategory(Long cgy, String customId) {
+		if (StrUtil.isNotBlank(customId)) {
+			Result<List<YhShopGoodsFrontView>> shopGoods = getShopCategoryGoods(yhShopFrontService.getYhsIdByCustomId(customId), cgy);
+			return shopGoods;
+		}
+		String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category:goods";
+		if (cgy != null) {
+			categoryGoodsKey += ":" + cgy;
+		}
+		Object o = redisService.get(categoryGoodsKey);
+		if (o == null) {
+			MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
+			if (cgy != null) {
+				String condition = String.format(" and id in (select goods_id from goods_don_category_relate where category = %s)", cgy);
+				mapBuilder.put("condition", condition);
+			}
+			List<GoodsFrontListView> goodsFrontListViews = beanSearcher.searchAll(GoodsFrontListView.class, mapBuilder.build());
+			redisService.setNx(categoryGoodsKey, goodsFrontListViews, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 10 * 60);
+			o = redisService.get(categoryGoodsKey);
+		}
+		List<GoodsFrontListView> goodsFrontListViews = Jsons.parseList(o, GoodsFrontListView.class);
+		DateTime now = DateTime.now();
+		goodsFrontListViews.forEach(data -> {
+			Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+					.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+			data.setSold(sold + data.getSold());
+			data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
+		});
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
+	}
+
+	@GetMapping("/get/shop/categoryGoods/{yhsId}")
+	public Result<List<YhShopGoodsFrontView>> getShopCategoryGoods(@PathVariable Long yhsId, Long category) {
+		String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":category";
+		if (category != null) {
+			categoryGoodsKey += ":" + category;
+		}
+		Object value = redisService.get(categoryGoodsKey);
+		if (value == null) {
+			MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+			String condition = String.format("and yhs_id = %s", yhsId);
+			if (category != null) {
+				condition += String.format(" and ys.goods_id in (select goods_id from goods_don_category_relate where category = %s)", category);
+			}
+			builder.put("condition", condition);
+			List<YhShopGoodsFrontView> list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
+			redisService.setNx(categoryGoodsKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 5 * 60);
+			value = redisService.get(categoryGoodsKey);
+		}
+		List<YhShopGoodsFrontView> list = Jsons.parseList(value, YhShopGoodsFrontView.class);
+		DateTime now = DateTime.now();
+		list.forEach(data -> {
+			Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+					.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
+			data.setSold(sold + data.getSold());
+			data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
+		});
+		return GatewayResponse.SUCCESS.newBuilder().toResult(list);
+	}
 }

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -525,7 +525,7 @@ public class GroupRelationController {
                 .field(RenewalView::getRelationId, relationId)
                 .field(RenewalView::getUserId, userIds).op(Operator.InList).build());
         Assert.notNull(renewalView, "您的车票不存在");
-        if (renewalView.getCategory() != 1) {
+        if (renewalView.getGoodsId() != 42) {
             throw BusinessRuntimeException.getInstance("该平台类型车票无法获取GPT直连token");
         }
         String account = renewalView.getAccount();

+ 14 - 9
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonCategoryController.java

@@ -16,6 +16,7 @@ import com.cyksj.service.mange.CmsGoodsDonService;
 import com.cyksj.service.mange.GoodsDonCategoryService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapBuilder;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.validation.annotation.Validated;
@@ -51,9 +52,9 @@ public class CmsGoodsDonCategoryController {
 	 * 新增分类
 	 */
 	@PostMapping("/post")
-	public Result<String> saveGoodsDonCategory(@RequestBody @Validated GoodsDonCategory category) {
+	public Result<GoodsDonCategory> saveGoodsDonCategory(@RequestBody @Validated GoodsDonCategory category) {
 		goodsDonCategoryService.saveOrUpdateGoods(category);
-		return GatewayResponse.SUCCESS.newBuilder().toResult();
+		return GatewayResponse.SUCCESS.newBuilder().toResult(category);
 	}
 
 	/**
@@ -62,7 +63,7 @@ public class CmsGoodsDonCategoryController {
 	@PutMapping("/put")
 	public Result<String> updateGoodsDonCategory(@RequestBody List<GoodsDonCategory> categorys) {
 		categorys.forEach(category -> goodsDonCategoryService.saveOrUpdateGoods(category));
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category" + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -76,7 +77,7 @@ public class CmsGoodsDonCategoryController {
 		Assert.notNull(byId, "分类不存在");
 		byId.setStatus(!byId.getStatus());
 		goodsDonCategoryService.updateById(byId);
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category" + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -92,7 +93,7 @@ public class CmsGoodsDonCategoryController {
 			throw BusinessRuntimeException.getInstance("存在该分类下平台");
 		}
 		goodsDonCategoryService.delById(id);
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category" + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -108,7 +109,7 @@ public class CmsGoodsDonCategoryController {
 		if (category.getSorted() != null) {
 			byId.setSorted(category.getSorted());
 			goodsDonCategoryService.updateById(byId);
-			Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category" + "*");
+			Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category" + "*");
 			redisService.del(keys.toArray(String[]::new));
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
@@ -132,8 +133,12 @@ public class CmsGoodsDonCategoryController {
 	 * 分类平台列表
 	 */
 	@GetMapping("/get/goods")
-	public Result<SearchResult<GoodsDonCategoryGoodsView>> getCategoryGoodsView() {
-		SearchResult<GoodsDonCategoryGoodsView> search = beanSearcher.search(GoodsDonCategoryGoodsView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
+	public Result<SearchResult<GoodsDonCategoryGoodsView>> getCategoryGoodsView(Long category) {
+		MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
+		if (category != null) {
+			mapBuilder.put("category", String.format(" and gcr.category = %s", category));
+		}
+		SearchResult<GoodsDonCategoryGoodsView> search = beanSearcher.search(GoodsDonCategoryGoodsView.class, mapBuilder.build());
 		search.getDataList().forEach(data->{
 			Integer count = goodsClickUserRecordMapper.selectCount(Wrappers.lambdaQuery(GoodsClickUserRecord.class)
 					.eq(GoodsClickUserRecord::getGoodsId, data.getGoodsId()));
@@ -178,7 +183,7 @@ public class CmsGoodsDonCategoryController {
 				.build());
 		all.forEach(data -> {
 			List<GoodsDonCategoryGoodsView> categoryGoodsViewList = beanSearcher.searchAll(GoodsDonCategoryGoodsView.class, MapUtils.
-					builder().field(GoodsDonCategoryGoodsView::getCategory, data.getId())
+					builder().put("category", String.format(" and gc.id = %s", data.getId()))
 					.field(GoodsDonCategoryGoodsView::getStatus, true).build());
 			data.setCategoryGoodsList(categoryGoodsViewList);
 		});

+ 20 - 4
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java

@@ -11,12 +11,14 @@ import com.cyksj.dto.Result;
 import com.cyksj.enums.BusinessType;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.entity.GoodsDon;
+import com.cyksj.model.entity.GoodsDonCategory;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.manage.request.ReqGoodsSpuInsert;
 import com.cyksj.model.manage.views.GoodsDonViewer;
 import com.cyksj.model.views.GoodsDonCategoryDetailView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.mange.CmsGoodsDonService;
+import com.cyksj.service.mange.GoodsDonCategoryService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapUtils;
@@ -29,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -49,6 +52,8 @@ public class CmsGoodsDonController {
 
     private final RedisService redisService;
 
+    private final GoodsDonCategoryService goodsDonCategoryService;
+
     @GetMapping("/get")
     public Result<SearchResult<GoodsDonCategoryDetailView>> get(){
         SearchResult<GoodsDonCategoryDetailView> search = beanSearcher.search(GoodsDonCategoryDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
@@ -67,6 +72,8 @@ public class CmsGoodsDonController {
         if (StrUtil.isNotBlank(goodsDonViewer.getRecommendGoods())) {
             goodsDonViewer.setRecommendGoodsList(Jsons.parseList(goodsDonViewer.getRecommendGoods(), Long.class));
         }
+        List<GoodsDonCategory> categoryView = goodsDonCategoryService.getCateGoryViewByGoodsId(id);
+        goodsDonViewer.setCategoryList(categoryView.stream().map(GoodsDonCategory::getId).collect(Collectors.toList()));
         return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonViewer);
     }
 
@@ -98,7 +105,12 @@ public class CmsGoodsDonController {
             }
         }
         goodsDonService.save(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        //保存平台 分类的 关联
+        List<Long> categoryList = spu.getCategoryList();
+        if (CollUtil.isNotEmpty(categoryList)) {
+            goodsDonCategoryService.saveBatchRelate(goods.getId(), categoryList);
+        }
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getId());
     }
@@ -138,8 +150,10 @@ public class CmsGoodsDonController {
             re_goodsIds.remove(spu.getId());
             goods.setRecommendGoods(Jsons.toJson(re_goodsIds));
         }
+        //平台 分类关系
+        goodsDonCategoryService.handleGoodsRelate(goods.getId(), spu.getCategoryList());
         goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
@@ -155,7 +169,7 @@ public class CmsGoodsDonController {
         }
         goods.setStatus(!goods.getStatus());
         goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getStatus());
     }
@@ -170,7 +184,7 @@ public class CmsGoodsDonController {
         }
         goods.setDeleted(false);
         goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult(id);
     }
@@ -195,6 +209,8 @@ public class CmsGoodsDonController {
         GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
                 .field(GoodsDon::getSpecialType, GoodsDon.SpecialType.giftCard.name())
                 .build());
+        List<GoodsDonCategory> categoryView = goodsDonCategoryService.getCateGoryViewByGoodsId(goodsDon.getId());
+        goodsDon.setCategoryList(categoryView.stream().map(GoodsDonCategory::getId).collect(Collectors.toList()));
         return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDon);
     }
 }

+ 4 - 4
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonSkuController.java

@@ -90,7 +90,7 @@ public class CmsGoodsDonSkuController {
         goodsDonSpecService.skuAppend(insert, goods);
         //给平台更新额外属性
         goodsDonService.updateGoodsSkuPrice(goods.getId(), goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
        return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
@@ -144,7 +144,7 @@ public class CmsGoodsDonSkuController {
         goodsDonSkuService.saveOrUpdate(sku);
         //给平台更新额外属性
         goodsDonService.updateGoodsSkuPrice(sku.getGoodsId(), null);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
@@ -162,7 +162,7 @@ public class CmsGoodsDonSkuController {
         goodsDonSkuService.handleDiscountPurchaseGoods(sku, null);
         goodsDonSkuService.removeById(skuId);
         goodsDonService.updateGoodsSkuPrice(sku.getGoodsId(), null);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
         redisService.del(keys.toArray(String[]::new));
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
@@ -209,7 +209,7 @@ public class CmsGoodsDonSkuController {
                 .eq(GoodsDonSku::getStatus, false));
         if (update) {
             goodsDonService.updateGoodsSkuPrice(goodsId, null);
-            Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+            Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
             redisService.del(keys.toArray(String[]::new));
         }
         return GatewayResponse.SUCCESS.newBuilder().toResult();

+ 10 - 7
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopGoodsController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Set;
 
 /*
  *项目名: yhlxj
@@ -69,9 +70,9 @@ public class YhShopGoodsController {
 		});
 		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
 				.eq(YhShop::getUserId, userId).last("limit 1"));
-		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhShop.getId();
-		redisService.del(yhShopCacheKey);
-		yhShopGoodsSkuService.saveOrUpdateBatch(goodsSkus);
+		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
+		Set<String> keys = redisService.keys(yhShopCacheKey);
+		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
@@ -84,8 +85,9 @@ public class YhShopGoodsController {
 		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
 				.eq(YhShop::getUserId, userId).last("limit 1"));
 		yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getDeleted, true).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getStatus, status));
-		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhShop.getId();
-		redisService.del(yhShopCacheKey);
+		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
+		Set<String> keys = redisService.keys(yhShopCacheKey);
+		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
@@ -99,8 +101,9 @@ public class YhShopGoodsController {
 		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
 				.eq(YhShop::getUserId, userId).last("limit 1"));
 		yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getDeleted, false));
-		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhShop.getId();
-		redisService.del(yhShopCacheKey);
+		String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhShop.getId() + "*";
+		Set<String> keys = redisService.keys(yhShopCacheKey);
+		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 

+ 7 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopUserController.java

@@ -14,6 +14,7 @@ import com.cyksj.model.entity.*;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.model.views.*;
 import com.cyksj.service.cps.shop.YhShopManageService;
+import com.cyksj.service.mange.GoodsDonCategoryService;
 import com.cyksj.web.util.StpYhShopManageUser;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -26,7 +27,9 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /*
  * admin/小店店铺/用户店铺后台
@@ -51,6 +54,8 @@ public class YhShopUserController {
 
 	private final YhShopApplyRecordMapper yhShopApplyRecordMapper;
 
+	private final GoodsDonCategoryService goodsDonCategoryService;
+
 	/**
 	 * 店铺 信息详情
 	 */
@@ -149,7 +154,8 @@ public class YhShopUserController {
 				.orderBy(YhShopUserDistributeRateView::getRate).desc()
 				.build());
 		YhShopUserDistributeDetailView detailView = new YhShopUserDistributeDetailView();
-		detailView.setRateViews(rateViews);
+		Map<String, List<YhShopUserDistributeRateView>> collect = rateViews.stream().filter(ct->StrUtil.isNotBlank(ct.getCategoryName())).collect(Collectors.groupingBy(YhShopUserDistributeRateView::getCategoryName));
+		detailView.setRateViews(collect);
 		detailView.setWMoney(BigDecimal.valueOf(wMoneyPoints.doubleValue()).divide(BigDecimal.valueOf(100)));
 		detailView.setReMoney(BigDecimal.valueOf(reMoneyPoints.doubleValue()).divide(BigDecimal.valueOf(100)));
 

+ 30 - 4
netflix-web/src/main/java/com/cyksj/web/controller/manage/home/HomeManageConfigController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Assert;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
+import com.cyksj.model.entity.GoodsDonCategory;
 import com.cyksj.model.entity.HomeManagementConfig;
 import com.cyksj.model.entity.HomeManagementConfigUserClickRecord;
 import com.cyksj.model.request.HomeManageConfigReq;
@@ -11,6 +12,7 @@ import com.cyksj.model.views.HomeManagementAvailableGoodsView;
 import com.cyksj.model.views.HomeManagementConfigView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.home.HomeManagementConfigService;
+import com.cyksj.service.mange.GoodsDonCategoryService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapUtils;
@@ -39,6 +41,8 @@ public class HomeManageConfigController {
 
 	private final RedisService redisService;
 
+	private final GoodsDonCategoryService goodsDonCategoryService;
+
 	/**
 	 * 新增首页配置
 	 */
@@ -54,7 +58,7 @@ public class HomeManageConfigController {
 	@PutMapping("/put")
 	public Result<String> updateConfig(@RequestBody HomeManageConfigReq config) {
 		homeManagementConfigService.saveOrUpdateConfig(config);
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -69,11 +73,33 @@ public class HomeManageConfigController {
 		Assert.notNull(byId, "配置不存在");
 		byId.setStatus(!byId.getStatus());
 		homeManagementConfigService.updateById(byId);
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 配置 一键上下架
+	 */
+	@PutMapping("/batch/update/status/{status}")
+	public Result<String> batchUpdateStatus(@RequestBody List<Long> ids, @PathVariable Boolean status) {
+		homeManagementConfigService.update(null, Wrappers.lambdaUpdate(HomeManagementConfig.class)
+				.set(HomeManagementConfig::getStatus, status)
+				.in(HomeManagementConfig::getId, ids));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 分类 一键上下架
+	 */
+	@PutMapping("/batch/update/category/status/{status}")
+	public Result<String> batchUpdateCategoryStatus(@RequestBody List<Long> ids, @PathVariable Boolean status) {
+		goodsDonCategoryService.update(null, Wrappers.lambdaUpdate(GoodsDonCategory.class)
+				.set(GoodsDonCategory::getStatus, status)
+				.in(GoodsDonCategory::getId, ids));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
 	/**
 	 * 配置排序
 	 */
@@ -85,7 +111,7 @@ public class HomeManageConfigController {
 		Integer sorted = config.getSorted();
 		byId.setSorted(sorted);
 		homeManagementConfigService.updateById(byId);
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -99,7 +125,7 @@ public class HomeManageConfigController {
 						.set(HomeManagementConfig::getDeleted, false)
 						.eq(HomeManagementConfig::getId, id)
 						.eq(HomeManagementConfig::getDeleted, true));
-		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage" + "*");
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "*");
 		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}