GroupOneMapper.xml
3.89 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
<?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.GroupOneMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.GroupOne">
<!--@Table scrm_group_one-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="template_id" jdbcType="INTEGER" property="templateId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="chat_id" jdbcType="VARCHAR" property="chatId" />
<result column="created_by" jdbcType="INTEGER" property="createdBy" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
</resultMap>
<resultMap id="ResultMap" type="cn.com.glsx.entmicro.model.response.GroupOneResponse"
extends="BaseResultMap">
</resultMap>
<sql id="Base_Column_List">
id, template_id, user_id, chat_id, created_by, created_time, del_flag
</sql>
<select id="selectByTemplateId" parameterType="map" resultMap="ResultMap">
select <include refid="Base_Column_List" /> from scrm_group_one
where 1 = 1 and del_flag = 0
<if test="templateId != null">
and template_id = #{templateId,jdbcType=INTEGER}
</if>
<if test="startTime != null">
and created_time <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
and created_time <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
</if>
</select>
<!--chatId查一客一群-->
<select id="getGroupOneByChatId" resultMap="ResultMap">
select <include refid="Base_Column_List" />
from scrm_group_one
where chat_id = #{chatId}
</select>
<select id="selectGroupOneCustomers" resultType="cn.com.glsx.entmicro.model.response.GroupOneCustomerDetailResponse">
SELECT c.`id` as id,o.`template_id` as templateId,t.`merchant_id` as merchantId,c.`customer_name` as customerName,
c.`type` as `type`,c.`avatar` as avatar,b.`created_time` as createdTime,o.`chat_id` as chatId,b.`chat_name` as chatName,
b.`lord` as lord,b.`del_flag` as delFlag,b.`updated_time` as disMiss
FROM `scrm_group_one` o
LEFT JOIN `scrm_customer` c ON c.`user_id`=o.`user_id`
LEFT JOIN `scrm_group_one_template` t ON t.`id`=o.`template_id`
LEFT JOIN `scrm_customer_base` b ON b.`chat_id`=o.`chat_id`
WHERE o.`template_id`=#{templateId} AND t.`merchant_id`=#{merchantId}
AND c.`user_id` IS NOT NULL
</select>
<select id="selectLord" resultType="cn.com.glsx.entmicro.model.response.GroupOneCustomerDetailResponse">
SELECT s.`staff_name` as lordName,r.`department_id` as departmentId,d.`department_name` as departName,b.`chat_id` as chatId,r.`relevance_merchant` as merchatId
FROM `entmicro_staff` s
LEFT JOIN `scrm_customer_base` b ON b.`lord`=s.`user_id`
LEFT JOIN `entmicro_staff_depart_relation` r ON r.`staff_id`=s.`id`
LEFT JOIN `entmicro_department` d ON d.`id` = r.`department_id`
WHERE b.`chat_id`
IN <foreach collection="chatIds" open="(" separator="," close=")" item="chatId">
#{chatId}
</foreach>
GROUP BY b.`chat_id`
</select>
<select id="getOneGroupCount"
resultType="cn.com.glsx.entmicro.model.response.oneGroup.OneGroupStaffCountRpcResponse">
SELECT s.`id` staffId,sr.`user_oneid` oneId,q.`chat_id` chatId,sr.`relevance_merchant` merchantId,COUNT(1) groupCount FROM `scrm_customer_base` q
LEFT JOIN `scrm_customer_base_relation` r ON r.`customer_base_id`=q.`id`
LEFT JOIN `entmicro_staff` s ON s.`id`=r.`customer_id`
LEFT JOIN `entmicro_staff_depart_relation` sr ON sr.`staff_id`=s.`id`
WHERE sr.`relevance_merchant`=#{request.merchantId} AND q.`creation_method`=2 AND q.`del_flag`=0
AND r.`del_flag`=0 AND s.`del_flag`=0 AND sr.`del_flag`=0 GROUP BY s.`id`,q.`chat_id`
</select>
</mapper>