<?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.kiisoo.ic.customer.mapper.OpCustomerDOMapper" >
<select id= "selectCustomerInfoByShopIds" resultType= "com.kiisoo.ic.customer.bean.OpCustomerDTO" >
select
t2.id,t2.`name`,
t2.member_id as idCard,GROUP_CONCAT(DISTINCT t0.`name`) as shopName,
GROUP_CONCAT(DISTINCT t4.`name`) as sellerName, t3.birthday, t2.phone,
t3.name as vipName,t3.phone as vipPhone
from
poi_store t0,
op_seller_customer_relation t1 LEFT JOIN privilage_user t4 on t1.user_id = t4.id,
op_customer t2 LEFT JOIN op_vip t3 on t2.member_id = t3.id
where t0.id = t1.store_id and t1.customer_id = t2.id
<choose >
<when test= "shopId != null and shopId.size > 0 " >
and t1.store_id in
<foreach collection= "shopId" index= "index" item= "item" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</when>
<otherwise >
and 1 = 0
</otherwise>
</choose>
<if test= "startDate != null" >
and t1.create_time >= #{startDate}
</if>
<if test= "endDate != null" >
and t1.create_time <![CDATA[ <= ]]> #{endDate}
</if>
GROUP BY t2.id
order by t2.id asc
</select>
<select id= "selectCustomerInfoBySellerId" resultType= "com.kiisoo.ic.customer.bean.OpCustomerDTO" >
select
t2.id,t2.`name`,t2.member_id as idCard,GROUP_CONCAT(DISTINCT t0.`name`) as shopName, GROUP_CONCAT(DISTINCT t4.`name`) as sellerName, t3.birthday, t2.phone
,t3.name as vipName,t3.phone as vipPhone
from
poi_store t0,
op_seller_customer_relation t1 LEFT JOIN privilage_user t4 on t1.user_id = t4.id,
op_customer t2 LEFT JOIN op_vip t3 on t2.member_id = t3.id
where t0.id = t1.store_id and t1.customer_id = t2.id
and t1.user_id = #{sellerId}
<if test= "startDate != null" >
and t1.create_time >= #{startDate}
</if>
<if test= "endDate != null" >
and t1.create_time <![CDATA[ <= ]]> #{endDate}
</if>
GROUP BY t2.id
order by t2.id asc
</select>
</mapper>