SecretReportHistoryMapper.xml 5.3 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.fw.valhalla.dao.mapper.SecretReportHistoryMapper">
    <select
            id="secretReportList"
            resultType="cn.fw.valhalla.domain.dto.SecretReportHistoryDTO"
            parameterType="cn.fw.valhalla.domain.query.SecretReportHistoryQuery"
    >
        SELECT t1.id,
        t1.task_id                              task_id,
        t1.task_type                            follow_type,
        t1.follow_record_id                     follow_record_id,
        t1.first_call                           first_call,
        t1.call_id                              call_id,
        t1.staff_id                             staff_id,
        t1.staff_name                           staff_name,
        t1.customer_id                          customer_id,
        t1.customer_id                          customer_id,
        if(t1.task_type=3 , t4.name, t3.name)   customer_name,
        if(t1.task_type=3 , t4.plate_no, t2.plate_no) plate_no,
        t1.call_type                            dial_type,
        t1.call_time                            call_time,
        t1.call_duration                        call_duration,
        t1.shop_id                              shop_id,
        t1.group_id                             group_id
        FROM secret_report_history t1
        left join customer t2 on t1.customer_id = t2.id
        left join customer_base_info t3 on t2.base_id = t3.id
        left join accident_pool t4 on t1.customer_id = t4.id
        <where>
            <if test="condition.groupId !=null">
                and t1.group_id = #{condition.groupId}
            </if>
            <if test="condition.userId !=null">
                and t1.staff_id = #{condition.userId}
            </if>
            <if test="condition.userName !=null and condition.userName != ''">
                and t1.staff_name like concat('%', #{condition.userName}, '%')
            </if>
            <if test="condition.plateNo != null and condition.plateNo !=''">
                and (t2.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', #{condition.plateNo}, '%'))
            </if>
            <if test="condition.customerName != null and condition.customerName !=''">
                and (t3.name like concat('%', #{condition.customerName}, '%') or t4.name like concat('%', #{condition.customerName}, '%'))
            </if>
            <if test="condition.shopIds !=null">
                and  t1.shop_id in
                <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.taskType !=null">
                and t1.task_type = #{condition.taskType}
            </if>
            <if test="condition.startTime1 !=null">
                and t1.call_time >= #{condition.startTime1}
            </if>
            <if test="condition.startTime2 !=null">
                and t1.call_time &lt;=  #{condition.startTime2}
            </if>
        </where>
        <if test="condition.orderString != null and condition.orderString !='' ">
            ${condition.orderString}
        </if>
        limit #{startIndex},#{pageSize};
    </select>


    <select
            id="secretReportCount"
            resultType="java.lang.Long"
            parameterType="cn.fw.valhalla.domain.query.SecretReportHistoryQuery"
    >
        SELECT count(t1.id)
        FROM secret_report_history t1
        left join customer t2 on t1.customer_id = t2.id
        left join customer_base_info t3 on t2.base_id = t3.id
        left join accident_pool t4 on t1.customer_id = t4.id
        <where>
            <if test="condition.groupId !=null">
                and t1.group_id = #{condition.groupId}
            </if>
            <if test="condition.userId !=null">
                and t1.staff_id = #{condition.userId}
            </if>
            <if test="condition.userName !=null and condition.userName != ''">
                and t1.staff_name like concat('%', #{condition.userName}, '%')
            </if>
            <if test="condition.plateNo != null and condition.plateNo !=''">
                and (t2.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', #{condition.plateNo}, '%'))
            </if>
            <if test="condition.customerName != null and condition.customerName !=''">
                and (t3.name like concat('%', #{condition.customerName}, '%') or t4.name like concat('%', #{condition.customerName}, '%'))
            </if>
            <if test="condition.shopIds !=null">
                and  t1.shop_id in
                <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.taskType !=null">
                and t1.task_type = #{condition.taskType}
            </if>
            <if test="condition.startTime1 !=null">
                and t1.call_time >= #{condition.startTime1}
            </if>
            <if test="condition.startTime2 !=null">
                and t1.call_time &lt;=  #{condition.startTime2}
            </if>
        </where>
    </select>
</mapper>