master:推广营销调优;

pull/1121/head
liujiang 2025-09-09 23:47:17 +08:00
parent eae6442a45
commit d688220e3c
3 changed files with 59 additions and 1 deletions

View File

@ -134,4 +134,12 @@ public class AdvertRoundController extends XktBaseController {
return R.ok(advertRoundService.getRejectReason(advertRoundId));
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
@ApiOperation(value = "根据advertRoundId查看设置的商品及设置的推广图", httpMethod = "GET", response = R.class)
@GetMapping(value = "/set/{advertRoundId}/{storeId}")
public R<AdRoundLatestResVO> getSetInfo(@PathVariable("advertRoundId") Long advertRoundId, @PathVariable("storeId") Long storeId) {
return R.ok(BeanUtil.toBean(advertRoundService.getSetInfo(advertRoundId, storeId), AdRoundLatestResVO.class));
}
}

View File

@ -138,4 +138,13 @@ public interface IAdvertRoundService {
* @return List<AdRoundStoreBoughtResDTO>
*/
List<AdRoundStoreBoughtResDTO> getStoreBoughtRecord(Long storeId);
/**
* 广IDID 广
*
* @param advertRoundId 广ID
* @param storeId ID
* @return AdRoundLatestResDTO
*/
AdRoundLatestResDTO getSetInfo(Long advertRoundId, Long storeId);
}

View File

@ -460,6 +460,31 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
return boughtRoundList;
}
/**
* 广IDID 广
*
* @param advertRoundId 广ID
* @param storeId ID
* @return AdRoundLatestResDTO
*/
@Override
@Transactional(readOnly = true)
public AdRoundLatestResDTO getSetInfo(Long advertRoundId, Long storeId) {
AdvertRound advertRound = this.advertRoundMapper.selectOne(new LambdaQueryWrapper<AdvertRound>()
.eq(AdvertRound::getId, advertRoundId).eq(AdvertRound::getDelFlag, Constants.UNDELETED)
.eq(AdvertRound::getStoreId, storeId));
AdRoundLatestResDTO roundSetInfoDTO = new AdRoundLatestResDTO();
if (ObjectUtils.isEmpty(advertRound)) {
return roundSetInfoDTO;
}
List<StoreProduct> storeProdList = Optional.ofNullable(this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
.in(StoreProduct::getId, StrUtil.split(advertRound.getProdIdStr(), ","))
.eq(StoreProduct::getDelFlag, Constants.UNDELETED).eq(StoreProduct::getStoreId, advertRound.getStoreId())))
.orElseThrow(() -> new ServiceException("档口商品不存在!", HttpStatus.ERROR));
return roundSetInfoDTO.setProdList(storeProdList.stream().map(x -> new AdRoundLatestResDTO.ARLProdDTO()
.setStoreProdId(x.getId()).setProdArtNum(x.getProdArtNum())).collect(Collectors.toList()));
}
/**
* 广ID广广
@ -851,13 +876,15 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
// 将minRoundIdMap中的值转换为List<AdRoundPopularResDTO>
List<AdRoundPopularResDTO> list = minRoundIdMap.values().stream().map(Optional::get).map(x -> new AdRoundPopularResDTO().setAdvertId(x.getAdvertId())
.setTypeId(x.getTypeId()).setTypeName(AdType.of(x.getTypeId()).getLabel()).setShowType(x.getShowType())
.setStartTime(DateUtils.timeMMDD(x.getStartTime())).setEndTime(DateUtils.timeMMDD(x.getEndTime())).setStartPrice(x.getStartPrice()))
.setStartTime(DateUtils.timeMMDD(x.getStartTime())).setEndTime(DateUtils.timeMMDD(x.getEndTime()))
.setStartPrice(this.getAvgStartPrice(x.getStartTime(), x.getEndTime(), x.getStartPrice())))
.collect(Collectors.toList());
// 存到redis中
redisCache.setCacheObject(ADVERT_POPULAR, list, 1, TimeUnit.DAYS);
return list;
}
/**
* 广
*
@ -1231,4 +1258,18 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
return Objects.equals(displayType, AdDisplayType.PICTURE.getValue()) || Objects.equals(displayType, AdDisplayType.PIC_AND_PROD.getValue());
}
/**
* 广
*
* @param startTime
* @param endTime
* @param startPrice
* @return
*/
private BigDecimal getAvgStartPrice(Date startTime, Date endTime, BigDecimal startPrice) {
// 根据当前日期与截止日期的占比修改推广价格
return startPrice.divide(BigDecimal.valueOf(calculateDurationDay(startTime, endTime, Boolean.TRUE)),
0, RoundingMode.HALF_UP);
}
}