pusong-crm/pusong-modules/pusong-business/src/main/resources/mapper/business/PsCompanyInfoMapper.xml
2024-10-21 09:10:13 +08:00

136 lines
6.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.PsCompanyInfoMapper">
<resultMap id="serviceCompanyServiceResult" type="com.pusong.business.domain.vo.PsCompanyInfoVo">
<id column="id" property="id"></id>
<collection columnPrefix="bus_" property="businessVoList" ofType="com.pusong.business.domain.vo.PsContractBusinessVo" >
<id column="id" property="id"></id>
<collection columnPrefix="det_" column="det" property="detailVoList" ofType="com.pusong.business.domain.vo.PsContractBusinessDetailVo" >
</collection>
</collection>
<collection columnPrefix="fu_" property="followUsers" ofType="com.pusong.system.domain.vo.SysUserVo" >
</collection>
<collection columnPrefix="app_" property="psApproverRecordVo" ofType="com.pusong.business.domain.vo.PsApproverRecordVo" >
</collection>
<!-- <collection column="company_id" property="psContractBusinessVos"-->
<!-- select="com.pusong.business.mapper.PsContractBusinessMapper.selectTuoGuanBusinessListByCompanyId" fetchType="eager"-->
<!-- ofType="com.pusong.business.domain.vo.PsContractBusinessVo" >-->
<!-- </collection>-->
</resultMap>
<resultMap id="serviceCompanyServiceResult2" type="com.pusong.business.domain.vo.PsCompanyInfoVo">
<id column="pcc_id" property="pccId"></id>
<collection columnPrefix="bus_" property="businessVoList" ofType="com.pusong.business.domain.vo.PsContractBusinessVo" >
<id column="id" property="id"></id>
<collection columnPrefix="det_" column="det" property="detailVoList" ofType="com.pusong.business.domain.vo.PsContractBusinessDetailVo" >
</collection>
</collection>
<collection columnPrefix="fu_" property="followUsers" ofType="com.pusong.system.domain.vo.SysUserVo" >
</collection>
</resultMap>
<select id="selectVoCustomManager" resultType="com.pusong.business.domain.vo.PsCompanyInfoVo">
select
com.*
,cus.custom_manager
<if test="contractCode != null ">
,bus.is_proxy
</if>
from ps_company_info com
left join ps_custom_info cus on cus.id = com.custom_id
<if test="contractCode != null ">
-- inner join ps_contract_company cc on cc.contract_code = ${contractCode} and cc.company_id = com.id
left join ps_contract_business bus on bus.company_id = com.id and bus.contract_code = ${contractCode}
</if>
${ew.getCustomSqlSegment}
</select>
<select id="selectPageList" resultMap="serviceCompanyServiceResult">
select
com.*,
cus.custom_manager,
cus.custom_name,
cus.custom_mobile,
cusi.custom_name custom_introducer,
usr.user_id fu_user_id,
usr.nick_name fu_nick_name
from ps_company_info com
left join ps_custom_info cus on com.custom_id = cus.id
left join ps_custom_info cusi on cus.custom_introducer = cusi.id
left join ps_company_follow cf on com.id = cf.company_id
left join sys_user usr on cf.user_id = usr.user_id
${ew.getCustomSqlSegment}
</select>
<select id="selectPageList2" resultMap="serviceCompanyServiceResult">
select
com.*,
com.id company_id,
cus.custom_manager,
cus.custom_name,
cus.custom_mobile,
cusi.custom_name custom_introducer,
usr.user_id fu_user_id,
usr.nick_name fu_nick_name,
app1.id app_id,
app1.apply_desc app_apply_desc,
app1.approver_status app_approver_status
from ps_company_info com
left join ps_custom_info cus on com.custom_id = cus.id
left join ps_custom_info cusi on cus.custom_introducer = cusi.id
left join ps_company_follow cf on com.id = cf.company_id
left join sys_user usr on cf.user_id = usr.user_id
left join (
SELECT business_id, max(apply_date) max_apply_date
FROM ps_approver_record
where business_type = 'stopAccount'
group by business_id
-- order by apply_date limit 1
) app on app.business_id = CAST(com.id AS CHAR)
left join ps_approver_record app1 on app1.apply_date = app.max_apply_date and app1.business_id = app.business_id
${ew.getCustomSqlSegment}
</select>
<select id="selectServiceCompanyList" resultMap="serviceCompanyServiceResult2">
select
--pcc.contract_code contract_code, 必须在 com.*, 上边否则company里的 contract_code值会被com表的字段覆盖
pcc.contract_code,
pcc.id pcc_id,
com.*,
bus.business_amount bus_business_amount,
bus.business_desc bus_business_desc,
bus.business_type bus_business_type,
bus.company_id bus_company_id,
bus.contract_code bus_contract_code,
bus.end_date bus_end_date,
bus.id bus_id,
bus.start_date bus_start_date,
bus.is_proxy bus_is_proxy,
bus.is_old bus_is_old,
det.id det_id,
det.business_id bus_det_business_id,
det.contract_code bus_det_contract_code,
det.business_project bus_det_business_project,
det.business_project_label bus_det_business_project_label,
det.amount bus_det_amount,
det.amount_desc bus_det_amount_desc,
det.extent_info bus_det_extent_info
from ps_company_info com
inner join ps_contract_company pcc on pcc.company_id = com.id
left join ps_contract_business bus on bus.company_id = com.id and bus.contract_code = pcc.contract_code
left join ps_contract_business_detail det on det.business_id = bus.id
${ew.getCustomSqlSegment}
</select>
</mapper>