ScrmBusinessCardMapper.xml
7.47 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
<?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.ScrmBusinessCardMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.ScrmBusinessCard">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="card_name" jdbcType="VARCHAR" property="cardName"/>
<result column="miniprogram_code" jdbcType="VARCHAR" property="miniprogramCode"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="staff_id" jdbcType="INTEGER" property="staffId"/>
<result column="operation" jdbcType="VARCHAR" property="operation"/>
<result column="skip_verify" jdbcType="INTEGER" property="skipVerify"/>
<result column="business_uuid" jdbcType="VARCHAR" property="businessUuid"/>
<result column="image" jdbcType="VARCHAR" property="image"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="qr_code" jdbcType="INTEGER" property="qrCode"/>
<result column="config_id" jdbcType="VARCHAR" property="configId"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.entmicro.entity.ScrmBusinessCard">
<!--
WARNING - @mbg.generated
-->
<result column="tag_json" jdbcType="LONGVARCHAR" property="tagJson"/>
</resultMap>
<resultMap id="BaseRpcResponseMap" type="cn.com.glsx.entmicro.model.response.businessCard.BusinessCardRpcResponse">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="card_name" jdbcType="VARCHAR" property="cardName"/>
<result column="miniprogram_code" jdbcType="VARCHAR" property="miniprogramCode"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="staff_id" jdbcType="INTEGER" property="staffId"/>
<result column="staffName" jdbcType="VARCHAR" property="staffName"/>
<result column="staffPhone" jdbcType="VARCHAR" property="staffPhone"/>
<result column="operation" jdbcType="VARCHAR" property="operation"/>
<result column="skip_verify" jdbcType="INTEGER" property="skipVerify"/>
<result column="business_uuid" jdbcType="VARCHAR" property="businessUuid"/>
<result column="image" jdbcType="VARCHAR" property="image"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="tag_json" jdbcType="VARCHAR" property="tagJson"/>
<result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
<result column="config_id" jdbcType="VARCHAR" property="configId"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, card_name, miniprogram_code, remark, staff_id, `operation`, skip_verify,
business_uuid, image, `state`,
del_flag, merchant_id, created_time, created_by, updated_time, updated_by
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
-->
tag_json
</sql>
<select id="getBusinessCardPageByCondition"
resultMap="BaseRpcResponseMap">
select
t.id,
t.card_name,
t.miniprogram_code,
t.remark,
t.staff_id,
t.skip_verify,
t.business_uuid,
t.image,
t.`state`,
t.merchant_id,
t.created_time,
t.created_by,
t.updated_time,
t.updated_by,
t.tag_json,
t.auto_welcome,
t1.staff_name as staffName,
t1.staff_phone as staffPhone
from scrm_business_card t
LEFT JOIN entmicro_staff t1 ON t1.id = t.staff_id AND t1.del_flag = 0
left join scrm_business_card_record t2 on t.id = t2.card_id AND t2.del_flag = 0
where t.del_flag = 0
<if test="condition.staffName != null and condition.staffName != ''">
AND t1.staff_name like concat('%',#{condition.staffName},'%')
</if>
<if test="condition.cardName != null and condition.cardName != ''">
AND t.card_name like concat('%',#{condition.cardName},'%')
</if>
<if test="condition.followStaff != null and condition.followStaff != ''">
AND t.follow_staff like concat('%',#{condition.followStaff},'%')
</if>
<if test="condition.statisticStartTime != null">
AND TO_DAYS(t2.last_time) <![CDATA[>=]]> TO_DAYS(#{condition.statisticStartTime})
</if>
<if test="condition.statisticEndTime != null">
AND TO_DAYS(t2.last_time) <![CDATA[<=]]> TO_DAYS(#{condition.statisticEndTime})
</if>
and t.merchant_id = #{condition.merchantId}
group by t.id
order by t.created_time desc
</select>
<select id="findCardById"
resultMap="BaseRpcResponseMap">
select t.id,
t.card_name,
t.miniprogram_code,
t.remark,
t.staff_id,
t.skip_verify,
t.business_uuid,
t.image,
t.`state`,
t.merchant_id,
t.created_time,
t.created_by,
t.updated_time,
t.updated_by,
t.tag_json,
t.auto_welcome,
t.operation,
t.qr_code,
t1.staff_name as staffName,
t1.staff_phone as staffPhone,
t.config_id
from scrm_business_card t
LEFT JOIN entmicro_staff t1 ON t1.id = t.staff_id AND t1.del_flag = 0
where t.del_flag = 0
and t.id = #{cardId}
group by t.id
</select>
<select id="findBusinessCardByPhone"
resultType="cn.com.glsx.entmicro.model.response.businessCard.BusinessCardRpcResponse">
select t2.staff_phone as staffPhone,t1.id as id,t1.merchant_id as merchantId,t1.created_time as createdTime from scrm_business_card t1
left join entmicro_staff t2 on t1.staff_id =t2.id
left join entmicro_staff_depart_relation t3 on t3.relevance_merchant=t1.merchant_id and t3.del_flag =0
where t1.del_flag =0 and t2.staff_phone=#{phone}
group by t1.id
order by t1.id desc
limit 1
</select>
</mapper>