소스 검색

小店店铺展示广告位

zoujiajian 2 년 전
부모
커밋
a6a91102c8

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/YhShopInfo.java

@@ -34,5 +34,10 @@ public class YhShopInfo {
 
 	private String reason;
 
+	/**
+	 * 是否展示广告
+	 */
+	private Boolean isShowAd;
+
 	private Date createdTime;
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/YhShop.java

@@ -32,6 +32,11 @@ public class YhShop extends BaseEntity {
 	 */
 	private String customId;
 
+	/**
+	 * 用户是否展示广告位 默认false
+	 */
+	private Boolean isShowAd;
+
 	/**
 	 * 商务id
 	 */

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

@@ -33,6 +33,11 @@ public class HomeManageConfigReq {
 
 	private HomeManagementConfig.AdType adType;
 
+	/**
+	 * 广告是否店铺展示 默认false
+	 */
+	private Boolean isShop;
+
 	private HomeManagementConfig.RgType rgType;
 
 	private BigDecimal rgPrice;

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

@@ -45,6 +45,9 @@ public class HomeManagementConfigView {
 	@DbField("hc.ad_type")
 	private HomeManagementConfig.AdType adType;
 
+	@DbField("hc.is_shop")
+	private Boolean isShop;
+
 	@DbField("hc.rg_type")
 	private HomeManagementConfig.AdType rgType;
 

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

@@ -54,6 +54,9 @@ public class HomeManagementFrontView {
 	@DbField("hc.ad_type")
 	private HomeManagementConfig.AdType adType;
 
+	@DbField("hc.is_shop")
+	private Boolean isShop;
+
 	@DbField("hc.rg_type")
 	private HomeManagementConfig.RgType rgType;
 

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

@@ -38,6 +38,9 @@ public class YhShopDetailView {
 	@DbField("ys.custom_id")
 	private String customId;
 
+	@DbField("ys.is_show_ad")
+	private Boolean isShowAd;
+
 	/**
 	 * 是否审核通过
 	 */

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

@@ -22,4 +22,10 @@ public interface RefreshCacheService {
 	 * 清除补贴商品缓存
 	 */
 	void refreshGoodsSkuSubsidyPageCache();
+
+
+	/**
+	 * 清除用户店铺缓存
+	 */
+	void refreshUserShopMangeCache(String customId);
 }

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

@@ -35,4 +35,10 @@ public class RefreshCacheServiceImpl implements RefreshCacheService {
 		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "subsidy" + "*");
 		redisService.del(keys.toArray(String[]::new));
 	}
+
+	@Override
+	public void refreshUserShopMangeCache(String customId) {
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + "*");
+		redisService.del(keys.toArray(String[]::new));
+	}
 }

+ 24 - 0
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -1216,4 +1216,28 @@ public class GoodsDonController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonSkuSubsidyAvailableViews);
 	}
 
+	/**
+	 * 获取用户店铺首页配置列表
+	 */
+	@GetMapping("/get/homeManage")
+	public Result<Map<String, List<HomeManagementFrontView>>> getShopHomeManageConfig(String customId) {
+		//是否同意展示对应首页广告位
+		String key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + ":homeManage";
+		Object o = redisService.get(key);
+		if (o == null) {
+			MapBuilder builder = MapUtils.builder()
+					.field(HomeManagementFrontView::getType, HomeManagementConfig.Type.ad.name())
+					.field(HomeManagementFrontView::getIsShop, 1);
+			List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
+			if (homeManagementFrontViews == null) {
+				return GatewayResponse.SUCCESS.newBuilder().toResult();
+			}
+			Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
+			map.putIfAbsent(HomeManagementConfig.Type.ad.name(), homeManagementFrontViews);
+			redisService.setNx(key, map, 50 * 60l);
+			o = redisService.get(key);
+		}
+		Map map = Jsons.parseObject(o, Map.class);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(map);
+	}
 }

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

@@ -14,7 +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.service.mange.RefreshCacheService;
 import com.cyksj.web.util.StpYhShopManageUser;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -54,7 +54,7 @@ public class YhShopUserController {
 
 	private final YhShopApplyRecordMapper yhShopApplyRecordMapper;
 
-	private final GoodsDonCategoryService goodsDonCategoryService;
+	private final RefreshCacheService refreshCacheService;
 
 	/**
 	 * 店铺 信息详情
@@ -85,6 +85,25 @@ public class YhShopUserController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 设置是否展示广告位
+	 */
+	@PutMapping("/set/shop/ad")
+	public Result<String> setShopAd(@RequestBody YhShop yhShop) {
+		long userId = StpYhShopManageUser.getLoginIdAsLong();
+		YhShop dbShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getUserId, userId).last("limit 1"));
+		if (dbShop == null) {
+			throw BusinessRuntimeException.getInstance("店铺不存在");
+		}
+		if (yhShop.getIsShowAd() != null && dbShop.getIsShowAd() != yhShop.getIsShowAd()) {
+			dbShop.setIsShowAd(yhShop.getIsShowAd());
+			yhShopMapper.updateById(dbShop);
+			refreshCacheService.refreshUserShopMangeCache(dbShop.getCustomId());
+		}
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
 	/**
 	 * 申请修改
 	 */