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.
 
 
 
 
 

35 lines
1.6 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="customerName" column="customerName"></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,
dc.CUSTOMER_NAME AS customerName,
dc.AREA_CODE AS customerAreaCode,
CR.CUSTOMER_ID AS subCustomerId
FROM
customer_relation cr
LEFT JOIN dim_customer dc ON ( cr.PARENT_CUSTOMER_ID = DC.ID and dc.del_flag='0')
WHERE
cr.DEL_FLAG = '0'
AND cr.`STATUS` = 'open'
AND cr.PARENT_CUSTOMER_ID != '0'
<if test="null !=list and list.size()>0">
AND cr.PARENT_CUSTOMER_ID IN
<foreach collection="list" item="customerId" index="index" open="(" close=")" separator=",">
#{customerId}
</foreach>
</if>
</select>
</mapper>