master:管理员取消拦截功能;

pull/1121/head
liujiang 2025-05-14 23:01:24 +08:00
parent dad848dd98
commit c2a4f0abbd
5 changed files with 89 additions and 16 deletions

View File

@ -6,10 +6,7 @@ import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.controller.xkt.vo.adminAdvertRound.AdminAdRoundAuditVO;
import com.ruoyi.web.controller.xkt.vo.adminAdvertRound.AdminAdRoundPageVO;
import com.ruoyi.web.controller.xkt.vo.adminAdvertRound.AdminAdRoundSysInterceptVO;
import com.ruoyi.web.controller.xkt.vo.adminAdvertRound.AdminAdRoundUnsubscribeVO;
import com.ruoyi.web.controller.xkt.vo.adminAdvertRound.*;
import com.ruoyi.web.controller.xkt.vo.advertRound.AdRoundUploadPicVO;
import com.ruoyi.xkt.dto.adminAdvertRound.*;
import com.ruoyi.xkt.dto.advertRound.AdRoundUploadPicDTO;
@ -90,9 +87,9 @@ public class AdminAdvertRoundController extends XktBaseController {
*/
@ApiOperation(value = "取消拦截广告位", httpMethod = "PUT", response = R.class)
@Log(title = "取消拦截广告位", businessType = BusinessType.UPDATE)
@PutMapping("/cancel-intercept/{advertRoundId}")
public R<Integer> cancelIntercept(@PathVariable Long advertRoundId) {
return R.ok(adminAdvertRoundService.cancelIntercept(advertRoundId));
@PutMapping("/cancel-intercept")
public R<Integer> cancelIntercept(@Valid @RequestBody AdminAdRoundCancelInterceptVO cancelInterceptVO) {
return R.ok(adminAdvertRoundService.cancelIntercept(BeanUtil.toBean(cancelInterceptVO, AdminAdRoundCancelInterceptDTO.class)));
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.web.controller.xkt.vo.adminAdvertRound;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("系统取消拦截推广位")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminAdRoundCancelInterceptVO {
@NotNull(message = "推广轮次ID不能为空")
@ApiModelProperty(value = "推广轮次ID")
private Long advertRoundId;
@NotNull(message = "档口ID不能为空")
@ApiModelProperty(value = "档口ID")
private Long storeId;
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.xkt.dto.adminAdvertRound;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("系统取消拦截推广位")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminAdRoundCancelInterceptDTO {
@ApiModelProperty(value = "推广轮次ID")
private Long advertRoundId;
@ApiModelProperty(value = "档口ID")
private Long storeId;
}

View File

@ -55,9 +55,9 @@ public interface IAdminAdvertRoundService {
/**
* 广
*
* @param advertRoundId 广ID
* @param cancelInterceptDTO 广
* @return Integer
*/
Integer cancelIntercept(Long advertRoundId);
Integer cancelIntercept(AdminAdRoundCancelInterceptDTO cancelInterceptDTO);
}

View File

@ -13,12 +13,14 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.AdvertRound;
import com.ruoyi.xkt.domain.AdvertRoundRecord;
import com.ruoyi.xkt.domain.AdvertStoreFile;
import com.ruoyi.xkt.domain.SysFile;
import com.ruoyi.xkt.dto.adminAdvertRound.*;
import com.ruoyi.xkt.dto.advertRound.AdRoundUploadPicDTO;
import com.ruoyi.xkt.enums.*;
import com.ruoyi.xkt.mapper.AdvertRoundMapper;
import com.ruoyi.xkt.mapper.AdvertRoundRecordMapper;
import com.ruoyi.xkt.mapper.AdvertStoreFileMapper;
import com.ruoyi.xkt.mapper.SysFileMapper;
import com.ruoyi.xkt.service.IAdminAdvertRoundService;
@ -55,6 +57,7 @@ public class AdminAdvertRoundServiceImpl implements IAdminAdvertRoundService {
final AdvertRoundMapper advertRoundMapper;
final SysFileMapper fileMapper;
final AdvertStoreFileMapper advertStoreFileMapper;
final AdvertRoundRecordMapper advertRoundRecordMapper;
/**
* 广
@ -196,12 +199,14 @@ public class AdminAdvertRoundServiceImpl implements IAdminAdvertRoundService {
LambdaQueryWrapper<AdvertRound> queryWrapper = new LambdaQueryWrapper<AdvertRound>()
.eq(AdvertRound::getAdvertId, advertRound.getAdvertId()).eq(AdvertRound::getRoundId, advertRound.getRoundId())
.eq(AdvertRound::getStoreId, interceptDTO.getStoreId()).eq(AdvertRound::getDelFlag, Constants.UNDELETED);
// 如果是位置枚举类型,则要加上具体的位置
if (Objects.equals(advertRound.getShowType(), AdShowType.POSITION_ENUM.getValue())) {
queryWrapper.eq(AdvertRound::getPosition, advertRound.getPosition());
}
// 该档口自己是否已购买该推广位
List<AdvertRound> existList = this.advertRoundMapper.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(existList)) {
throw new ServiceException("档口" + interceptDTO.getStoreName() + "已出价该推广位,不可重复购买!", HttpStatus.ERROR);
throw new ServiceException("档口" + interceptDTO.getStoreName() + ",已出价该推广位,不可拦截!", HttpStatus.ERROR);
}
// 若该推广位已投放
if (Objects.equals(advertRound.getLaunchStatus(), AdLaunchStatus.LAUNCHING.getValue())) {
@ -226,7 +231,10 @@ public class AdminAdvertRoundServiceImpl implements IAdminAdvertRoundService {
}
// 如果该推广位是被档口正常购买,则直接退费
if (ObjectUtils.isNotEmpty(advertRound.getStoreId()) && Objects.equals(advertRound.getSysIntercept(), AdSysInterceptType.UN_INTERCEPT.getValue())) {
// 给档口退费
assetService.refundAdvertFee(advertRound.getStoreId(), ObjectUtils.defaultIfNull(advertRound.getPayPrice(), BigDecimal.ZERO));
// 档口竞价失败加入AdvertRoundRecord表
this.record(advertRound);
}
// 设置系统拦截的数据 并将系统拦截设置为1
advertRound.setStoreId(interceptDTO.getStoreId()).setSysIntercept(AdSysInterceptType.INTERCEPT.getValue())
@ -245,31 +253,45 @@ public class AdminAdvertRoundServiceImpl implements IAdminAdvertRoundService {
if (Objects.equals(advertRound.getShowType(), AdShowType.POSITION_ENUM.getValue())) {
advertRound.setPayPrice(BigDecimal.valueOf(RandomUtils.nextLong(40, 60 + 1) * 10));
}
return this.advertRoundMapper.updateById(advertRound);
return this.advertRoundMapper.updateById(advertRound);
}
/**
* 广
*
* @param advertRoundId 广ID
* @param cancelInterceptDTO
* @return Integer
*/
@Override
@Transactional
public Integer cancelIntercept(Long advertRoundId) {
public Integer cancelIntercept(AdminAdRoundCancelInterceptDTO cancelInterceptDTO) {
// TODO 判断当前是否是管理员
this.isSuperAdmin();
// 该推广位是否被拦截
AdvertRound advertRound = Optional.ofNullable(this.advertRoundMapper.selectOne(new LambdaQueryWrapper<AdvertRound>()
.eq(AdvertRound::getId, advertRoundId).eq(AdvertRound::getDelFlag, Constants.UNDELETED)
.eq(AdvertRound::getSysIntercept, AdSysInterceptType.INTERCEPT.getValue())))
.orElseThrow(() -> new ServiceException("推广位不存在!", HttpStatus.ERROR));
.eq(AdvertRound::getId, cancelInterceptDTO.getAdvertRoundId()).eq(AdvertRound::getDelFlag, Constants.UNDELETED)
.eq(AdvertRound::getStoreId, cancelInterceptDTO.getStoreId()).eq(AdvertRound::getSysIntercept, AdSysInterceptType.INTERCEPT.getValue())))
.orElseThrow(() -> new ServiceException("该推广位未被拦截,不可取消!", HttpStatus.ERROR));
// 被系统拦截的推广位不用退费,直接清空数据即可
return this.advertRoundMapper.updateAttrNull(advertRound.getId());
}
/**
* 广
*
* @param failAdvert 广
*/
private void record(AdvertRound failAdvert) {
// 新增推广营销历史记录 将旧档口推广营销 置为竞价失败
AdvertRoundRecord record = BeanUtil.toBean(failAdvert, AdvertRoundRecord.class);
record.setId(null).setAdvertRoundId(failAdvert.getId()).setDisplayType(failAdvert.getDisplayType())
// 置为竞价失败
.setBiddingStatus(AdBiddingStatus.BIDDING_FAIL.getValue());
this.advertRoundRecordMapper.insert(record);
}
/**
*