master:推广营销微调;

pull/1121/head
liujiang 2025-05-16 21:33:46 +08:00
parent b8ecc6ff3a
commit e826f1ef06
7 changed files with 74 additions and 80 deletions

View File

@ -83,9 +83,6 @@ public class AdvertCreateVO {
@NotNull(message = "文件大小不能为空!")
@ApiModelProperty(value = "文件大小", required = true)
private BigDecimal fileSize;
@NotNull(message = "文件类型不能为空!")
@ApiModelProperty(value = "文件类型", required = true)
private Integer typeId;
}
}

View File

@ -18,26 +18,35 @@ public enum AdType {
PC_HOME_TOP_LEFT_BANNER(1, "顶部横向大图", "/url"),
// 顶部纵向小图
PC_HOME_TOP_RIGHT_BANNER(2, "顶部纵向小图", "/url"),
// 首页销售榜榜一
PC_HOME_SALE_RANK_ONE(3, "销售榜榜一", "/url"),
// 首页销售榜榜二
PC_HOME_SALE_RANK_TWO(4, "销售榜榜二", "/url"),
// 首页销售榜榜三
PC_HOME_SALE_RANK_THREE(5, "销售榜榜三", "/url"),
// 首页销售榜榜四
PC_HOME_SALE_RANK_FOUR(6, "销售榜榜四", "/url"),
// 人气榜左侧大图
PC_HOME_POP_LEFT_BANNER(3, "人气榜左大图", "/url"),
PC_HOME_POP_LEFT_BANNER(7, "人气榜左大图", "/url"),
// 人气榜中间图
PC_HOME_POP_MID_TOP(4, "人气榜中间图", "/url"),
PC_HOME_POP_MID_TOP(8, "人气榜中间图", "/url"),
// 人气榜右侧图
PC_HOME_POP_RIGHT_TOP(5, "人气榜右侧图", "/url"),
PC_HOME_POP_RIGHT_TOP(9, "人气榜右侧图", "/url"),
// 首页档口横幅
PC_HOME_SINGLE_BANNER(6, "首页档口横幅", "/url"),
PC_HOME_SINGLE_BANNER(10, "首页档口横幅", "/url"),
// 首页商品列表
PC_HOME_PRODUCT_LIST(7, "首页商品列表", "/url"),
PC_HOME_PRODUCT_LIST(11, "首页商品列表", "/url"),
// 首页两侧固定挂耳
PC_HOME_FIXED_EAR(8, "首页两侧固定挂耳", "/url"),
PC_HOME_FIXED_EAR(12, "首页两侧固定挂耳", "/url"),
// 首页搜索框下名称
PC_HOME_SEARCH_DOWN_NAME(9, "首页搜索框下名称", "/url"),
PC_HOME_SEARCH_DOWN_NAME(13, "首页搜索框下名称", "/url"),
// 首页搜索框商品
PC_HOME_SEARCH_PRODUCT(10, "首页搜索框商品", "/url"),
PC_HOME_SEARCH_PRODUCT(14, "首页搜索框商品", "/url"),
// 首页搜索框档口
PC_HOME_SEARCH_STORE(11, "首页搜索框档口", "/url"),
PC_HOME_SEARCH_STORE(15, "首页搜索框档口", "/url"),
// 首页以图搜款商品
PC_HOME_PIC_SEARCH_PRODUCT(12, "首页以图搜款商品", "/url"),
PC_HOME_PIC_SEARCH_PRODUCT(16, "首页以图搜款商品", "/url"),
// 新品馆顶部横向大图

View File

@ -401,7 +401,6 @@ public class XktTask {
if (CollectionUtils.isNotEmpty(updateList)) {
this.advertRoundMapper.insertOrUpdate(updateList);
}
// 更新推广轮次截止时间到redis
this.saveAdvertDeadlineToRedis();
}

View File

@ -73,9 +73,6 @@ public class AdvertCreateDTO {
@NotNull(message = "文件大小不能为空!")
@ApiModelProperty(value = "文件大小", required = true)
private BigDecimal fileSize;
@NotNull(message = "文件类型不能为空!")
@ApiModelProperty(value = "文件类型", required = true)
private Integer typeId;
}
}

View File

@ -2,8 +2,6 @@ package com.ruoyi.xkt.service;
import com.ruoyi.xkt.dto.storeProductStorageDemandDeduct.StoreProdStorageDemandDeductDTO;
import java.util.List;
/**
* Service
*
@ -15,7 +13,7 @@ public interface IStoreProductStorageDemandDeducteService {
/**
*
*
* @param storeId ID
* @param storeId ID
* @param storageCode
* @return List<StoreProdStorageDemandDeductDTO>
*/

