liyong
2026-04-20 0ef7f96095ae8f4e37c99b9ef226cce5554f3450
feat(customer): 添加客户档案新增字段并优化删除逻辑

- 在CustomerPrivate实体类中新增法人、传真、开户行、代理四个字段
- 在CustomerPrivatePoolDto数据传输对象中同步新增四个字段定义
- 更新CustomerPrivatePoolMapper.xml映射文件中的查询语句,包含新字段
- 为查询条件添加boundId筛选功能
- 优化客户删除逻辑,检查并阻止删除存在私海数据的客户档案
- 修改销售台账导出功能,使用统一的客户池DTO对象获取客户信息
已修改6个文件
89 ■■■■ 文件已修改
src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java
@@ -121,4 +121,26 @@
    private List<Long> ids;
    @ApiModelProperty(value = "法人")
    @Excel(name = "法人")
    @TableField(value = "corporation")
    private String corporation;
    @ApiModelProperty(value = "传真")
    @Excel(name = "传真")
    @TableField(value = "fax")
    private String fax;
    @ApiModelProperty(value = "开户行")
    @Excel(name = "开户行")
    @TableField(value = "bank_name")
    private String bankName;
    @ApiModelProperty(value = "代理")
    @Excel(name = "代理")
    @TableField(value = "agent")
    private String agent;
}
src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java
@@ -88,6 +88,28 @@
    @Excel(name = "客户分类")
    private String customerType;
    @ApiModelProperty(value = "法人")
    @Excel(name = "法人")
    @TableField(value = "corporation")
    private String corporation;
    @ApiModelProperty(value = "传真")
    @Excel(name = "传真")
    @TableField(value = "fax")
    private String fax;
    @ApiModelProperty(value = "开户行")
    @Excel(name = "开户行")
    @TableField(value = "bank_name")
    private String bankName;
    @ApiModelProperty(value = "代理")
    @Excel(name = "代理")
    @TableField(value = "agent")
    private String agent;
    @ApiModelProperty("创建人ID")
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -185,12 +185,15 @@
        if (!salesLedgers.isEmpty()) {
            throw new RuntimeException("客户档案下有销售合同,请先删除销售合同");
        }
        //  删除客户的同时也需要删除对应的客户跟随、附件和回访提醒
        for (Long id : ids) {
            customerFollowUpService.deleteByCustomerId(id);
            customerReturnVisitService.deleteByCustomerId(id);
        List<CustomerPrivatePool> customerPrivatePools = customerPrivatePoolMapper.selectList(new QueryWrapper<CustomerPrivatePool>().lambda().in(CustomerPrivatePool::getCustomerId, idList));
        if (!customerPrivatePools.isEmpty()) {
            throw new RuntimeException("客户档案下有客户私海,请先收回私海数据");
        }
        //  删除客户的同时也需要删除对应的客户跟随、附件和回访提醒
//        for (Long id : ids) {
//            customerFollowUpService.deleteByCustomerId(id);
//            customerReturnVisitService.deleteByCustomerId(id);
//        }
        return customerMapper.deleteBatchIds(idList);
    }
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -480,14 +480,15 @@
        exportProcessContract.setId(id);
        SalesLedger salesLedger = salesLedgerMapper.selectById(id);
        // 查询客户公司信息
        Customer customer = customerMapper.selectById(salesLedger.getCustomerId());
        CustomerPrivatePoolDto customerPrivatePoolDto = customerPrivatePoolMapper.selectInfo(salesLedger.getCustomerId());
        exportProcessContract.setCreateTime(LocalDateTimeUtil.format(Optional.ofNullable(salesLedger.getExecutionDate()).orElse(LocalDate.now()), "yyyy年MM月dd日"));
        exportProcessContract.setRemark(Optional.ofNullable(salesLedger.getRemarks()).orElse("无")); // 备注
        exportProcessContract.setPlaceOfSinging(Optional.ofNullable(salesLedger.getPlaceOfSinging()).orElse(""));
        // 填写甲方信息
        ExportProcessContractVo.Customer partyA = ExportProcessContractVo.Customer.getCustomer(customer);
        exportProcessContract.setPartyAClientName(customer.getCustomerName());
        ExportProcessContractVo.Customer partyA = ExportProcessContractVo.Customer.getCustomer(customerPrivatePoolDto);
        exportProcessContract.setPartyAClientName(customerPrivatePoolDto.getCustomerName());
        exportProcessContract.setPartyA(partyA);
        // 填写乙方信息
src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java
@@ -83,7 +83,7 @@
        // 邮编
        private String postCode = "";
        public static ExportProcessContractVo.Customer getCustomer(com.ruoyi.basic.pojo.Customer customer) {
        public static ExportProcessContractVo.Customer getCustomer(com.ruoyi.basic.dto.CustomerPrivatePoolDto customer) {
            ExportProcessContractVo.Customer partyA = new ExportProcessContractVo.Customer();
            partyA.setFax(Optional.ofNullable(customer.getFax()).orElse(""));
            partyA.setAddress(padRight(customer.getCompanyAddress(), 15));
src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
@@ -29,7 +29,11 @@
        coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
        coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
        coalesce(c.bank_account, cp.bank_account) as bank_account,
        coalesce(c.bank_code, cp.bank_code) as bank_code
        coalesce(c.bank_code, cp.bank_code) as bank_code,
        coalesce(c.corporation, cp.corporation) as corporation,
        coalesce(c.fax, cp.fax) as fax,
        coalesce(c.agent, cp.agent) as agent,
        coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
        left join customer c on c.id = cpp.customer_id and cpp.type = 1
        left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
@@ -40,6 +44,9 @@
            </if>
            <if test="c.customerType != null">
                and c.customer_type = #{c.customerType}
            </if>
            <if test="c.boundId != null">
                and cpp.bound_id = #{c.boundId}
            </if>
        </where>
        order by cpp.id desc
@@ -61,7 +68,11 @@
               coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
               coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
               coalesce(c.bank_account, cp.bank_account) as bank_account,
               coalesce(c.bank_code, cp.bank_code) as bank_code
               coalesce(c.bank_code, cp.bank_code) as bank_code,
               coalesce(c.corporation, cp.corporation) as corporation,
               coalesce(c.fax, cp.fax) as fax,
               coalesce(c.agent, cp.agent) as agent,
               coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
                 left join customer c on c.id = cpp.customer_id and cpp.type = 1
                 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
@@ -89,9 +100,13 @@
               coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
               coalesce(c.bank_account, cp.bank_account) as bank_account,
               coalesce(c.bank_code, cp.bank_code) as bank_code
            coalesce(c.corporation, cp.corporation) as corporation,
               coalesce(c.fax, cp.fax) as fax,
               coalesce(c.agent, cp.agent) as agent,
               coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
                 left join customer c on c.id = cpp.customer_id and cpp.type = 1
                 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
            left join customer c on c.id = cpp.customer_id and cpp.type = 1
            left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
    </select>
</mapper>