CustomerBaseStatisticsMapper.xml 3.02 KB
<?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>