<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.pusong.business.mapper.PsCustomInfoMapper"> <sql id="queryCustomerList" > SELECT info.* , usr.nick_name as custom_manager_name ,psinfo.custom_name as custom_introducer_name, EXISTS(SELECT * FROM ps_contract_info coninfo WHERE coninfo.custom_id = info.id and coninfo.contract_status != '10') have_contract FROM ps_custom_info info left join sys_user usr on info.custom_manager = usr.user_id left join ps_custom_info psinfo on info.custom_introducer = psinfo.id </sql> <select id="selectPageCustomerList" resultType="com.pusong.business.domain.vo.PsCustomInfoVo"> <include refid="queryCustomerList"/> ${ew.getCustomSqlSegment} </select> <select id="selectPagePublicCustomerList" resultType="com.pusong.business.domain.vo.PsCustomInfoVo"> <include refid="queryCustomerList"/> ${ew.getCustomSqlSegment} </select> <select id="selectCustomerList" resultType="com.pusong.business.domain.vo.PsCustomInfoVo"> <include refid="queryCustomerList"/> ${ew.getCustomSqlSegment} </select> <select id="selectPageCustomerRecordList" resultType="com.pusong.business.domain.vo.PsCustomerRecordVo"> select custom.id, custom.create_time, custom.custom_status, custom.custom_source, (select pci.custom_name from ps_custom_info pci where pci.id = custom.custom_introducer limit 0,1) custom_introducer, con.contract_code, custom.custom_name, custom.custom_mobile, (select GROUP_CONCAT(business.business_type SEPARATOR ',') from ps_contract_business business where business.contract_code = con.contract_code) as business_type_name, task.start_date, com.finance_account_no, custom.custom_manager, com.company_adress, com.company_name, com.customer_num, com.customer_cert, com.legal_person_name, com.legal_person_idcard, com.legal_person_phone, (select GROUP_CONCAT(appoint.executor SEPARATOR ',') from ps_task_appoint appoint where appoint.task_id = task.id) as executors, con.sign_desc, con.contract_amount, con.finish_date, con.confirm_ossid, (select par.approver_status from ps_approver_record par where par.contract_code = con.contract_code and business_type = 'free' order by id desc limit 0,1) approver_status from ps_custom_info custom left join (select * from ps_task_main main where main.start_date in (select max(ma.start_date) start_date from ps_task_main ma group by ma.custom_id)) task on custom.id = task.custom_id left join ps_company_info com on com.id = task.company_id left join ps_contract_info con on con.contract_code = task.contract_code ${ew.getCustomSqlSegment} </select> </mapper>