CustomerBaseStatisticsMapper.xml
3.02 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
<?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.CustomerBaseStatisticsMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.CustomerBaseStatistics">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="merchantId" jdbcType="INTEGER" property="merchantId"/>
<result column="statistics_date" jdbcType="VARCHAR" property="statisticsDate"/>
<result column="new_customer_count" jdbcType="INTEGER" property="newCustomerCount"/>
<result column="total_count" jdbcType="INTEGER" property="totalCount"/>
<result column="del_customer_count" jdbcType="INTEGER" property="delCustomerCount"/>
<result column="customer_base_id" jdbcType="INTEGER" property="customerBaseId"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, merchantId, statistics_date, new_customer_count, total_count,del_customer_count,customer_base_id
</sql>
<select id="getBaseCusAllList" resultType="cn.com.glsx.entmicro.model.response.StoreCollectViewResponse">
SELECT count(DISTINCT sc.id) packmenberCount
from scrm_customer sc
left JOIN scrm_customer_base_relation scbr on (scbr.customer_id = sc.id and scbr.type=2)
left JOIN scrm_customer_base scb ON scb.id = scbr.customer_base_id
left join entmicro_customer_follow ef on sc.id=ef.customer_id
left join entmicro_staff_depart_relation er on er.staff_id=ef.staff_id
where scb.del_flag = 0
and scbr.del_flag = 0
and er.relevance_merchant in
<foreach collection="merchantIds" item="merchantId" separator="," open="(" close=")">
#{merchantId}
</foreach>
<!--开始时间-->
<if test="date!=null">
and DATEDIFF(join_time, DATE_FORMAT(#{date}, '%Y-%m-%d')) <![CDATA[<=]]> 0
</if>
</select>
<select id="getAddBaseCusList" resultType="cn.com.glsx.entmicro.model.response.StoreCollectViewResponse">
SELECT count(DISTINCT sc.id) todayAddPackmenberCount
from scrm_customer sc
left JOIN scrm_customer_base_relation scbr on (scbr.customer_id = sc.id and scbr.type=2)
left JOIN scrm_customer_base scb ON scb.id = scbr.customer_base_id
left join entmicro_customer_follow ef on sc.id=ef.customer_id
left join entmicro_staff_depart_relation er on er.staff_id=ef.staff_id
where scb.del_flag = 0
and scbr.del_flag = 0
and sc.del_flag = 0
and er.relevance_merchant in
<foreach collection="merchantIds" item="merchantId" separator="," open="(" close=")">
#{merchantId}
</foreach>
<!--开始时间-->
<if test="date!=null">
and DATEDIFF(join_time, DATE_FORMAT(#{date}, '%Y-%m-%d')) = 0
</if>
</select>
</mapper>