pusong-crm/pusong-modules/pusong-business/src/main/resources/mapper/business/PsCustomInfoMapper.xml

71 lines
3.0 KiB
XML
Raw Normal View History

2024-07-26 17:44:59 +08:00
<?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">
2024-08-02 10:36:59 +08:00
<sql id="queryCustomerList" >
2024-07-26 17:44:59 +08:00
SELECT info.*
, usr.nick_name as custom_manager_name
2024-07-31 17:04:22 +08:00
,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
2024-07-26 17:44:59 +08:00
FROM ps_custom_info info
2024-08-02 10:36:59 +08:00
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>
2024-08-20 09:30:51 +08:00
<select id="selectPagePublicCustomerList" resultType="com.pusong.business.domain.vo.PsCustomInfoVo">
<include refid="queryCustomerList"/>
${ew.getCustomSqlSegment}
</select>
2024-08-02 10:36:59 +08:00
<select id="selectCustomerList" resultType="com.pusong.business.domain.vo.PsCustomInfoVo">
<include refid="queryCustomerList"/>
${ew.getCustomSqlSegment}
2024-07-26 17:44:59 +08:00
</select>
2024-08-14 11:27:26 +08:00
<select id="selectPageCustomerRecordList" resultType="com.pusong.business.domain.vo.PsCustomerRecordVo">
select
custom.id,
2024-08-26 18:08:49 +08:00
custom.create_time,
custom.custom_status,
con.contract_code,
2024-08-14 11:27:26 +08:00
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,
2024-08-26 18:08:49 +08:00
com.company_adress,
com.company_name,
com.customer_num,
com.customer_cert,
com.legal_person_name,
com.legal_person_idcard,
com.legal_person_phone,
2024-08-14 11:27:26 +08:00
(select GROUP_CONCAT(appoint.executor SEPARATOR ',')
from ps_task_appoint appoint where appoint.task_id = task.id) as executors,
2024-08-26 18:08:49 +08:00
con.sign_desc,
con.contract_amount,
con.finish_date,
(select par.approver_status from ps_approver_record par where par.contract_code = con.contract_code and business_type = 'free' limit 0,1) approver_status
2024-08-14 11:27:26 +08:00
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>
2024-07-26 17:44:59 +08:00
</mapper>