pusong-crm/pusong-modules/pusong-business/src/main/resources/mapper/business/PsCustomInfoMapper.xml
1073413548 60610275f7 commit
2024-08-20 09:30:51 +08:00

66 lines
2.7 KiB
XML

<?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_introducer 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,
con.contractCode,
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,
custom.company_adress,
custom.company_name,
custom.customer_num,
custom.customer_cert,
custom.legal_person_name,
custom.legal_person_idcard,
custom.legal_person_phone,
(select GROUP_CONCAT(appoint.executor SEPARATOR ',')
from ps_task_appoint appoint where appoint.task_id = task.id) as executors,
info.sign_desc
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>