| | |
| | | package cn.iocoder.yudao.module.crm.dal.mysql.quotation; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | 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.framework.mybatis.core.query.MPJLambdaWrapperX; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationPageReqVO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO; |
| | | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| | |
| | | /** |
| | | * CRM 销售报价单 Mapper |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Mapper |
| | | public interface CrmSaleQuotationMapper extends BaseMapperX<CrmSaleQuotationDO> { |
| | |
| | | } |
| | | |
| | | default PageResult<CrmSaleQuotationDO> selectPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId) { |
| | | return selectPage(pageReqVO, userId, null); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询(带客户权限过滤) |
| | | * |
| | | * @param pageReqVO 查询条件 |
| | | * @param userId 用户ID |
| | | * @param permittedCustomerIds 有权限的客户ID列表(null表示不限制) |
| | | */ |
| | | default PageResult<CrmSaleQuotationDO> selectPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId, List<Long> permittedCustomerIds) { |
| | | MPJLambdaWrapperX<CrmSaleQuotationDO> query = new MPJLambdaWrapperX<>(); |
| | | // 拼接数据权限的查询条件 |
| | | CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_SALE_QUOTATION.getType(), |
| | |
| | | .eqIfPresent(CrmSaleQuotationDO::getBusinessId, pageReqVO.getBusinessId()) |
| | | .eqIfPresent(CrmSaleQuotationDO::getStatus, pageReqVO.getStatus()) |
| | | .orderByDesc(CrmSaleQuotationDO::getId); |
| | | |
| | | // 客户权限过滤 |
| | | if (permittedCustomerIds != null) { |
| | | if (CollUtil.isEmpty(permittedCustomerIds)) { |
| | | return PageResult.empty(); |
| | | } |
| | | query.in(CrmSaleQuotationDO::getCustomerId, permittedCustomerIds); |
| | | } |
| | | |
| | | return selectJoinPage(pageReqVO, CrmSaleQuotationDO.class, query); |
| | | } |
| | | |
| | |
| | | return selectCount(CrmSaleQuotationDO::getCustomerId, customerId); |
| | | } |
| | | |
| | | /** |
| | | * 清除报价单的合同关联(删除合同时调用) |
| | | * |
| | | * @param quotationId 报价单编号 |
| | | */ |
| | | default void clearContractReference(Long quotationId) { |
| | | update(new LambdaUpdateWrapper<CrmSaleQuotationDO>() |
| | | .eq(CrmSaleQuotationDO::getId, quotationId) |
| | | .set(CrmSaleQuotationDO::getContractId, null) |
| | | .set(CrmSaleQuotationDO::getStatus,0) |
| | | .set(CrmSaleQuotationDO::getContractNo, null)); |
| | | } |
| | | |
| | | } |