ReceptionBizInfoMapper.xml 9.12 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="com.bs.reception.mapper.ReceptionBizInfoMapper">

    <resultMap id="ReceptionBizInfoResult" type="com.bs.reception.entity.reception.ReceptionBizInfo">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="typeCode" column="type_code" jdbcType="VARCHAR"/>
        <result property="storeCode" column="store_code" jdbcType="VARCHAR"/>
        <result property="spCode" column="sp_code" jdbcType="VARCHAR"/>
        <result property="carType" column="car_type" jdbcType="VARCHAR"/>
        <result property="result" column="result" jdbcType="VARCHAR"/>
        <result property="customerType" column="customer_type" jdbcType="VARCHAR"/>
        <result property="customerName" column="customer_name" jdbcType="VARCHAR"/>
        <result property="customerPhone" column="customer_phone" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
        <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
        <result property="materialId" column="material_id" jdbcType="BIGINT"/>
        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
        <result property="createById" column="create_by_id" jdbcType="BIGINT"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
        <result property="updateById" column="update_by_id" jdbcType="BIGINT"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
    </resultMap>
    <resultMap id="ReceptionManagePageVO" type="com.bs.reception.model.reception.ReceptionManagePageVO">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="typeCode" column="type_code" jdbcType="VARCHAR"/>
        <result property="storeCode" column="store_code" jdbcType="VARCHAR"/>
        <result property="storeName" column="store_name" jdbcType="VARCHAR"/>
        <result property="spCode" column="sp_code" jdbcType="VARCHAR"/>
        <result property="spName" column="sp_name" jdbcType="VARCHAR"/>
        <result property="carType" column="car_type" jdbcType="VARCHAR"/>
        <result property="result" column="result" jdbcType="VARCHAR"/>
        <result property="customerType" column="customer_type" jdbcType="VARCHAR"/>
        <result property="customerName" column="customer_name" jdbcType="VARCHAR"/>
        <result property="customerPhone" column="customer_phone" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="phoneNumber" column="phone_number" jdbcType="VARCHAR"/>
        <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
        <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
        <result property="materialId" column="material_id" jdbcType="BIGINT"/>
        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
        <result property="createById" column="create_by_id" jdbcType="BIGINT"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
        <result property="updateById" column="update_by_id" jdbcType="BIGINT"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="score" column="score" jdbcType="DECIMAL"/>
        <result property="duration" column="duration" jdbcType="BIGINT"/>
        <result property="receptionDate" column="receptionDate" jdbcType="TIMESTAMP"/>
        <result property="recordUrl" column="recordUrl" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="selectReceptionBizInfo">
        select id,
        type_code,
        store_code,
        sp_code,
        car_type,
        result,
        customer_type,
        customer_name,
        customer_phone,
        user_id,
        user_name,
        start_time,
        end_time,
        material_id,
        create_by,
        create_by_id,
        create_time,
        update_by,
        update_by_id,
        update_time,
        remark,
        del_flag
        from reception_biz_info
    </sql>
    <select id="findByRecordindId" resultMap="ReceptionBizInfoResult">
        select t1.* from reception_biz_info t1
        left join reception_recording t2 on t1.id=t2.biz_info_id
        where t2.id=#{recordindId}
    </select>
    <select id="receptionManagePage" resultMap="ReceptionManagePageVO">
        SELECT 
            rbi.*,
            rcr.score,
            rr.duration,
            DATE(rbi.start_time) receptionDate,
            rr.url as recordUrl,
            su.phone_number,
            si.sp_name,
            bs.store_name
        FROM `reception_biz_info` rbi
        LEFT JOIN `reception_recording` rr ON rr.biz_info_id=rbi.id AND rr.del_flag=0
        LEFT JOIN `recording_model_call` rmc ON rmc.recording_id=rr.id
        LEFT JOIN `recording_check_result` rcr ON rcr.model_call_id=rmc.id AND deleted_flag='N'
        LEFT JOIN `sys_user` su ON rbi.user_id = su.user_id
        LEFT JOIN `sp_info` si ON rbi.sp_code = si.sp_code
        LEFT JOIN `business_store` bs ON rbi.store_code = bs.store_code
        WHERE rbi.del_flag=0
        <if test="query.spCode != null and query.spCode != ''">
            AND rbi.sp_code = #{query.spCode}
        </if>
        <if test="query.storeCode != null and query.storeCode != ''">
            AND rbi.store_code = #{query.storeCode}
        </if>
        <if test="query.phoneNumber != null and query.phoneNumber != ''">
            AND su.phone_number LIKE CONCAT('%',#{query.phoneNumber},'%')
        </if>
        <if test="query.typeCode != null and query.typeCode != ''">
            AND rbi.type_code=#{query.typeCode}
        </if>
        <if test="query.userName != null and query.userName != ''">
            AND rbi.user_name LIKE CONCAT('%',#{query.userName},'%')
        </if>
        <if test="query.customerName != null and query.customerName != ''">
            AND rbi.customer_name LIKE CONCAT('%',#{query.customerName},'%')
        </if>
        <if test="query.customerPhone != null and query.customerPhone != ''">
            AND rbi.customer_phone LIKE CONCAT('%',#{query.customerPhone},'%')
        </if>
        <if test="query.receptionDateStart != null">
            AND rbi.start_time <![CDATA[>=]]> #{query.receptionDateStart}
        </if>
        <if test="query.receptionDateEnd != null">
            AND rbi.start_time <![CDATA[<=]]> #{query.receptionDateEnd}
        </if>
        <if test="query.qcScoreMin != null">
            AND rcr.score <![CDATA[>=]]> #{query.qcScoreMin}
        </if>
        <if test="query.qcScoreMax != null">
            AND rcr.score <![CDATA[<=]]> #{query.qcScoreMax}
        </if>
        <if test="query.result != null and query.result != ''">
            AND rbi.result=#{query.result}
        </if>
        <!-- 服务商数据权限过滤 -->
        <if test="query.params.dataScope != null and query.params.dataScope != ''">
            AND ${query.params.dataScope}
        </if>
        ORDER BY rbi.id DESC
    </select>

    <select id="getReceptionStatistics" resultType="com.bs.reception.model.reception.ReceptionStatisticsVO">
        SELECT
            COUNT(DISTINCT rbi.id) AS receptionCount,
            AVG(rcr.score) AS avgCheckScore,
            AVG(rr.duration) AS avgDuration
        FROM `reception_biz_info` rbi
        LEFT JOIN `reception_recording` rr ON rr.biz_info_id = rbi.id AND rr.del_flag = 0
        LEFT JOIN `recording_model_call` rmc ON rmc.recording_id = rr.id
        LEFT JOIN `recording_check_result` rcr ON rcr.model_call_id = rmc.id AND rcr.deleted_flag = 'N'
        WHERE rbi.del_flag = 0
        <if test="receptionStartTime != null">
            AND rbi.start_time <![CDATA[>=]]> #{receptionStartTime}
        </if>
        <if test="receptionEndTime != null">
            AND rbi.start_time <![CDATA[<=]]> #{receptionEndTime}
        </if>
        <if test="params.dataScope != null and params.dataScope != ''">
            AND ${params.dataScope}
        </if>
    </select>

    <select id="getReceptionCount" resultType="java.lang.Long">
        SELECT COUNT(rbi.id)
        FROM `reception_biz_info` rbi
        WHERE rbi.del_flag = 0
        <if test="receptionStartTime != null">
            AND rbi.start_time <![CDATA[>=]]> #{receptionStartTime}
        </if>
        <if test="receptionEndTime != null">
            AND rbi.start_time <![CDATA[<=]]> #{receptionEndTime}
        </if>
        <if test="params.dataScope != null and params.dataScope != ''">
            AND ${params.dataScope}
        </if>
    </select>

</mapper>