liyong
2026-07-03 bee96a1d36c86068cd5a7eb69f4e3294a8123b04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package cn.iocoder.yudao.module.crm.dal.mysql.quotation;
 
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 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;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum;
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
import org.apache.ibatis.annotations.Mapper;
 
import java.util.List;
 
/**
 * CRM 销售报价单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CrmSaleQuotationMapper extends BaseMapperX<CrmSaleQuotationDO> {
 
    default CrmSaleQuotationDO selectByNo(String no) {
        return selectOne(CrmSaleQuotationDO::getNo, no);
    }
 
    default PageResult<CrmSaleQuotationDO> selectPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId) {
        MPJLambdaWrapperX<CrmSaleQuotationDO> query = new MPJLambdaWrapperX<>();
        // 拼接数据权限的查询条件
        CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_SALE_QUOTATION.getType(),
                CrmSaleQuotationDO::getId, userId, pageReqVO.getSceneType());
        // 拼接自身的查询条件
        query.selectAll(CrmSaleQuotationDO.class)
                .likeIfPresent(CrmSaleQuotationDO::getNo, pageReqVO.getNo())
                .likeIfPresent(CrmSaleQuotationDO::getName, pageReqVO.getName())
                .eqIfPresent(CrmSaleQuotationDO::getCustomerId, pageReqVO.getCustomerId())
                .eqIfPresent(CrmSaleQuotationDO::getBusinessId, pageReqVO.getBusinessId())
                .eqIfPresent(CrmSaleQuotationDO::getStatus, pageReqVO.getStatus())
                .orderByDesc(CrmSaleQuotationDO::getId);
        return selectJoinPage(pageReqVO, CrmSaleQuotationDO.class, query);
    }
 
    default PageResult<CrmSaleQuotationDO> selectPageByCustomerId(CrmSaleQuotationPageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmSaleQuotationDO>()
                .eq(CrmSaleQuotationDO::getCustomerId, pageReqVO.getCustomerId())
                .likeIfPresent(CrmSaleQuotationDO::getNo, pageReqVO.getNo())
                .likeIfPresent(CrmSaleQuotationDO::getName, pageReqVO.getName())
                .orderByDesc(CrmSaleQuotationDO::getId));
    }
 
    default PageResult<CrmSaleQuotationDO> selectPageByBusinessId(CrmSaleQuotationPageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmSaleQuotationDO>()
                .eq(CrmSaleQuotationDO::getBusinessId, pageReqVO.getBusinessId())
                .likeIfPresent(CrmSaleQuotationDO::getNo, pageReqVO.getNo())
                .likeIfPresent(CrmSaleQuotationDO::getName, pageReqVO.getName())
                .orderByDesc(CrmSaleQuotationDO::getId));
    }
 
    default List<CrmSaleQuotationDO> selectListByCustomerId(Long customerId) {
        return selectList(CrmSaleQuotationDO::getCustomerId, customerId);
    }
 
    default List<CrmSaleQuotationDO> selectListByBusinessId(Long businessId) {
        return selectList(CrmSaleQuotationDO::getBusinessId, businessId);
    }
 
    default Long selectCountByBusinessId(Long businessId) {
        return selectCount(CrmSaleQuotationDO::getBusinessId, businessId);
    }
 
    default Long selectCountByCustomerId(Long customerId) {
        return selectCount(CrmSaleQuotationDO::getCustomerId, customerId);
    }
 
}