OutboundTaskCustomerMapper.xml 11.5 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.OutboundTaskCustomerMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.outbound.OutboundTaskCustomer">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="outbound_task_tbid" jdbcType="INTEGER" property="outboundTaskTbid"/>
        <result column="outbound_execute_task_tbid" jdbcType="INTEGER" property="outboundExecuteTaskTbid"/>
        <result column="task_member_id" jdbcType="BIGINT" property="taskMemberId"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="phone_status" jdbcType="INTEGER" property="phoneStatus"/>
        <result column="past_time" jdbcType="TIMESTAMP" property="pastTime"/>
        <result column="execute_status" jdbcType="INTEGER" property="executeStatus"/>
        <result column="call_times" jdbcType="INTEGER" property="callTimes"/>
        <result column="call_start_time" jdbcType="TIMESTAMP" property="callStartTime"/>
        <result column="call_end_time" jdbcType="TIMESTAMP" property="callEndTime"/>
        <result column="end_type" jdbcType="INTEGER" property="endType"/>
        <result column="end_type_reason" jdbcType="VARCHAR" property="endTypeReason"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="phone_msg_status" jdbcType="TINYINT" property="phoneMsgStatus"/>
        <result column="phone_msg_detail" jdbcType="VARCHAR" property="phoneMsgDetail"/>
        <result column="talking_time_len" jdbcType="INTEGER" property="talkingTimeLen"/>
        <result column="talking_time_leng" jdbcType="INTEGER" property="talkingTimeLeng"/>
        <result column="start_time" jdbcType="BIGINT" property="startTime"/>
        <result column="intent" jdbcType="VARCHAR" property="intent"/>
        <result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
        <result column="last_insurance_company" jdbcType="VARCHAR" property="lastInsuranceCompany"/>
        <result column="insurance_end_time" jdbcType="DATE" property="insuranceEndTime"/>
    </resultMap>

    <resultMap id="BaseResponseMap" type="cn.com.glsx.entmicro.model.response.outbound.OutBoundTaskCustomerRpcResponse">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="outbound_task_tbid" jdbcType="INTEGER" property="outboundTaskTbid"/>
        <result column="outbound_execute_task_tbid" jdbcType="INTEGER" property="outboundExecuteTaskTbid"/>
        <result column="task_member_id" jdbcType="BIGINT" property="taskMemberId"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="phone_status" jdbcType="INTEGER" property="phoneStatus"/>
        <result column="past_time" jdbcType="TIMESTAMP" property="pastTime"/>
        <result column="execute_status" jdbcType="INTEGER" property="executeStatus"/>
        <result column="call_times" jdbcType="INTEGER" property="callTimes"/>
        <result column="call_start_time" jdbcType="TIMESTAMP" property="callStartTime"/>
        <result column="call_end_time" jdbcType="TIMESTAMP" property="callEndTime"/>
        <result column="end_type" jdbcType="INTEGER" property="endType"/>
        <result column="end_type_reason" jdbcType="VARCHAR" property="endTypeReason"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="talking_time_len" jdbcType="INTEGER" property="talkingTimeLen"/>
        <result column="talking_time_leng" jdbcType="INTEGER" property="talkingTimeLeng"/>
        <result column="start_time" jdbcType="BIGINT" property="startTime"/>
        <result column="intent" jdbcType="VARCHAR" property="intent"/>
        <result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
        <result column="last_insurance_company" jdbcType="VARCHAR" property="lastInsuranceCompany"/>
        <result column="insurance_end_time" jdbcType="DATE" property="insuranceEndTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, outbound_task_tbid, outbound_execute_task_tbid, task_member_id, phone, `name`,
        phone_status, past_time, execute_status, call_times, call_start_time, call_end_time, end_type,
        end_type_reason, del_flag, created_by, created_time, updated_by, updated_time, phone_msg_status, phone_msg_detail,
        talking_time_len,talking_time_leng,start_time,intent,car_number,last_insurance_company,insurance_end_time
    </sql>
    <update id="updateOutboundTaskCustomerPhoneStatus">
        UPDATE `scrm_outbound_task_customer` SET phone_status=4,past_time=SYSDATE()
        WHERE phone=#{customerPhone}
        AND outbound_task_tbid
        IN (SELECT id FROM `scrm_outbound_task` WHERE merchant_id IN
        <foreach collection="merchantIds" item="merchantId" separator="," close=")" open="(">
            #{merchantId}
        </foreach>
        )
    </update>
    <select id="queryTaskCustomerCount" resultType="cn.com.glsx.entmicro.model.outbound.TaskCustomerCountModel">
        SELECT outbound_task_tbid id,COUNT(execute_status) `count`
        FROM `scrm_outbound_task_customer`
        WHERE outbound_task_tbid IN
        <foreach collection="outboundTaskTbids" open="(" close=")" separator="," item="id">
            #{id}
        </foreach>
        AND execute_status IN (1,2) GROUP BY outbound_task_tbid
    </select>
    <select id="queryTaskCustomerPhoneStatusCount"
            resultType="cn.com.glsx.entmicro.model.outbound.TaskCustomerCountModel">
        SELECT outbound_task_tbid id,phone_status phoneStatus,COUNT(phone_status) `count`
        FROM `scrm_outbound_task_customer`
        WHERE outbound_task_tbid IN
        <foreach collection="outboundTaskTbids" open="(" close=")" separator="," item="id">
            #{id}
        </foreach>
        AND phone_status IN (1,2,3,4)
        GROUP BY outbound_task_tbid,phone_status
    </select>
    <select id="getExecuteTaskCustomerPhonesByTaskId" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM `scrm_outbound_task_customer`
        WHERE outbound_task_tbid = #{taskId}
        AND execute_status = 0
        AND outbound_execute_task_tbid IS NULL
        AND del_flag = 0 LIMIT #{limitNum}
    </select>
    <select id="countNeedToContinueCustomers" resultType="java.lang.Integer">
        SELECT COUNT(1)
        FROM `scrm_outbound_task_customer`
        WHERE outbound_task_tbid = #{outboundTaskId}
          AND outbound_execute_task_tbid IS NULL
    </select>
    <select id="queryCondition" resultMap="BaseResponseMap">
        SELECT * FROM scrm_outbound_task_customer WHERE del_flag = 0
        <if test="condition.id != null and condition.id != ''">
            AND outbound_task_tbid = #{condition.id}
        </if>
        <if test="condition.phone != null and condition.phone != ''">
            AND phone = #{condition.phone}
        </if>
        <if test="condition.phoneStatus != null and condition.phoneStatus != ''">
            AND phone_status = #{condition.phoneStatus}
        </if>
    </select>
    <select id="selectTaskCountTotalCallMinuteAndAnswersById"
            resultType="cn.com.glsx.entmicro.model.response.outbound.OutboundCallTaskEchoRpcResponse">
        SELECT COUNT(1) answers, IF(SUM(t.`talking_time_leng`) IS NULL,0,SUM(t.`talking_time_leng`)) totalCallMinute
        FROM `scrm_outbound_task_customer` t
        WHERE t.`outbound_task_tbid`=#{taskId}
        AND t.`end_type`=1
        AND t.`talking_time_leng`>0
        AND t.`del_flag`=0;
    </select>
    <select id="selectNotConnectPhoneStatusList"
            resultType="cn.com.glsx.entmicro.model.response.outbound.NotConnectPhoneStatusResponse">
        SELECT t.`end_type_reason` reason,COUNT(1) notConnectCount
        FROM `scrm_outbound_task_customer` t
        WHERE t.`outbound_task_tbid`=#{taskId}
        AND t.`end_type`=0
        AND t.`del_flag`=0
        GROUP BY t.`end_type_reason`
    </select>
    <select id="selectTaskCountTotalCallMinuteAndAnswersByIds" resultType="cn.com.glsx.entmicro.model.response.outbound.OutboundCallTaskEchoRpcResponse">
        SELECT t.`outbound_task_tbid` id,IF(SUM(t.`talking_time_leng`) IS NULL,0,SUM(t.`talking_time_leng`))
        totalCallMinute
        FROM `scrm_outbound_task_customer` t
        WHERE t.`outbound_task_tbid` IN
        <foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
            #{taskId}
        </foreach>
        AND t.`end_type`=1
        AND t.`talking_time_leng`>0
        AND t.`del_flag`=0
        GROUP BY t.`outbound_task_tbid`
    </select>
    <select id="findCustomersPageByCondition" resultMap="BaseResponseMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM `scrm_outbound_task_customer` t
        WHERE t.`outbound_task_tbid` = #{taskId}
        <if test="phone!=null and phone!=''">
            AND t.phone LIKE CONCAT('%',#{phone},'%')
        </if>
        <if test="answer!=null and answer.size()>0 and endType != null and endType==1">
            AND (t.end_type_reason IN
            <foreach collection="answer" item="reason" open="(" separator="," close=")">
                #{reason}
            </foreach>
            OR t.talking_time_len <![CDATA[>]]> 0)
        </if>
        <if test="answer!=null and answer.size()>0 and endType == null">
            AND t.end_type = 0
            AND t.end_type_reason IN
            <foreach collection="answer" item="reason" open="(" separator="," close=")">
                #{reason}
            </foreach>
        </if>
        <if test="answer==null and endType != null and endType==1">
            AND t.talking_time_len <![CDATA[>]]> 0
        </if>
        <if test="reCallTimes != null">
            AND t.call_times = #{reCallTimes}+1
        </if>
        <if test="intent != null and intent==true ">
            AND t.intent is not null
        </if>
        <if test="intent != null and intent==false ">
            AND t.intent is null
        </if>
        <if test="talkingTimeLenMin != null">
            AND t.talking_time_len <![CDATA[>=]]> #{talkingTimeLenMin}
        </if>
        <if test="talkingTimeLenMax != null">
            AND t.talking_time_len <![CDATA[<=]]> #{talkingTimeLenMax}
        </if>
        <if test="carNumber != null and carNumber != ''">
            AND t.car_number LIKE CONCAT('%',#{carNumber},'%')
        </if>
        <if test="insuranceCompany != null and insuranceCompany != ''">
            AND t.last_insurance_company LIKE CONCAT('%',#{insuranceCompany},'%')
        </if>
        <if test="startTime != null">
            AND t.insurance_end_time <![CDATA[>=]]> #{startTime}
        </if>
        <if test="endTime != null">
            AND t.insurance_end_time <![CDATA[<=]]> #{endTime}
        </if>
    </select>
</mapper>