<?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="com.house365.ws.dao.mapper.CallDailyMapper">

    <select id="queryByDept" resultType="map" parameterType="map">
        SELECT src,disposition,billsec FROM crm_recoder_log WHERE src IN
          ( SELECT cornet FROM user WHERE enabled = 1 AND deptUrlPath LIKE
            (
             SELECT CONCAT( urlPath, '/%' )
              FROM department
                WHERE 1 = 1
                <if test="city != null and city !='' ">
                    AND descripition = #{city}
                </if>
                <if test="id != null and id >=0">
                    AND id = #{id}
                </if>
            )
          )
         AND tag = 1
         AND calldate BETWEEN #{startTime} AND #{endTime}

    </select>

    <select id="queryByUserId" resultType="map" parameterType="map">
        SELECT src,disposition,billsec FROM crm_recoder_log WHERE src IN
            ( SELECT cornet FROM user WHERE id = #{id} and enabled = 1 )
        AND tag = 1
        AND calldate BETWEEN #{startTime} AND #{endTime}
    </select>

</mapper>