package cn.iocoder.yudao.module.crm.dal.mysql.cancellation;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.module.crm.controller.admin.cancellation.vo.CrmCancellationPageReqVO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.cancellation.CrmCancellationDO;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import org.apache.ibatis.annotations.Mapper;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Mapper
|
public interface CrmCancellationMapper extends BaseMapperX<CrmCancellationDO> {
|
|
default PageResult<CrmCancellationDO> selectPage(CrmCancellationPageReqVO reqVO) {
|
return selectPage(reqVO, buildQuery(reqVO));
|
}
|
|
/**
|
* 提交审批:置为审批中,并清空上一轮审核结果
|
*
|
* 之所以用 UpdateWrapper 而非 updateById:MyBatis-Plus 默认的字段更新策略会忽略 null,
|
* 直接 updateById 无法把审核不通过后残留的审核人、审核时间、审核意见真正清空。
|
*
|
* @param id 销户申请编号
|
* @param status 目标状态(审批中)
|
* @return 影响行数
|
*/
|
default int submitAndResetAuditInfo(Long id, Integer status) {
|
return update(null, new LambdaUpdateWrapper<CrmCancellationDO>()
|
.eq(CrmCancellationDO::getId, id)
|
.set(CrmCancellationDO::getAuditStatus, status)
|
.set(CrmCancellationDO::getReviewerId, null)
|
.set(CrmCancellationDO::getReviewerName, null)
|
.set(CrmCancellationDO::getReviewTime, null)
|
.set(CrmCancellationDO::getReviewRemark, null));
|
}
|
|
/**
|
* 审核:写入审核结果、审核人与审核意见
|
*
|
* reviewRemark 允许为 null(审核通过时意见可选),故同样使用 UpdateWrapper 直写。
|
*
|
* @param id 销户申请编号
|
* @param status 目标状态(审核通过 / 审核不通过)
|
* @param reviewerId 审核人编号
|
* @param reviewerName 审核人姓名
|
* @param reviewRemark 审核意见
|
* @return 影响行数
|
*/
|
default int auditCancellation(Long id, Integer status, Long reviewerId,
|
String reviewerName, String reviewRemark) {
|
return update(null, new LambdaUpdateWrapper<CrmCancellationDO>()
|
.eq(CrmCancellationDO::getId, id)
|
.set(CrmCancellationDO::getAuditStatus, status)
|
.set(CrmCancellationDO::getReviewerId, reviewerId)
|
.set(CrmCancellationDO::getReviewerName, reviewerName)
|
.set(CrmCancellationDO::getReviewTime, LocalDateTime.now())
|
.set(CrmCancellationDO::getReviewRemark, reviewRemark));
|
}
|
|
default List<CrmCancellationDO> selectList(CrmCancellationPageReqVO reqVO) {
|
return selectList(buildQuery(reqVO));
|
}
|
|
default CrmCancellationDO selectByCancellationNo(String cancellationNo) {
|
return selectOne(new LambdaQueryWrapperX<CrmCancellationDO>()
|
.eq(CrmCancellationDO::getCancellationNo, cancellationNo));
|
}
|
|
private LambdaQueryWrapperX<CrmCancellationDO> buildQuery(CrmCancellationPageReqVO reqVO) {
|
return new LambdaQueryWrapperX<CrmCancellationDO>()
|
.likeIfPresent(CrmCancellationDO::getCancellationNo, reqVO.getCancellationNo())
|
.eqIfPresent(CrmCancellationDO::getCustomerId, reqVO.getCustomerId())
|
.eqIfPresent(CrmCancellationDO::getCancellationType, reqVO.getCancellationType())
|
.eqIfPresent(CrmCancellationDO::getAuditStatus, reqVO.getAuditStatus())
|
.orderByDesc(CrmCancellationDO::getId);
|
}
|
|
}
|