Browse Source

平台列表

zoujiajian 2 years ago
parent
commit
dcec822dd7

+ 90 - 6
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDonSku.java

@@ -3,10 +3,10 @@ package com.cyksj.model.entity;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.cyksj.model.views.GoodsDiscountPlusPurchaseRelationFrontView;
-import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -19,7 +19,8 @@ import java.util.List;
  */
 @Getter
 @Setter
-@SearchBean(tables = "goods_don_sku")
+@SearchBean(tables = "goods_don_sku",
+        where = ":condition:")
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class GoodsDonSku extends BaseEntity {
 
@@ -53,6 +54,26 @@ public class GoodsDonSku extends BaseEntity {
      */
     private String notifyText;
 
+    /**
+     * H5标签
+     */
+    private String mobileTags;
+
+    /**
+     * 规格背景图
+     */
+    private String img;
+
+    /**
+     * 规格框提示
+     */
+    private String smallMsg;
+
+    /**
+     * 双重验证码次数
+     */
+    private Integer codeNum;
+
     /**
      * 商品预览图
      */
@@ -116,9 +137,9 @@ public class GoodsDonSku extends BaseEntity {
     @TableField(updateStrategy = FieldStrategy.IGNORED)
     private Integer days;
 
-    @DbField("case when spec_val like '%月%' and spec_val not like '%年%' then 0 when spec_val like '%季%' then 1 when spec_val like '%半年%' then 2 when spec_val like '%年%' then 3 else 66 end")
-    @TableField(exist = false)
-    private Integer orderBy;
+//    @DbField("case when spec_val like '%月%' and spec_val not like '%年%' then 0 when spec_val like '%季%' then 1 when spec_val like '%半年%' then 2 when spec_val like '%年%' then 3 else 66 end")
+//    @TableField(exist = false)
+//    private Integer orderBy;
 
     /**
      * 加购规格
@@ -132,10 +153,73 @@ public class GoodsDonSku extends BaseEntity {
      */
     private Boolean isDp;
 
+    /**
+     * 是否是镜像服务
+     */
+    private Boolean isMirror;
+
+    /**
+     * 是否是车队形式
+     */
+    private Boolean isCar;
+
+    /**
+     * 限制次数
+     */
+    private Integer gptLimitNum;
+
+    /**
+     * 限制时间
+     */
+    private Long gptLimitTime;
+
+    /**
+     * mj fast次数
+     */
+    private Integer mjFastNum;
+
+    /**
+     * mj relax次数
+     */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private Integer mjRelaxNum;
+
+    /**
+     * 特定价格
+     */
+    private BigDecimal specificPrice;
+
+    /**
+     * 特定平台购买用户人群
+     */
+    private String specificGoodsIds;
+
     /**
      * 优惠加购商品规格展示
      */
     @DbIgnore
     @TableField(exist = false)
-    private List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuViews;
+    private List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuList;
+
+    /**
+     * 前端展示
+     */
+    @DbIgnore
+    @TableField(exist = false)
+    @JsonProperty("gname")
+    private String gName;
+
+    /**
+     * 前端展示
+     */
+    @DbIgnore
+    @TableField(exist = false)
+    @JsonProperty("sname")
+    private String sName;
+
+    /**
+     * 排序
+     */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private Integer sorted;
 }

+ 15 - 0
netflix-service/src/main/java/com/cyksj/service/mange/RefreshCacheService.java

@@ -0,0 +1,15 @@
+package com.cyksj.service.mange;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: RefreshCacheService
+ * 创建者: JavaZou
+ * 创建时间:2024/2/22 16:28
+ */
+public interface RefreshCacheService {
+
+	/**
+	 * 清除官网首页商品缓存
+	 */
+	void refreshYhHomePageCache();
+}

+ 26 - 0
netflix-service/src/main/java/com/cyksj/service/mange/impl/RefreshCacheServiceImpl.java

@@ -0,0 +1,26 @@
+package com.cyksj.service.mange.impl;
+
+import com.cyksj.redis.RedisService;
+import com.cyksj.service.mange.RefreshCacheService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: RefreshCacheServiceImpl
+ * 创建者: JavaZou
+ * 创建时间:2024/2/22 16:28
+ */
+@Service
+@RequiredArgsConstructor
+public class RefreshCacheServiceImpl implements RefreshCacheService {
+	private final RedisService redisService;
+
+	@Override
+	public void refreshYhHomePageCache() {
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
+		redisService.del(keys.toArray(String[]::new));
+	}
+}

+ 139 - 137
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java

@@ -9,15 +9,16 @@ import com.cyksj.common.util.Jsons;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.BusinessType;
 import com.cyksj.enums.GatewayResponse;
-import com.cyksj.model.entity.GoodsDiscountPlusPurchaseRelation;
 import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.manage.request.ReqGoodsSpuInsert;
 import com.cyksj.model.manage.views.GoodsDonViewer;
-import com.cyksj.redis.RedisService;
 import com.cyksj.service.mange.CmsGoodsDonService;
+import com.cyksj.service.mange.RefreshCacheService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.param.Operator;
+import com.ejlchina.searcher.util.MapBuilder;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -40,13 +41,13 @@ import java.util.Set;
 @RequestMapping("/manage/goods")
 public class CmsGoodsDonController {
 
-    private final HttpServletRequest request;
+	private final HttpServletRequest request;
 
-    private final BeanSearcher beanSearcher;
+	private final BeanSearcher beanSearcher;
 
-    private final CmsGoodsDonService goodsDonService;
+	private final CmsGoodsDonService goodsDonService;
 
-    private final RedisService redisService;
+	private final RefreshCacheService refreshCacheService;
 
     @GetMapping("/get")
     public Result<SearchResult<GoodsDon>> get(){
@@ -56,135 +57,136 @@ public class CmsGoodsDonController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
 
-    /**
-     * 商品详情
-     */
-    @GetMapping("/get/{id}")
-    public Result<GoodsDonViewer> getById(@PathVariable Long id) throws Exception {
-        GoodsDonViewer goodsDonViewer = beanSearcher.searchFirst(GoodsDonViewer.class, MapUtils.builder().field(GoodsDonViewer::getId, id).build());
-        if (StrUtil.isNotBlank(goodsDonViewer.getRecommendGoods())) {
-            goodsDonViewer.setRecommendGoodsList(Jsons.parseList(goodsDonViewer.getRecommendGoods(), Long.class));
-        }
-        List<GoodsDonSku> goodsDonSkus = beanSearcher.searchAll(GoodsDonSku.class, MapUtils.builder().field(GoodsDonSku::getGoodsId, id).build());
-        if (goodsDonViewer.getType() == 1) {
-            goodsDonSkus.forEach(sku -> {
-                if (sku.getIsDp()) {
-                    sku.setDpSku(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelation.class, MapUtils.builder()
-                            .field(GoodsDiscountPlusPurchaseRelation::getSkuId, sku.getId())
-                            .build()));
-                }
-            });
-        }
-        goodsDonViewer.setSkus(goodsDonSkus);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonViewer);
-    }
-
-    /**
-     * 商品规格详情
-     */
-    @GetMapping("/get/sku/{id}")
-    public Result<List<GoodsDonSku>> getSkuById(@PathVariable Long id, HttpServletRequest request) {
-        List<GoodsDonSku> goodsDonSkus = beanSearcher.searchAll(GoodsDonSku.class, MapUtils.flatBuilder(request.getParameterMap()).field(GoodsDonSku::getGoodsId, id).build());
-        return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonSkus);
-    }
-
-    /**
-     * 新增 商品spu
-     */
-    @PostMapping(value = "/post")
-    @Log(module = "平台管理/新增平台", businessType = BusinessType.POST, isSaveRequestData = true)
-    public Result<Long> spuInsert(@Validated @RequestBody ReqGoodsSpuInsert spu) throws Exception {
-        // 新增商品
-        GoodsDon goods = new GoodsDon();
-        BeanUtil.copyProperties(spu, goods);
-        if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
-            if (CollUtil.isEmpty(spu.getRecommendGoodsList())) {
-                throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
-            }
-        }
-        goodsDonService.save(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
-        redisService.del(keys.toArray(String[]::new));
-        return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getId());
-    }
-
-    /**
-     * 修改 商品spu
-     */
-    @PutMapping(value = "/update")
-    @Log(module = "平台管理/编辑平台", businessType = BusinessType.PUT, isSaveRequestData = true)
-    public Result<String> spuUpdate(@Validated @RequestBody ReqGoodsSpuInsert spu) throws Exception{
-        GoodsDon goods = new GoodsDon();
-        BeanUtil.copyProperties(spu,goods);
-        if (spu.getSpecialType() == null) {
-            goods.setSpecialType(null);
-        }
-        if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
-            if (CollUtil.isEmpty(spu.getRecommendGoodsList())) {
-                throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
-            }
-        }
-        if (CollUtil.isNotEmpty(spu.getRecommendGoodsList())) {
-            Set<Long> re_goodsIds = new HashSet<>(spu.getRecommendGoodsList());
-            //去除自己
-            re_goodsIds.remove(spu.getId());
-            goods.setRecommendGoods(Jsons.toJson(re_goodsIds));
-        }
-        if (StrUtil.isEmpty(goods.getRecommendTitle())) {
-            goods.setRecommendTitle(null);
-        }
-        if (StrUtil.isEmpty(goods.getVideo())) {
-            goods.setVideo(null);
-        }
-        if (CollUtil.isNotEmpty(spu.getRecommendGoodsList())) {
-            Set<Long> re_goodsIds = new HashSet<>(spu.getRecommendGoodsList());
-            //去除自己
-            re_goodsIds.remove(spu.getId());
-            goods.setRecommendGoods(Jsons.toJson(re_goodsIds));
-        }
-        goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
-        redisService.del(keys.toArray(String[]::new));
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
-
-
-    @PutMapping("/put/status/{id}")
-    @Log(module = "平台管理/平台上下架", businessType = BusinessType.PUT, isSaveRequestData = true, isSaveResponseData = true)
-    public Result<Boolean> updateStatus(@PathVariable Long id) {
-        GoodsDon goods = goodsDonService.getById(id);
-        if (goods == null) {
-            throw BusinessRuntimeException.getInstance("平台不存在");
-        }
-        goods.setStatus(!goods.getStatus());
-        goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
-        redisService.del(keys.toArray(String[]::new));
-        return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getStatus());
-    }
-
-    @DeleteMapping("/delete/{id}")
-    @Log(module = "平台管理/删除平台", businessType = BusinessType.DELETE, isSaveRequestData = true, isSaveResponseData = true)
-    public Result<Long> deleteById(@PathVariable Long id) {
-        GoodsDon goods = goodsDonService.getById(id);
-        if (goods == null) {
-            throw BusinessRuntimeException.getInstance("平台不存在");
-        }
-        goods.setDeleted(false);
-        goodsDonService.updateById(goods);
-        Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
-        redisService.del(keys.toArray(String[]::new));
-        return GatewayResponse.SUCCESS.newBuilder().toResult(id);
-    }
-
-    /**
-     * 获取所有平台列表
-     */
-    @GetMapping("/get/all")
-    public Result<List<GoodsDon>> getAllGoodsList() {
-        List<GoodsDon> goodsDons = beanSearcher.searchAll(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
-                .field(GoodsDon::getDeleted,true)
-                .onlySelect(GoodsDon::getId, GoodsDon::getCategory, GoodsDon::getType, GoodsDon::getTitle).build());
-        return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDons);
-    }
+	/**
+	 * 商品详情
+	 */
+	@GetMapping("/get/{id}")
+	public Result<GoodsDonViewer> getById(@PathVariable Long id) throws Exception {
+		GoodsDonViewer goodsDonViewer = beanSearcher.searchFirst(GoodsDonViewer.class, MapUtils.builder().field(GoodsDonViewer::getId, id).build());
+		if (StrUtil.isNotBlank(goodsDonViewer.getRecommendGoods())) {
+			goodsDonViewer.setRecommendGoodsList(Jsons.parseList(goodsDonViewer.getRecommendGoods(), Long.class));
+		}
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonViewer);
+	}
+
+	/**
+	 * 商品规格详情
+	 */
+	@GetMapping("/get/sku/{id}")
+	public Result<List<GoodsDonSku>> getSkuById(@PathVariable Long id, HttpServletRequest request) {
+		List<GoodsDonSku> goodsDonSkus = beanSearcher.searchAll(GoodsDonSku.class, MapUtils.flatBuilder(request.getParameterMap()).field(GoodsDonSku::getGoodsId, id)
+				.orderBy(GoodsDonSku::getSorted).asc()
+				.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonSkus);
+	}
+
+	/**
+	 * 新增 商品spu
+	 */
+	@PostMapping(value = "/post")
+	@Log(module = "平台管理/新增平台", businessType = BusinessType.POST, isSaveRequestData = true)
+	public Result<Long> spuInsert(@Validated @RequestBody ReqGoodsSpuInsert spu) throws Exception {
+		// 新增商品
+		GoodsDon goods = new GoodsDon();
+		if (spu.getSecondType() == null) {
+			spu.setSecondType(2);
+		}
+		BeanUtil.copyProperties(spu, goods);
+		if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
+			if (CollUtil.isEmpty(spu.getRecommendGoodsList())) {
+				throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
+			}
+		}
+		goodsDonService.save(goods);
+		refreshCacheService.refreshYhHomePageCache();
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getId());
+	}
+
+	/**
+	 * 修改 商品spu
+	 */
+	@PutMapping(value = "/update")
+	@Log(module = "平台管理/编辑平台", businessType = BusinessType.PUT, isSaveRequestData = true)
+	public Result<String> spuUpdate(@Validated @RequestBody ReqGoodsSpuInsert spu) throws Exception{
+		GoodsDon goods = new GoodsDon();
+		BeanUtil.copyProperties(spu,goods);
+		if (spu.getSpecialType() == null) {
+			goods.setSpecialType(null);
+		}
+		if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
+			if (CollUtil.isEmpty(spu.getRecommendGoodsList())) {
+				throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
+			}
+		}
+		if (CollUtil.isNotEmpty(spu.getRecommendGoodsList())) {
+			Set<Long> re_goodsIds = new HashSet<>(spu.getRecommendGoodsList());
+			//去除自己
+			re_goodsIds.remove(spu.getId());
+			goods.setRecommendGoods(Jsons.toJson(re_goodsIds));
+		}
+		if (StrUtil.isEmpty(goods.getRecommendTitle())) {
+			goods.setRecommendTitle(null);
+		}
+		if (StrUtil.isEmpty(goods.getVideo())) {
+			goods.setVideo(null);
+		}
+		if (CollUtil.isNotEmpty(spu.getRecommendGoodsList())) {
+			Set<Long> re_goodsIds = new HashSet<>(spu.getRecommendGoodsList());
+			//去除自己
+			re_goodsIds.remove(spu.getId());
+			goods.setRecommendGoods(Jsons.toJson(re_goodsIds));
+		}
+		goodsDonService.updateById(goods);
+		refreshCacheService.refreshYhHomePageCache();
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+
+	@PutMapping("/put/status/{id}")
+	@Log(module = "平台管理/平台上下架", businessType = BusinessType.PUT, isSaveRequestData = true, isSaveResponseData = true)
+	public Result<Boolean> updateStatus(@PathVariable Long id) {
+		GoodsDon goods = goodsDonService.getById(id);
+		if (goods == null) {
+			throw BusinessRuntimeException.getInstance("平台不存在");
+		}
+		goods.setStatus(!goods.getStatus());
+		goodsDonService.updateById(goods);
+		refreshCacheService.refreshYhHomePageCache();
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goods.getStatus());
+	}
+
+	@DeleteMapping("/delete/{id}")
+	@Log(module = "平台管理/删除平台", businessType = BusinessType.DELETE, isSaveRequestData = true, isSaveResponseData = true)
+	public Result<Long> deleteById(@PathVariable Long id) {
+		GoodsDon goods = goodsDonService.getById(id);
+		if (goods == null) {
+			throw BusinessRuntimeException.getInstance("平台不存在");
+		}
+		goods.setDeleted(false);
+		goodsDonService.updateById(goods);
+		refreshCacheService.refreshYhHomePageCache();
+		return GatewayResponse.SUCCESS.newBuilder().toResult(id);
+	}
+
+	/**
+	 * 获取所有平台列表
+	 */
+	@GetMapping("/get/all")
+	public Result<List<GoodsDon>> getAllGoodsList(Boolean isNoBuyout) {
+		MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
+		//过滤买断制 平台
+		String conditionSql;
+		if (isNoBuyout != null && isNoBuyout) {
+			mapBuilder.field(GoodsDon::getSpecialType).op(Operator.IsNull);
+			conditionSql = "(select count(*) from goods_don_sku sku where sku.goods_id = g.id and sku.months = 300) = 0";
+		} else {
+			conditionSql = "(special_type is null or special_type != 'giftCard')";
+		}
+		conditionSql += "  and exists (select id from goods_don_sku sku where sku.goods_id = g.id limit 1)";
+		List<GoodsDon> goodsDons = beanSearcher.searchAll(GoodsDon.class, mapBuilder
+				.put("condition", conditionSql)
+				.field(GoodsDon::getDeleted, true)
+				.onlySelect(GoodsDon::getId, GoodsDon::getCategory, GoodsDon::getType, GoodsDon::getTitle, GoodsDon::getSecondType).build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDons);
+	}
 }