DracImInfoMapper.xml
5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?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="cn.com.glsx.entmicro.mapper.DracImInfoMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.DracImInfo">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="im_state" jdbcType="VARCHAR" property="imState"/>
<result column="im_type" jdbcType="INTEGER" property="imType"/>
<result column="customer_count" jdbcType="INTEGER" property="customerCount"/>
<result column="im_status" jdbcType="INTEGER" property="imStatus"/>
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
</resultMap>
<resultMap id="resultMap" type="cn.com.glsx.entmicro.model.response.DracImInfoResponse">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="im_state" jdbcType="VARCHAR" property="imState"/>
<result column="customer_count" jdbcType="INTEGER" property="customerCount"/>
<result column="im_status" jdbcType="INTEGER" property="imStatus"/>
<result column="im_uid" jdbcType="VARCHAR" property="uuid"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="staffId" jdbcType="INTEGER" property="staffId"/>
<result column="im_name" jdbcType="INTEGER" property="imName"/>
<result column="tagging" jdbcType="VARCHAR" property="tagging"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.entmicro.entity.DracImInfo">
<!--
WARNING - @mbg.generated
-->
<result column="tagging" jdbcType="LONGVARCHAR" property="tagging"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, im_state, im_type, customer_count, im_status, del_flag, merchant_id, created_by,
created_time, updated_by, updated_time
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
-->
tagging
</sql>
<select id="findMerchantByPage" resultMap="resultMap">
select * from drac_im_info
where im_type=2
and merchant_id=#{dracImInfoRequest.merchantId}
<if test="dracImInfoRequest.imStatus != null ">
and im_status=#{dracImInfoRequest.imStatus}
</if>
<if test="dracImInfoRequest.imUid != null ">
and im_uid like concat ('%',#{dracImInfoRequest.imUid},'%')
</if>
<if test="dracImInfoRequest.imName != null ">
and im_Name like concat ('%',#{dracImInfoRequest.imName},'%')
</if>
<if test="dracImInfoRequest.beginTime != null ">
and DATE_FORMAT(created_time,'%Y-%m-%d')<![CDATA[>=]]>
DATE_FORMAT(#{dracImInfoRequest.beginTime},'%Y-%m-%d')
</if>
<if test="dracImInfoRequest.endTime != null ">
and DATE_FORMAT(created_time,'%Y-%m-%d')<![CDATA[<=]]>DATE_FORMAT(#{dracImInfoRequest.endTime},'%Y-%m-%d')
</if>
order by created_time desc
</select>
<select id="findDramImByCode" resultMap="resultMap">
select t3.*,t1.phone from drac_im_customer_collection t1
left join drac_channel_code t2 on t1.code_id=t2.id
LEFT join drac_im_info t3 on t1.im_id=t3.id
where t2.code_state=#{state}
</select>
<select id="findFirstNotAddEntmicroImCustomer" resultType="java.lang.String">
SELECT sm.customer_phone FROM scrm_customer_merge sm
WHERE sm.is_join=0 AND merchant_id=#{merchantId} AND sm.customer_phone IS NOT NULL AND NOT EXISTS
(SELECT dc.phone FROM drac_im_info di
LEFT JOIN drac_im_customer_collection dc ON di.id=dc.im_id WHERE merchant_id=#{merchantId} AND di.im_type=1 AND sm.customer_phone=dc.phone)
</select>
<select id="findSecondNotAddEntmicroImCustomer" resultType="java.lang.String">
SELECT sm.customer_phone FROM scrm_customer_merge sm
WHERE sm.is_join=0 AND merchant_id=#{merchantId} AND sm.customer_phone IS NOT NULL AND EXISTS
(SELECT dc.phone FROM drac_im_info di
LEFT JOIN drac_im_customer_collection dc ON di.id=dc.im_id WHERE merchant_id=#{merchantId} AND di.im_type=1 AND
TIMESTAMPDIFF(DAY,dc.created_time,NOW())>=30
AND sm.customer_phone=dc.phone)
AND NOT EXISTS
(SELECT dc.phone FROM drac_im_info di
LEFT JOIN drac_im_customer_collection dc ON di.id=dc.im_id WHERE merchant_id=#{merchantId} AND di.im_type=1 AND di.im_count=2
AND sm.customer_phone=dc.phone)
</select>
<select id="findAddEntmicroImCustomer" resultType="java.lang.String">
SELECT sm.customer_phone FROM scrm_customer_merge sm
WHERE sm.is_join=1 AND merchant_id=#{merchantId}
and sm.customer_phone in
<foreach collection="phones" open="(" close=")" separator="," item="id">
#{id}
</foreach>
union all
SELECT dc.phone FROM drac_im_info di
LEFT JOIN drac_im_customer_collection dc ON di.id=dc.im_id WHERE merchant_id=#{merchantId} AND di.im_type=1 AND dc.phone
in
<foreach collection="phones" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</select>
</mapper>