CustomerSopJourneyMapper.xml
8.97 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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.cdp.modules.mapper.CustomerSopJourneyMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.cdp.modules.entity.CustomerSopJourney">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="one_id" jdbcType="VARCHAR" property="oneId" />
<result column="sop_journey_id" jdbcType="VARCHAR" property="sopJourneyId" />
<result column="sop_journey_stage" jdbcType="VARCHAR" property="sopJourneyStage" />
<result column="sop_journey_enter_time" jdbcType="TIMESTAMP" property="sopJourneyEnterTime" />
<result column="sop_journey_stage_enter_time" jdbcType="TIMESTAMP" property="sopJourneyStageEnterTime" />
<result column="sop_follow_up_person_id" jdbcType="VARCHAR" property="sopFollowUpPersonId" />
<result column="sop_follow_up_person_name" jdbcType="VARCHAR" property="sopFollowUpPersonName" />
<result column="sop_follow_up_person_phone" jdbcType="VARCHAR" property="sopFollowUpPersonPhone" />
<result column="sop_follow_up_person_aiSpeech" jdbcType="VARCHAR" property="sopFollowUpPersonAiSpeech" />
<result column="sop_follow_up_person_sms" jdbcType="VARCHAR" property="sopFollowUpPersonSms" />
<result column="ex_json" jdbcType="LONGVARCHAR" property="exJson" />
<result column="add_way" jdbcType="VARCHAR" property="addWay" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
</resultMap>
<resultMap id="BOResultMap" type="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" extends="BaseResultMap">
<association property="customer" javaType="cn.com.glsx.cdp.modules.model.CustomerBO">
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="one_id" jdbcType="VARCHAR" property="oneId" />
<result column="customer_name" jdbcType="VARCHAR" property="customerName" />
<result column="gender" jdbcType="CHAR" property="gender" />
<result column="birthday" jdbcType="TIMESTAMP" property="birthday" />
<result column="age" jdbcType="INTEGER" property="age" />
<result column="customer_phone" jdbcType="VARCHAR" property="customerPhone" />
<result column="customer_email" jdbcType="VARCHAR" property="customerEmail" />
<result column="id_number" jdbcType="VARCHAR" property="idNumber" />
<result column="nationality" jdbcType="VARCHAR" property="nationality" />
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="region" jdbcType="VARCHAR" property="region" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="org_user_id" jdbcType="VARCHAR" property="orgUserId" />
<result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
<result column="wechat_nickname" jdbcType="VARCHAR" property="wechatNickname" />
<result column="wechat_avatar_url" jdbcType="VARCHAR" property="wechatAvatarUrl" />
<result column="wechat_union_id" jdbcType="VARCHAR" property="wechatUnionId" />
<result column="marital_status" jdbcType="CHAR" property="maritalStatus" />
<result column="occupation" jdbcType="VARCHAR" property="occupation" />
<result column="customer_annual_income" jdbcType="DECIMAL" property="customerAnnualIncome" />
<result column="customer_company" jdbcType="VARCHAR" property="customerCompany" />
<result column="education_level" jdbcType="CHAR" property="educationLevel" />
<result column="notes" jdbcType="VARCHAR" property="notes" />
<result column="c_add_way" jdbcType="INTEGER" property="addWay" />
<result column="c_ex_json" jdbcType="LONGVARCHAR" property="exJson" />
</association>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, org_id, one_id, sop_journey_id, sop_journey_stage, sop_journey_enter_time, sop_journey_stage_enter_time,
sop_follow_up_person_id, sop_follow_up_person_name, sop_follow_up_person_phone, sop_follow_up_person_aiSpeech,
sop_follow_up_person_sms, add_way, created_by, created_time, updated_by, updated_time,
del_flag
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
-->
ex_json
</sql>
<sql id="base_param" >
csj.del_flag = 0
<if test="oneId != null">
and csj.one_id = #{oneId}
</if>
<if test="oneIds != null and oneIds.size()>0">
and csj.one_id in
<foreach collection="oneIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopJourneyId != null">
and csj.sop_journey_id = #{sopJourneyId}
</if>
<if test="sopJourneyIds != null and sopJourneyIds.size()>0">
and csj.sop_journey_id in
<foreach collection="sopJourneyIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopJourneyStages != null and sopJourneyStages.size()>0">
and csj.sop_journey_stage in
<foreach collection="sopJourneyStages" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhones != null and customerPhones.size()>0">
and c.customer_phone in
<foreach collection="customerPhones" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="customerPhone != null and customerPhone != ''">
and c.customer_phone like CONCAT('%', #{customerPhone},'%')
</if>
<if test="customerName != null and customerName != ''">
and c.customer_name like CONCAT('%', #{customerName},'%')
</if>
<if test="wechatNickname != null and wechatNickname != ''">
and c.wechat_nickname like CONCAT('%', #{wechatNickname},'%')
</if>
<if test="sopFollowUpPersonIds != null and sopFollowUpPersonIds.size()>0">
and csj.sop_follow_up_person_id in
<foreach collection="sopFollowUpPersonIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sopFollowUpPersonPhone != null and sopFollowUpPersonPhone != ''">
and csj.sop_follow_up_person_phone = #{sopFollowUpPersonPhone}
</if>
<if test="sopJourneyEnterTimeBegin != null and sopJourneyEnterTimeBegin != ''">
and csj.sop_journey_enter_time >= #{sopJourneyEnterTimeBegin}
</if>
<if test="sopJourneyEnterTimeEnd != null and sopJourneyEnterTimeEnd != ''">
and csj.sop_journey_enter_time <= #{sopJourneyEnterTimeEnd}
</if>
</sql>
<select id="listCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" resultMap="BOResultMap">
select
csj.id, csj.org_id, csj.one_id, csj.sop_journey_id, csj.sop_journey_stage,
csj.sop_journey_enter_time, csj.sop_journey_stage_enter_time, csj.sop_follow_up_person_id,
csj.sop_follow_up_person_name, csj.sop_follow_up_person_phone, csj.sop_follow_up_person_aiSpeech,
csj.sop_follow_up_person_sms, csj.add_way,
c.customer_name, c.gender, c.birthday, c.age, c.customer_phone, c.customer_email,
c.id_number, c.nationality, c.province, c.city, c.region, c.address, c.marital_status,
c.occupation, c.customer_annual_income, c.customer_company, c.education_level, c.notes, c.wechat_id,
c.wechat_nickname, c.wechat_avatar_url, c.wechat_union_id,
c.add_way as c_add_way
from cdp_customer_sop_journey csj
left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
<where>
<include refid="base_param" />
</where>
</select>
<select id="statisticsCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO"
resultType="cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyStatisticsDTO">
select
csj.sop_journey_id as sopJourneyId,
csj.sop_journey_stage as sopJourneyStage,
count(csj.id) as count
from cdp_customer_sop_journey csj
left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
<where>
<include refid="base_param" />
</where>
group by csj.sop_journey_id, csj.sop_journey_stage
</select>
<select id="customerSopJourneyCount" resultType="java.util.Map"
parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO">
select
csj.sop_journey_stage as sop_journey_stage,count(1) as count
from cdp_customer_sop_journey csj
left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
<where>
<include refid="base_param" />
</where>
group by csj.sop_journey_stage
</select>
</mapper>