View File

@ -88,11 +88,6 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
System.err.println(advertLockMap);
}
public void test() {
System.err.println(advertLockMap);
}
/**
* 广
* 广广
@ -612,7 +607,7 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
// 服务器当前时间 yyyy-MM-dd
final Date now = DateUtils.parseDate(DateUtils.getDate(), DateUtils.YYYY_MM_DD);
// 当天截止的时间 yyyy-MM-dd 22:00:00
final String filterTime = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS).format(LocalDateTime.now().withHour(22).withMinute(0).withSecond(0));
final String todayFilterTime = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS).format(LocalDateTime.now().withHour(22).withMinute(0).withSecond(0));
advertRoundList.stream().collect(Collectors.groupingBy(AdvertRound::getAdvertId))
.forEach((advertId, roundList) -> {
// 判断当前推广类型是否为 时间范围
@ -623,67 +618,62 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
.orElseThrow(() -> new ServiceException("获取推广结束时间失败,请联系客服!", HttpStatus.ERROR)).getEndTime();
// 时间范围处理逻辑
if (isTimeRange) {
if (now.compareTo(firstRoundEndTime) < 0) {
// 第一轮过期时间为当天
AdvertRound firstRound = roundList.stream().filter(x -> Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.max(Comparator.comparing(AdvertRound::getEndTime))
.orElseThrow(() -> new ServiceException("获取推广结束时间失败,请联系客服!", HttpStatus.ERROR));
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + firstRound.getSymbol(), filterTime, 1, TimeUnit.DAYS);
// 第二轮之后的轮次过期时间都为开始时间前一天
Map<String, Date> roundSymbolMap = roundList.stream().filter(x -> !Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.collect(Collectors.toMap(AdvertRound::getSymbol, AdvertRound::getStartTime, (s1, s2) -> s2));
if (MapUtils.isNotEmpty(roundSymbolMap)) {
roundSymbolMap.forEach((symbol, startTime) -> {
// 推广开始时间的前一天的 22:00:00
LocalDateTime futureTimeFilter = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusDays(1).withHour(22).withMinute(0).withSecond(0);
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + symbol, futureTimeFilter, 1, TimeUnit.DAYS);
});
}
}
if (now.compareTo(firstRoundEndTime) == 0) {
// 第一轮不用管,设置第二轮 或者 第一轮 第二轮过期时间都可以为 当天
List<AdvertRound> firstOrSecondRoundList = roundList.stream().filter(x -> Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue())
|| Objects.equals(x.getRoundId(), AdRoundType.SECOND_ROUND.getValue())).collect(Collectors.toList());
Map<String, Date> roundSymbolMap = firstOrSecondRoundList.stream().collect(Collectors.toMap(AdvertRound::getSymbol, AdvertRound::getStartTime, (s1, s2) -> s2));
if (MapUtils.isNotEmpty(roundSymbolMap)) {
roundSymbolMap.forEach((symbol, startTime) -> {
// 推广开始时间的前一天的 22:00:00
LocalDateTime futureTimeFilter = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusDays(1).withHour(22).withMinute(0).withSecond(0);
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + symbol, futureTimeFilter, 1, TimeUnit.DAYS);
});
}
List<AdvertRound> otherRoundList = roundList.stream().filter(x -> !Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue())
&& !Objects.equals(x.getRoundId(), AdRoundType.SECOND_ROUND.getValue())).collect(Collectors.toList());
Map<String, Date> otherRoundSymbolMap = otherRoundList.stream().collect(Collectors.toMap(AdvertRound::getSymbol, AdvertRound::getStartTime, (s1, s2) -> s2));
if (MapUtils.isNotEmpty(otherRoundSymbolMap)) {
otherRoundSymbolMap.forEach((symbol, startTime) -> {
// 推广开始时间的前一天的 22:00:00
LocalDateTime futureTimeFilter = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusDays(1).withHour(22).withMinute(0).withSecond(0);
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + symbol, futureTimeFilter, 1, TimeUnit.DAYS);
});
}
}
this.setTimeRangePatternDeadline(todayFilterTime, roundList);
} else {
// 第一轮最后一天则直接处理第二轮的symbol
if (now.equals(firstRoundEndTime)) {
// 开始时间和结束时间相同,则代表是 只有一天 的枚举类型
List<AdvertRound> onceRoundList = roundList.stream().filter(x -> Objects.equals(x.getStartTime(), x.getEndTime())).collect(Collectors.toList());
// 开始时间和结束时间不一致,则代表是 时间范围 的枚举类型
List<AdvertRound> timePositionList = roundList.stream().filter(x -> !Objects.equals(x.getStartTime(), x.getEndTime())).collect(Collectors.toList());
// 处理只有一天的枚举类型
if (CollectionUtils.isNotEmpty(onceRoundList)) {
// 将位置枚举的每一个symbol都存放到redis中
roundList.stream().filter(x -> !Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.forEach(x -> redisCache.setCacheObject(ADVERT_DEADLINE_KEY + x.getSymbol(), filterTime, 1, TimeUnit.DAYS));
} else {
// 将位置枚举的每一个symbol都存放到redis中
roundList.stream().filter(x -> Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.forEach(x -> redisCache.setCacheObject(ADVERT_DEADLINE_KEY + x.getSymbol(), filterTime, 1, TimeUnit.DAYS));
onceRoundList.stream().filter(x -> Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.forEach(x -> redisCache.setCacheObject(ADVERT_DEADLINE_KEY + x.getSymbol(), todayFilterTime, 1, TimeUnit.DAYS));
onceRoundList.stream().filter(x -> !Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.forEach(x -> {
// 推广开始时间的前一天的 22:00:00
LocalDateTime futureTimeFilter = x.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusDays(1).withHour(22).withMinute(0).withSecond(0);
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + x.getSymbol(), futureTimeFilter, 1, TimeUnit.DAYS);
});
}
// 时间范围 + 位置枚举
if (CollectionUtils.isNotEmpty(timePositionList)) {
this.setTimeRangePatternDeadline(todayFilterTime, timePositionList);
}
}
});
}
/**
* "时间范围" "时间范围 + 位置枚举"
*
* @param todayFilterTime 22:00
* @param roundList
*/
private void setTimeRangePatternDeadline(String todayFilterTime, List<AdvertRound> roundList) {
// 第一轮过期时间为当天
AdvertRound firstRound = roundList.stream().filter(x -> Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.max(Comparator.comparing(AdvertRound::getEndTime))
.orElseThrow(() -> new ServiceException("获取推广结束时间失败,请联系客服!", HttpStatus.ERROR));
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + firstRound.getSymbol(), todayFilterTime, 1, TimeUnit.DAYS);
// 第二轮之后的轮次过期时间都为开始时间前一天
Map<String, Date> roundSymbolMap = roundList.stream().filter(x -> !Objects.equals(x.getRoundId(), AdRoundType.PLAY_ROUND.getValue()))
.collect(Collectors.toMap(AdvertRound::getSymbol, AdvertRound::getStartTime, (s1, s2) -> s2));
if (MapUtils.isNotEmpty(roundSymbolMap)) {
roundSymbolMap.forEach((symbol, startTime) -> {
// 推广开始时间的前一天的 22:00:00
LocalDateTime futureTimeFilter = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusDays(1).withHour(22).withMinute(0).withSecond(0);
redisCache.setCacheObject(ADVERT_DEADLINE_KEY + symbol, futureTimeFilter, 1, TimeUnit.DAYS);
});
}
}
/**
* 广
*
* @param symbol
* @return
* @return
*/
private String getDeadline(String symbol) throws ParseException {
String deadline = redisCache.getCacheObject(ADVERT_DEADLINE_KEY + symbol);

View File

@ -14,6 +14,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.Advert;
import com.ruoyi.xkt.domain.SysFile;
import com.ruoyi.xkt.dto.advert.*;
import com.ruoyi.xkt.enums.AdDisplayType;
import com.ruoyi.xkt.enums.AdOnlineStatus;
import com.ruoyi.xkt.enums.AdPlatformType;
import com.ruoyi.xkt.enums.AdTab;
@ -61,15 +62,18 @@ public class AdvertServiceImpl implements IAdvertService {
// TODO 判断当前是否超级管理员在操作
this.isSuperAdmin();
// 将文件插入到SysFile表中
SysFile file = BeanUtil.toBean(createDTO.getExample(), SysFile.class);
this.fileMapper.insert(file);
Advert advert = BeanUtil.toBean(createDTO, Advert.class);
advert.setBasicSymbol(random10Str());
advert.setOnlineStatus(AdOnlineStatus.ONLINE.getValue());
advert.setExamplePicId(file.getId());
// 推广类型为 推广图 或者 图及商品 则新增系统文件
if (!Objects.equals(createDTO.getDisplayType(), AdDisplayType.PRODUCT.getValue()) && ObjectUtils.isNotEmpty(createDTO.getExample())) {
// 将文件插入到SysFile表中
SysFile file = BeanUtil.toBean(createDTO.getExample(), SysFile.class);
this.fileMapper.insert(file);
advert.setExamplePicId(file.getId());
}
return this.advertMapper.insert(advert);
// 更新档口推广营销截止时间
}