ConversationBatchMapper.xml 28.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
<?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.dj.mindworkplate.mapper.ConversationBatchMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.ConversationBatch">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="conversation_id" property="conversationId" jdbcType="INTEGER"/>
        <result column="num" property="num" jdbcType="INTEGER"/>
        <result column="start_time" property="startTime" jdbcType="VARCHAR"/>
        <result column="end_time" property="endTime" jdbcType="VARCHAR"/>
        <result column="duration" property="duration" jdbcType="VARCHAR"/>
        <result column="file_url" property="fileUrl" jdbcType="VARCHAR"/>
        <result column="estimated_result" property="estimatedResult" jdbcType="VARCHAR"/>
        <result column="score" property="score" jdbcType="DECIMAL"/>
        <result column="digest" property="digest" jdbcType="VARCHAR"/>
        <result column="score" property="score" jdbcType="VARCHAR"/>
        <result column="quality_inspection" property="qualityInspection" jdbcType="VARCHAR"/>
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
        <result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
        <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
        <result column="che_taskId" property="cheTaskId" jdbcType="VARCHAR"/>
        <result column="record_id" property="recordId" jdbcType="INTEGER"/>
        <result column="che_result_flag" property="cheResultFlag" jdbcType="INTEGER"/>
        <result column="language" property="language" jdbcType="INTEGER"/>
        <result column="defence_task_id" property="defenceTaskId" jdbcType="VARCHAR"/>
      <result column="checkHistoryFlag" property="checkHistoryFlag" jdbcType="INTEGER"/>
      <result column="checkType" property="checkType" jdbcType="INTEGER"/>
    </resultMap>
    <resultMap id="DTOResultMap" type="cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO" extends="BaseResultMap">
        <result column="customer_name" property="customerName" jdbcType="VARCHAR"/>
        <result column="phone_number" property="phoneNumber" jdbcType="VARCHAR"/>
        <result column="receptionDate" property="receptionDate" jdbcType="VARCHAR"/>
        <result column="car_model" property="carModel" jdbcType="VARCHAR"/>
        <result column="car_brand" property="carBrand" jdbcType="VARCHAR"/>
        <result column="reception_status" property="receptionStatus" jdbcType="INTEGER"/>
        <result column="bussiness_type" property="bussinessType" jdbcType="INTEGER"/>
        <result column="customer_type" property="customerTypeName" jdbcType="VARCHAR"/>
        <result column="def_score" property="defencePoint" jdbcType="VARCHAR"/>
        <result column="defence_result_flag" property="defence" jdbcType="INTEGER"/>
        <result column="axbOpenFlag" property="axbOpenFlag" jdbcType="BOOLEAN"/>
        <result column="isOrderFinishFlag" property="orderFinishFlag" jdbcType="BOOLEAN"/>
        <result column="isFinishFlag" property="finishFlag" jdbcType="BOOLEAN"/>
      <result column="employeeName" property="employeeName" jdbcType="VARCHAR"/>
        <result column="merchant_id" property="merchantId" jdbcType="INTEGER"/>
        <result column="reception_start_time" property="receptionStartTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <resultMap id="ResultMapWithBLOBs" type="cn.com.glsx.dj.mindworkplate.model.ConversationBatch"
               extends="BaseResultMap">
        <!--
          WARNING - @mbg.generated
        -->
        <result column="digest" property="digest" jdbcType="LONGVARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, conversation_id, num, start_time, end_time, duration, file_url, estimated_result,
        score, digest, quality_inspection, created_by, created_date, updated_by, updated_date, deleted_flag,che_taskId,che_result_flag,record_id
    </sql>
  <update id="updatReviewFlag">
    update inspection_conversation_batch t1,inspection_badge_recordings t2 set review_flag=0
    where t1.record_id=t2.id and t1.id=#{batchId}
  </update>

  <select id="page"
            parameterType="cn.com.glsx.dj.mindworkplate.dto.ConversationBatchRequestDTO"
            resultMap="DTOResultMap">
        select cb.*,re.customer_name,re.phone_number,re.car_brand,re.car_model,re.reception_status,re.bussiness_type,ind.customer_type,ind.avg_defence as def_score,
        ibr.defence_result_flag, ibr.defence_task_id,if(t3.Is_mentioned=1,true,false) as axbOpenFlag, re.merchant_id, re.reception_start_time,ibr.check_history_flag as checkHistoryFlag,
    COALESCE(orders.has_anxin, 0) AS isFinishFlag,          -- 安心包是否成交 → isFinishFlag
    COALESCE(orders.has_completed, 0) AS isOrderFinishFlag  -- 订单是否成交 → isOrderFinishFlag
    from
        inspection_conversation_batch cb
        left join reception_customer_info re on cb.task_id = re.id
        left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
        left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
        left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id
        LEFT JOIN (
        SELECT
        phone,
        1 AS has_completed,  -- 因为 WHERE 已限定 order_status IN (4,6)
        MAX(is_anxin_package) AS has_anxin
        FROM dj_smartcarlife.customer_order_temp
        WHERE order_status IN (4, 6)
        GROUP BY phone
        ) orders ON re.phone_number = orders.phone
        <where>
            cb.deleted_flag = 'N'
            <if test="id != null">
                and cb.id = #{id}
            </if>
            <if test="conversationDateId != null">
                and cb.conversation_id = #{conversationDateId}
            </if>
            <if test="startTime != null">
                and cb.start_time &gt;= #{startTime}
            </if>
            <if test="endTime != null">
                and cb.end_time &lt;= #{endTime}
            </if>
            <if test="estimatedResult != null and estimatedResult != ''">
                and cb.estimated_result = #{estimatedResult}
            </if>
            <if test="qualityTestScoreBegin != null">
                and cb.score &gt;= #{qualityTestScoreBegin}
            </if>
            <if test="qualityTestScoreEnd != null">
                and cb.score &lt;= #{qualityTestScoreEnd}
            </if>
            <if test="merchantNo != null">
                and re.merchant_id=#{merchantNo}
            </if>
        </where>
        order by cb.start_time desc
    </select>
  <select id="findListByConversationId"
          resultType="cn.com.glsx.dj.mindworkplate.dto.FileProcessDTO">
    SELECT id as id,start_time as beginTime,end_time as endTime from inspection_conversation_batch
    where conversation_id=#{conversationId}

  </select>

  <select id="findBatchByConversationId" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/>
    from inspection_conversation_batch
    where conversation_id=#{conversationId}
  </select>

    <select id="findBatchByPhone" resultMap="DTOResultMap">
        select * from inspection_conversation_batch t1
        left join reception_customer_info t2 on t1.task_id = t2.id
        where t2.phone_number = #{phone} order by t1.start_time  desc
    </select>
  <select id="findNotGetCheckResult"
    resultMap="BaseResultMap">
      select t1.id,t1.conversation_id, t1.num, t1.start_time, t1.end_time, t1.duration, t1.file_url, t1.estimated_result,
      t1.score, t1.digest,t1.quality_inspection,t2.che_taskId,t2.che_result_flag,t1.record_id,t2.check_History_Flag as checkHistoryFlag,t2.check_type as checkType
      from inspection_conversation_batch t1
      left join inspection_badge_recordings t2 on t1.record_id = t2.id
      where t2.che_result_flag=1
  </select>
    <select id="selectByRecordId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from inspection_conversation_batch
        where record_id=#{recordId}
    </select>
    <select id="findBatchByIds"
      resultMap="DTOResultMap">
        select t1.conversation_id,t2.customer_name,t2.reception_status,t1.start_time,t1.file_url,t1.duration from inspection_conversation_batch t1
        left join reception_customer_info t2 on t1.task_id = t2.id
        <where>
            <if test="ids != null and ids.size>0">
                t1.conversation_id in
                <foreach close=")" collection="ids" item="item" open="(" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <select id="findStaticBatch"
            resultType="cn.com.glsx.dj.mindworkplate.model.ConversationDate">
        select conversation_id as id,sum(score)/count(1) as score,count(1) as batchNum from inspection_conversation_batch
        where conversation_id in
        <if test="ids != null and ids.size>0">
            <foreach close=")" collection="ids" item="item" open="(" separator=",">
                #{item}
            </foreach>
        </if>
        group by conversation_id
    </select>

    <select id="findCheckAgainList" resultMap="BaseResultMap">
        select t1.*,
               t2.che_taskId,
               t2.che_result_flag,
               t3.language
        from inspection_conversation_batch t1
                 left join inspection_badge_recordings t2 on t1.record_id = t2.id
                 left join inspection_employee_badge t3 on t3.badge_id = t2.badge_id
        where t1.deleted_flag = 'N'
          and t2.che_result_flag = 2
          and t3.language = 1
          and t1.score &lt;= 10
          and t2.check_again_flag = 0
    </select>

    <select id="getDefenceList" resultMap="BaseResultMap">
        select t1.id,
               t1.conversation_id,
               t1.num,
               t1.start_time,
               t1.end_time,
               t1.duration,
               t1.file_url,
               t1.estimated_result,
               t1.score,
               t1.digest,
               t1.quality_inspection,
               t2.che_taskId,
               t2.che_result_flag,
               t1.record_id
        from inspection_conversation_batch t1
                 left join inspection_badge_recordings t2 on t1.record_id = t2.id
        where t1.deleted_flag = 'N'
          and t2.defence_result_flag = 0
          and t2.resolved_flag = 1
    </select>

    <select id="needGetDefenceDetail" resultMap="BaseResultMap">
        select t.*,t1.defence_task_id
        from inspection_conversation_batch t
        inner join inspection_badge_recordings t1 on t1.id = t.record_id and t1.deleted_flag = 'N'
        left join inspection_defence ind on ind.batch_id = t.id and ind.deleted_flag = 'N'
        where t1.defence_task_id is not null and t1.defence_result_flag = 1
    </select>

    <select id="getBatchIdByReceptionId" resultType="java.lang.Integer">
        select t.id
        from inspection_conversation_batch t
        inner join inspection_badge_recordings t1 on t1.id = t.record_id and t1.deleted_flag = 'N'
        where t1.reception_id = #{receptionId} order by t1.created_date desc limit 1
    </select>
  <select id="findExtBatchByIds"
    resultType="cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO">
    select t1.conversation_id as conversationId,t2.customer_name as customerName,t2.phone_number as phoneNumber,t2.reception_status,t1.start_time,t1.file_url,t1.duration,
    if(t3.Is_mentioned=1,true,false) as axbOpenFlag,if(t4.Is_mentioned=1,true,false) as dtcOpenFlag,
    -- 👇 关键:按你的 Java 字段命名
    COALESCE(orders.has_anxin, 0) AS isFinishFlag,          -- 安心包是否成交 → isFinishFlag
    COALESCE(orders.has_completed, 0) AS isOrderFinishFlag  -- 订单是否成交 → isOrderFinishFlag
    from inspection_conversation_batch t1
    left join reception_customer_info t2 on t1.task_id = t2.id
    left join recording_batch_model_call_axb t3 on t1.id=t3.batch_id
    left join recording_batch_model_call_dtc t4 on t1.id=t4.batch_id
    LEFT JOIN (
    SELECT
    phone,
    1 AS has_completed,  -- 因为 WHERE 已限定 order_status IN (4,6)
    MAX(is_anxin_package) AS has_anxin  -- 👈 关键:取最大值(0/1),只要有一个1就是1
    FROM dj_smartcarlife.customer_order_temp
    WHERE order_status IN (4, 6) and scene_type=0
    GROUP BY phone
    ) orders ON t2.phone_number = orders.phone
    <where>
      <if test="ids != null and ids.size>0">
        t1.conversation_id in
        <foreach close=")" collection="ids" item="item" open="(" separator=",">
          #{item}
        </foreach>
      </if>
    </where>
  </select>
  <select id="findAllFinishPhone" resultType="java.lang.String">
    select
    dclgoc.customer_phone
    from dj_car_life_goods_order dclgo
    left join dj_car_life_goods_sub_order dclgso
    on dclgo.order_code = dclgso.order_code and dclgso.deleted_flag = 'N'
    left join dj_car_life_goods_order_customer dclgoc
    on dclgoc.order_code = dclgo.order_code and dclgoc.deleted_flag = 'N'
    left join dj_car_life_pay_order dclpo on dclpo.order_code = dclgo.order_code and dclpo.deleted_flag = 'N'
    where (upgrade_goods_name like concat('%', #{goodsName},'%')
    or upgrade_goods_alias like concat('%', #{goodsName},'%')
    or package_name like concat('%', #{goodsName},'%') )
    and dclgo.deleted_flag = 'N' and dclgo.scene_type = 0
    and dclgo.status in (4, 6) and upgrade_flag = 'Y'
    order by order_time desc
  </select>
  <select id="findOrderByPhoneList"
          resultType="cn.com.glsx.dj.mindworkplate.service.recordmodelcall.model.ReceptionOrderDetailExportModel">
    select
    dclgoc.customer_phone as phoneNumer,
    dclgo.order_code as orderCode,
    COALESCE( dclgso.upgrade_goods_name, '-')  AS upgradeGoodsName,
    COALESCE( dclgso.upgrade_goods_alias, '-') AS upgradeGoodsAlias,
    COALESCE(package_name, '-') AS packageName,
    dclgso.total_price as unitPrice,
    dclgo.total_price as totalPrice
    from dj_car_life_goods_order dclgo
    left join dj_car_life_goods_sub_order dclgso
    on dclgo.order_code = dclgso.order_code and dclgso.deleted_flag = 'N'
    left join dj_car_life_goods_order_customer dclgoc
    on dclgoc.order_code = dclgo.order_code and dclgoc.deleted_flag = 'N'
    left join dj_car_life_pay_order dclpo on dclpo.order_code = dclgo.order_code and dclpo.deleted_flag = 'N'
    where
    dclgo.deleted_flag = 'N' and dclgo.scene_type = 0
    and dclgo.status in (4, 6) and upgrade_flag = 'Y'
    and  dclgoc.customer_phone in
    <foreach close=")" collection="collect" item="item" open="(" separator=",">
      #{item}
    </foreach>

  </select>
  <select id="findBatchDetailByCondition"
    resultType="cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO">
    select t2.staff_uuid as staffUuid,t2.phone_number as phoneNumber,date_format (t2.reception_start_time,'%Y-%m-%d') as searchdate,t2.merchant_id as merchantNo,
    t2.bussiness_type as bussinessType,t2.customer_name as customerName,t2.car_model as carModel,t2.reception_status as receptionStatus,
    t1.estimated_result as estimatedResult,t1.score as score,t5.avg_defence as defencePoint,t5.customer_type as customerTypeName,
    t1.start_time as startTime,t1.end_time as endTime,t1.file_url as fileUrl,t1.duration,
    if(t3.Is_mentioned=1,true,false) as axbOpenFlag,if(t4.Is_mentioned=1,true,false) as dtcOpenFlag,group_concat(distinct t6.mentioned_type) as axbOpenDetail
    from inspection_conversation_batch t1
    left join reception_customer_info t2 on t1.task_id  = t2.id
    left join inspection_defence t5 on (t1.id =t5.batch_id and  t5.deleted_flag='N')
    left join recording_batch_model_call_axb t3 on t1.id=t3.batch_id
    left join recording_batch_model_call_axb_detail t6 on t3.id=t6.abx_id
    left join recording_batch_model_call_dtc t4 on t1.id=t4.batch_id
    where t2.bussiness_type=1 and t2.merchant_id in
    <foreach close=")" collection="merchantNos" item="item" open="(" separator=",">
      #{item}
    </foreach>
    <if test="startTime != null">
      and date_format (t2.reception_start_time,'%Y-%m-%d') <![CDATA[ >= ]]> date_format (#{startTime},'%Y-%m-%d')
    </if>
    <if test="endTime != null">
      and date_format (t2.reception_start_time,'%Y-%m-%d') <![CDATA[ <= ]]> date_format (#{endTime},'%Y-%m-%d')
    </if>
    group by t1.id
    order by t2.reception_start_time desc,t2.staff_uuid
  </select>

  <select id="findAllOrderPhone" resultType="java.lang.String">
    select
    distinct dclgoc.customer_phone
    from dj_car_life_goods_order dclgo
    left join dj_car_life_goods_sub_order dclgso
    on dclgo.order_code = dclgso.order_code and dclgso.deleted_flag = 'N'
    left join dj_car_life_goods_order_customer dclgoc
    on dclgoc.order_code = dclgo.order_code and dclgoc.deleted_flag = 'N'
    left join dj_car_life_pay_order dclpo on dclpo.order_code = dclgo.order_code and dclpo.deleted_flag = 'N'
    where dclgo.deleted_flag = 'N' and dclgo.scene_type = 0
    and dclgo.status in (4, 6) and upgrade_flag = 'Y'
    order by order_time desc
  </select>
  <select id="receptionDetailPage"
          resultMap="DTOResultMap">
    select cb.*,re.customer_name,re.phone_number,re.car_model,re.reception_status as receptionStatus,re.bussiness_type,ind.customer_type,ind.avg_defence as def_score,
    ibr.defence_result_flag, ibr.defence_task_id,if(t3.Is_mentioned=1,true,false) as axbOpenFlag,re.staff_uuid as staffUuid,t5.staff_name as employeeName
    from
    reception_customer_info re
    left join inspection_conversation_batch cb on cb.task_id = re.id
    left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
    left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
    left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id
    left join dj_car_life_staff_info    t5 on t5.staff_uuid =re.staff_uuid

    <where>
      cb.deleted_flag = 'N'
      <if test="condition.startTime != null">
        and date_format (cb.start_time,'%Y-%m-%d') &gt;= #{condition.startTime}
      </if>
      <if test="condition.endTime != null">
       and date_format (cb.start_time,'%Y-%m-%d') &lt;= #{condition.endTime}
      </if>
      <if test="condition.bussinessType != null">
        and ibr.check_type = #{condition.bussinessType}
      </if>
      <if test="condition.merchantNo != null">
        and re.merchant_id=#{condition.merchantNo}
      </if>
      <if test="condition.staffUUid != null and condition.staffUUid != ''">
        and re.staff_uuid=#{condition.staffUUid}
      </if>
      <if test="condition.orderFinishFlag != null and condition.orderFinishFlag == 1">
        and re.phone_number in
        <foreach close=")" collection="condition.orderPhoneList" item="item" open="(" separator=",">
          #{item}
        </foreach>
      </if>
      <if test="condition.orderFinishFlag != null and condition.orderFinishFlag == 0">
        and re.phone_number not in
        <foreach close=")" collection="condition.orderPhoneList" item="item" open="(" separator=",">
          #{item}
        </foreach>
      </if>
      order by date_format (re.reception_start_time,'%Y-%m-%d') desc
    </where>

  </select>
  <select id="findReceptionCount" resultType="java.lang.Integer">
    select count(1) from reception_customer_info t1
    left join inspection_badge_recordings t2 on t1.id=t2.reception_id
    left join inspection_conversation_batch t3 on t3.record_id=t2.id
    where t3.deleted_flag = 'N'
    <if test="condition.dateTime != null">
      and t1.reception_start_time like concat('%',#{condition.dateTime},'%')
    </if>
    <if test="condition.bussinessTypes != null">
    and t1.bussiness_type in
    <foreach close=")" collection="condition.bussinessTypes" item="item" open="(" separator=",">
      #{item}
    </foreach>
    </if>
    <if test="condition.merchantNo != null">
      and t1.merchant_id=#{condition.merchantNo}
    </if>
    <if test="condition.staffUUid != null">
      and t1.staff_uuid in
      <foreach close=")" collection="condition.staffUUid" item="item" open="(" separator=",">
        #{item}
      </foreach>
    </if>
  </select>
  <select id="findFalseReceptionCount" resultType="java.lang.Integer">
    select count(1) from reception_customer_info t1
    left join inspection_badge_recordings t2 on t1.id=t2.reception_id
    left join inspection_conversation_batch t3 on t3.record_id=t2.id
    where t3.deleted_flag = 'N'  and ((t3.score is not null and t3.score &lt; 20) or t2.recording_duration &lt; 120)
    <if test="condition.dateTime != null">
      and t1.reception_start_time like concat('%',#{condition.dateTime},'%')
    </if>
    <if test="condition.bussinessTypes != null">
    and t1.bussiness_type in
    <foreach close=")" collection="condition.bussinessTypes" item="item" open="(" separator=",">
      #{item}
    </foreach>
    </if>
    <if test="condition.merchantNo != null">
      and t1.merchant_id=#{condition.merchantNo}
    </if>
    <if test="condition.staffUUid != null">
      and t1.staff_uuid in
    <foreach close=")" collection="condition.staffUUid" item="item" open="(" separator=",">
      #{item}
    </foreach>

    </if>

  </select>
  <select id="receptionDetailStaff"
          resultType="cn.com.glsx.dj.mindworkplate.response.warning.WarningMsgStaffRes">
    select re.staff_uuid as staffId,t5.staff_name as staffName
    from
    reception_customer_info re
    left join inspection_conversation_batch cb on cb.task_id = re.id
    left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
    left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
    left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id
    left join dj_car_life_staff_info  t5 on t5.staff_uuid =re.staff_uuid
    <where>
      cb.deleted_flag = 'N'
      <if test="condition.startTime != null">
        and date_format (cb.start_time,'%Y-%m-%d') &gt;= #{condition.startTime}
      </if>
      <if test="condition.endTime != null">
        and date_format (cb.start_time,'%Y-%m-%d') &lt;= #{condition.endTime}
      </if>
      <if test="condition.bussinessType != null">
        and ibr.check_type = #{condition.bussinessType}
      </if>
      <if test="condition.merchantNo != null">
        and re.merchant_id=#{condition.merchantNo}
      </if>
      group by re.staff_uuid
    </where>
  </select>
  <select id="findAllOrderPhoneByCondition" resultType="java.lang.String">
    select
    distinct dclgoc.customer_phone as customer_phone
    from dj_car_life_goods_order dclgo
    left join dj_car_life_goods_sub_order dclgso
    on dclgo.order_code = dclgso.order_code and dclgso.deleted_flag = 'N'
    left join dj_car_life_goods_order_customer dclgoc
    on dclgoc.order_code = dclgo.order_code and dclgoc.deleted_flag = 'N'
    left join dj_car_life_pay_order dclpo on dclpo.order_code = dclgo.order_code and dclpo.deleted_flag = 'N'
    where dclgo.deleted_flag = 'N'
    and dclgo.status in (4, 6) and upgrade_flag = 'Y'
    <if test="condition.bussinessType != null and (condition.bussinessType==1 or condition.bussinessType==3)">
      and dclgo.scene_type = 0
    </if>
    <if test="condition.bussinessType != null and (condition.bussinessType==2)">
      and dclgo.scene_type = 1
    </if>
  </select>
  <select id="findHisFlagByBatchId"
          resultMap="BaseResultMap">
    select
    t2.check_History_Flag as checkHistoryFlag
    from inspection_conversation_batch t1
    left join inspection_badge_recordings t2 on t1.record_id=t2.id
    where t1.id=#{batchId}
    and t2.deleted_flag = 'N'
  </select>
  <select id="getRecordPageListByCondition"
          resultMap="DTOResultMap">
    select
    t2.id as id,
    t4.phone_number as phoneNumber,
    t4.customer_name as customerName,
    t4.car_model as carModel,
    t5.staff_name as employeeName,
    date_format (t4.reception_start_time,'%Y-%m-%d') as receptionDate,
    t2.start_time,
    t2.file_url,
    t2.end_time,
    t2.score as score,
    t2.duration  as duration,
    t3.avg_defence  as def_score,
    t4.reception_status as receptionStatus,
    t1.check_History_Flag as checkHistoryFlag,
    t4.merchant_id,
    CASE
    WHEN EXISTS (
        SELECT 1 FROM customer_order_temp cot
        WHERE cot.phone = t4.phone_number
        AND cot.scene_type = t4.bussiness_type - 1
        AND cot.order_status IN (4,6)
    ) THEN true
    ELSE false END as orderFinishFlag
    from
    inspection_badge_recordings t1
    left join inspection_conversation_batch t2 on t2.record_id=t1.id
    left join inspection_defence t3 on (t3.batch_id=t2.id and t3.deleted_flag = 'N')
    left join reception_customer_info t4 on t4.id=t1.reception_id
    left join dj_car_life_staff_info t5 on t5.staff_uuid =t4.staff_uuid
    where t1.deleted_flag = 'N' and t4.id is not null
    <if test="condition.startDate != null">
      and date_format (t1.recording_start_time,'%Y-%m-%d') &gt;= #{condition.startDate}
    </if>
    <if test="condition.receptionDate != null and condition.receptionDate!=''">
      and date_format (t1.recording_start_time,'%Y-%m-%d')=#{condition.receptionDate}
    </if>
    <if test="condition.endDate != null">
      and date_format (t1.recording_start_time,'%Y-%m-%d') &lt;= #{condition.endDate}
    </if>
    <if test="condition.staffName != null and condition.staffName!=''">
      and t5.staff_name like concat('%',#{condition.staffName},'%')
    </if>
    <if test="condition.businessType != null">
      and t4.bussiness_type = #{condition.businessType}
    </if>
    <if test="condition.merchantId != null">
      and t4.merchant_id= #{condition.merchantId}
    </if>
    <if test="condition.staffId != null">
      and t4.staff_uuid= #{condition.staffId}
    </if>
    <if test="condition.recordIdList != null ">
      and t2.id in
      <foreach close=")" collection="condition.recordIdList" item="item" open="(" separator=",">
        #{item}
      </foreach>
    </if>
    <if test="condition.orderFinishFlag!=null and condition.orderFinishFlag==1">
      and  EXISTS (
      SELECT 1
      FROM customer_order_temp cot
      WHERE cot.phone = t4.phone_number
      AND cot.scene_type+1 = t4.bussiness_type
      AND cot.order_status IN (4, 6)
      )
    </if>
    <if test="condition.orderFinishFlag!=null and condition.orderFinishFlag==0">
      and not EXISTS (
      SELECT 1
      FROM customer_order_temp cot
      WHERE cot.phone = t4.phone_number
      AND cot.scene_type+1 = t4.bussiness_type
      AND cot.order_status IN (4, 6)
      )
    </if>
    <if test="condition.customerName != null and condition.customerName != ''">
      and t4.customer_name like concat('%',#{condition.customerName},'%')
    </if>
    <if test="condition.carModel != null and condition.carModel != ''">
      and t4.car_model like concat('%',#{condition.carModel},'%')
    </if>
    <if test="condition.productName != null and condition.productName != ''">
      and EXISTS (
        SELECT 1 FROM customer_order_temp cot
        WHERE cot.phone = t4.phone_number
        AND cot.upgrade_goods_name like concat('%',#{condition.productName},'%')
        <if test="condition.businessType != null">
          <if test="condition.businessType == 1 or condition.businessType == 3">
            AND cot.scene_type = 0
          </if>
          <if test="condition.businessType == 2">
            AND cot.scene_type = 1
          </if>
        </if>
      )
    </if>
    order by t1.recording_start_time desc
  </select>
  <select id="getRecordStaticByCondition"
          resultType="cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO">
    select
    CASE
    WHEN COUNT(t2.score) > 0 THEN SUM(t2.score) / COUNT(t2.score)
    ELSE 0
    END AS avgScore,
    CASE
    WHEN COUNT(t3.avg_defence) > 0 THEN SUM(t3.avg_defence) / COUNT(t3.avg_defence)
    ELSE 0
    END AS avgDefScore
    from
    inspection_badge_recordings t1
    left join inspection_conversation_batch t2 on t2.record_id=t1.id
    left join inspection_defence t3 on (t3.batch_id=t2.id and t3.deleted_flag = 'N')
    left join reception_customer_info t4 on t4.id=t1.reception_id
    left join dj_car_life_staff_info t5 on t5.staff_uuid =t4.staff_uuid
    where t1.deleted_flag = 'N' and t4.id is not null
    <if test="condition.startDate != null">
      and date_format (t1.recording_start_time,'%Y-%m-%d') &gt;= #{condition.startDate}
    </if>
    <if test="condition.endDate != null">
      and date_format (t1.recording_start_time,'%Y-%m-%d') &lt;= #{condition.endDate}
    </if>
    <if test="condition.businessType != null">
      and t1.check_type = #{condition.businessType}
    </if>
    <if test="condition.merchantId != null">
      and t4.merchant_id= #{condition.merchantId}
    </if>
    <if test="condition.staffId != null">
      and t4.staff_uuid= #{condition.staffId}
    </if>
  </select>
</mapper>