ReceptionCustomerFileMapper.xml 7.97 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.dj.mindworkplate.mapper.ReceptionCustomerFileMapper">

  <select id="listNeedGenerateTodayLightModReception" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo">
    select distinct
    rci.id as id,
    rci.reception_status as receptionStatus,
    ieb.employee_name as staffName,
    ieb.phone_number as staffPhone,
    rci.customer_name as customerName,
    rci.phone_number as phoneNumber
    from reception_customer_info rci
    inner join inspection_badge_recordings ibr on ibr.reception_id = rci.id and ibr.deleted_flag = 'N'
    inner join inspection_conversation_batch cb on cb.task_id = rci.id and cb.deleted_flag = 'N'
    inner join inspection_conversation_date t2 on cb.conversation_id = t2.id and t2.deleted_flag = 'N'
    inner join inspection_employee_badge ieb on ieb.badge_id = t2.badge_id and ieb.deleted_flag = 'N'
    where rci.deleted_flag = 'N'
    and rci.bussiness_type = 2
    and rci.reception_start_time &gt;= #{startTime}
    and rci.reception_start_time &lt; #{endTime}
    and ibr.recording_id is not null and ibr.recording_id != ''
    and not exists (
      select 1 from reception_customer_file rcf
      where rcf.reception_id = rci.id and rcf.deleted_flag = 'N'
    )
    order by rci.id asc
  </select>

  <insert id="batchInsertInit">
    insert into reception_customer_file
    (submit_status, push_status, reception_id, reception_result, created_by, created_date, deleted_flag)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.submitStatus}, #{item.pushStatus}, #{item.receptionId}, #{item.receptionResult}, #{item.createdBy}, #{item.createdDate}, #{item.deletedFlag})
    </foreach>
  </insert>

  <update id="updateCustomerFileFlag">
    update reception_customer_info
    set customer_file_flag = 1, updated_by = 'system', updated_date = now()
    where id in
    <foreach collection="ids" item="item" separator="," open="(" close=")">
      #{item}
    </foreach>
  </update>

  <update id="updatePushStatusByReceptionIds">
    update reception_customer_file
    set push_status = 1, updated_by = 'system', updated_date = now()
    where reception_id in
    <foreach collection="receptionIds" item="item" separator="," open="(" close=")">
      #{item}
    </foreach>
  </update>

  <select id="findDetailByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO">
    select
      rci.customer_name as customerName,
      rci.phone_number as phoneNumber,
      rci.reception_start_time as receptionStartTime,
      rci.car_brand as carBrand,
      rcf.id as id,
      rcf.submit_status as submitStatus,
      rcf.reception_id as receptionId,
      rcf.reception_result as receptionResult,
      rcf.deal_attribution as dealAttribution,
      rcf.lose_reason as loseReason,
      rcf.car_user_type as carUserType,
      rcf.customer_background as customerBackground,
      rcf.easy_communication as easyCommunication,
      rcf.is_mortgage as isMortgage,
      rcf.down_payment_ratio as downPaymentRatio,
      rcf.purchase_background as purchaseBackground,
      rcf.is_local_use as isLocalUse,
      rcf.purchase_purpose as purchasePurpose,
      rcf.install_items as installItems,
      rcf.gift_items as giftItems,
      rcf.film_brand as filmBrand,
      rcf.know_other_brand_goods as knowOtherBrandGoods
    from inspection_conversation_batch t2
    LEFT JOIN reception_customer_file rcf on rcf.reception_id = t2.record_id and rcf.deleted_flag = 'N'
    left join reception_customer_info rci on t2.task_id = rci.id and rci.deleted_flag = 'N'
    where t2.record_id = #{receptionId}
    limit 1
  </select>

  <update id="updateByReceptionId">
    update reception_customer_file
    <set>
      <if test="receptionResult != null">reception_result = #{receptionResult},</if>
      <if test="dealAttribution != null">deal_attribution = #{dealAttribution},</if>
      <if test="loseReason != null">lose_reason = #{loseReason},</if>
      <if test="carUserType != null">car_user_type = #{carUserType},</if>
      <if test="customerBackground != null">customer_background = #{customerBackground},</if>
      <if test="easyCommunication != null">easy_communication = #{easyCommunication},</if>
      <if test="isMortgage != null">is_mortgage = #{isMortgage},</if>
      <if test="downPaymentRatio != null">down_payment_ratio = #{downPaymentRatio},</if>
      <if test="purchaseBackground != null">purchase_background = #{purchaseBackground},</if>
      <if test="isLocalUse != null">is_local_use = #{isLocalUse},</if>
      <if test="purchasePurpose != null">purchase_purpose = #{purchasePurpose},</if>
      <if test="installItems != null">install_items = #{installItems},</if>
      <if test="giftItems != null">gift_items = #{giftItems},</if>
      <if test="filmBrand != null">film_brand = #{filmBrand},</if>
      <if test="knowOtherBrandGoods != null">know_other_brand_goods = #{knowOtherBrandGoods},</if>
      <if test="updatedBy != null">updated_by = #{updatedBy},</if>
      submit_status = 1,
      updated_date = now()
    </set>
    where reception_id = #{receptionId}
    and deleted_flag = 'N'
  </update>

  <select id="listSummaryBetweenDates" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO">
    select
      ieb.employee_name as salesName,
      rci.merchant_id as merchantName,
      rci.reception_start_time as receptionStartTime,
      rci.customer_name as customerName,
      rci.phone_number as phoneNumber,
      rci.car_model as carModel,
      icb.file_url as fileUrl,
      rcf.reception_result as receptionResult,
      rcf.deal_attribution as dealAttribution,
      rcf.lose_reason as loseReason,
      rcf.car_user_type as carUserType,
      rcf.customer_background as customerBackground,
      rcf.easy_communication as easyCommunication,
      rcf.is_mortgage as isMortgage,
      rcf.down_payment_ratio as downPaymentRatio,
      rcf.purchase_background as purchaseBackground,
      rcf.is_local_use as isLocalUse,
      rcf.purchase_purpose as purchasePurpose,
      rcf.install_items as installItems,
      rcf.gift_items as giftItems,
      rcf.film_brand as filmBrand,
      rcf.know_other_brand_goods as knowOtherBrandGoods
    from reception_customer_file rcf
    left join inspection_conversation_batch icb on rcf.reception_id = icb.record_id and icb.deleted_flag = 'N'
    left join reception_customer_info rci on icb.task_id = rci.id and rci.deleted_flag = 'N'
    LEFT JOIN inspection_badge_recordings t3 ON icb.record_id = t3.id and t3.deleted_flag = 'N'
    LEFT JOIN inspection_employee_badge ieb ON t3.badge_id = ieb.badge_id and ieb.deleted_flag = 'N'
    where rcf.submit_status = 1
    and rcf.created_date &gt;= #{startTime}
    and rcf.created_date &lt; #{endTime}
    and rcf.deleted_flag = 'N'
    order by rcf.created_date desc
  </select>

  <select id="selectByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile">
    select
      id, 
      submit_status as submitStatus, 
      reception_id as receptionId, 
      reception_result as receptionResult, 
      deal_attribution as dealAttribution,
      lose_reason as loseReason, 
      car_user_type as carUserType, 
      customer_background as customerBackground, 
      easy_communication as easyCommunication, 
      is_mortgage as isMortgage,
      down_payment_ratio as downPaymentRatio, 
      purchase_background as purchaseBackground, 
      is_local_use as isLocalUse, 
      purchase_purpose as purchasePurpose,
      install_items as installItems, 
      gift_items as giftItems, 
      film_brand as filmBrand, 
      know_other_brand_goods as knowOtherBrandGoods,
      created_by as createdBy, 
      created_date as createdDate, 
      updated_by as updatedBy, 
      updated_date as updatedDate, 
      deleted_flag as deletedFlag
    from reception_customer_file
    where reception_id = #{receptionId}
    and deleted_flag = 'N'
    limit 1
  </select>


</mapper>