You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.8 KiB

<?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.epmet.dao.crm.CustomerRelationDao">
<resultMap id="CustomerSubInfoDTOResMap" type="com.epmet.dto.indexcal.CustomerSubInfoDTO">
<result property="customerId" column="customerId"></result>
<result property="customerAreaCode" column="customerAreaCode"></result>
<collection property="subCustomerIds" ofType="java.lang.String">
<result column="subCustomerId"/>
</collection>
</resultMap>
<!-- 查询当前客户的area_code信息、以及下一级客户列表 -->
<select id="selectCustomerSubInfo" parameterType="map" resultMap="CustomerSubInfoDTOResMap">
SELECT
CR.PARENT_CUSTOMER_ID AS customerId,
CR.CUSTOMER_ID AS subCustomerId,
(select c.AREA_CODE from customer_relation c where c.del_flag='0' and c.CUSTOMER_ID=#{customerId}) as customerAreaCode
FROM
customer_relation cr
WHERE
cr.DEL_FLAG = '0'
AND cr.`STATUS` = 'open'
AND cr.PARENT_CUSTOMER_ID =#{customerId}
</select>
<select id="selectListByPids" parameterType="java.lang.String" resultType="com.epmet.entity.crm.CustomerRelationEntity">
SELECT
*
FROM
customer_relation cr
WHERE
cr.DEL_FLAG = '0'
AND cr.PIDS LIKE CONCAT(
#{customerId},
'%')
</select>
<!-- 查询子级客户 -->
<select id="selectSubCustomer" resultType="com.epmet.entity.crm.CustomerRelationEntity">
SELECT * FROM customer_relation WHERE DEL_FLAG = 0 AND PARENT_CUSTOMER_ID = #{customerId}
</select>
</mapper>