CustomerSopJourneyMapper.xml 8.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.cdp.modules.mapper.CustomerSopJourneyMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.cdp.modules.entity.CustomerSopJourney">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="org_id" jdbcType="VARCHAR" property="orgId" />
    <result column="one_id" jdbcType="VARCHAR" property="oneId" />
    <result column="sop_journey_id" jdbcType="VARCHAR" property="sopJourneyId" />
    <result column="sop_journey_stage" jdbcType="VARCHAR" property="sopJourneyStage" />
    <result column="sop_journey_enter_time" jdbcType="TIMESTAMP" property="sopJourneyEnterTime" />
    <result column="sop_journey_stage_enter_time" jdbcType="TIMESTAMP" property="sopJourneyStageEnterTime" />
    <result column="sop_follow_up_person_id" jdbcType="VARCHAR" property="sopFollowUpPersonId" />
    <result column="sop_follow_up_person_name" jdbcType="VARCHAR" property="sopFollowUpPersonName" />
    <result column="sop_follow_up_person_phone" jdbcType="VARCHAR" property="sopFollowUpPersonPhone" />
    <result column="sop_follow_up_person_aiSpeech" jdbcType="VARCHAR" property="sopFollowUpPersonAiSpeech" />
    <result column="sop_follow_up_person_sms" jdbcType="VARCHAR" property="sopFollowUpPersonSms" />
    <result column="ex_json" jdbcType="LONGVARCHAR" property="exJson" />
    <result column="add_way" jdbcType="VARCHAR" property="addWay" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
  </resultMap>

  <resultMap id="BOResultMap" type="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" extends="BaseResultMap">
    <association property="customer" javaType="cn.com.glsx.cdp.modules.model.CustomerBO">
      <result column="org_id" jdbcType="VARCHAR" property="orgId" />
      <result column="one_id" jdbcType="VARCHAR" property="oneId" />
      <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
      <result column="gender" jdbcType="CHAR" property="gender" />
      <result column="birthday" jdbcType="TIMESTAMP" property="birthday" />
      <result column="age" jdbcType="INTEGER" property="age" />
      <result column="customer_phone" jdbcType="VARCHAR" property="customerPhone" />
      <result column="customer_email" jdbcType="VARCHAR" property="customerEmail" />
      <result column="id_number" jdbcType="VARCHAR" property="idNumber" />
      <result column="nationality" jdbcType="VARCHAR" property="nationality" />
      <result column="province" jdbcType="VARCHAR" property="province" />
      <result column="city" jdbcType="VARCHAR" property="city" />
      <result column="region" jdbcType="VARCHAR" property="region" />
      <result column="address" jdbcType="VARCHAR" property="address" />
      <result column="org_user_id" jdbcType="VARCHAR" property="orgUserId" />
      <result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
      <result column="wechat_nickname" jdbcType="VARCHAR" property="wechatNickname" />
      <result column="wechat_avatar_url" jdbcType="VARCHAR" property="wechatAvatarUrl" />
      <result column="wechat_union_id" jdbcType="VARCHAR" property="wechatUnionId" />
      <result column="marital_status" jdbcType="CHAR" property="maritalStatus" />
      <result column="occupation" jdbcType="VARCHAR" property="occupation" />
      <result column="customer_annual_income" jdbcType="DECIMAL" property="customerAnnualIncome" />
      <result column="customer_company" jdbcType="VARCHAR" property="customerCompany" />
      <result column="education_level" jdbcType="CHAR" property="educationLevel" />
      <result column="notes" jdbcType="VARCHAR" property="notes" />
      <result column="c_add_way" jdbcType="INTEGER" property="addWay" />
      <result column="c_ex_json" jdbcType="LONGVARCHAR" property="exJson" />
    </association>
  </resultMap>

  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, org_id, one_id, sop_journey_id, sop_journey_stage, sop_journey_enter_time, sop_journey_stage_enter_time,
    sop_follow_up_person_id, sop_follow_up_person_name, sop_follow_up_person_phone, sop_follow_up_person_aiSpeech,
    sop_follow_up_person_sms, add_way, created_by, created_time, updated_by, updated_time,
    del_flag
  </sql>
  <sql id="Blob_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    ex_json
  </sql>
  <sql id="base_param" >
    csj.del_flag = 0
    <if test="oneId != null">
      and csj.one_id = #{oneId}
    </if>
    <if test="oneIds != null and oneIds.size()>0">
      and csj.one_id in
      <foreach collection="oneIds" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    <if test="sopJourneyId != null">
      and csj.sop_journey_id = #{sopJourneyId}
    </if>
    <if test="sopJourneyIds != null and sopJourneyIds.size()>0">
      and csj.sop_journey_id in
      <foreach collection="sopJourneyIds" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    <if test="sopJourneyStages != null and sopJourneyStages.size()>0">
      and csj.sop_journey_stage in
      <foreach collection="sopJourneyStages" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    <if test="customerPhones != null and customerPhones.size()>0">
      and c.customer_phone in
      <foreach collection="customerPhones" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    <if test="customerPhone != null and customerPhone != ''">
      and c.customer_phone like CONCAT('%', #{customerPhone},'%')
    </if>
    <if test="customerName != null and customerName != ''">
      and c.customer_name like CONCAT('%', #{customerName},'%')
    </if>
    <if test="wechatNickname != null and wechatNickname != ''">
      and c.wechat_nickname like CONCAT('%', #{wechatNickname},'%')
    </if>
    <if test="sopFollowUpPersonIds != null and sopFollowUpPersonIds.size()>0">
      and csj.sop_follow_up_person_id in
      <foreach collection="sopFollowUpPersonIds" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    <if test="sopFollowUpPersonPhone != null and sopFollowUpPersonPhone != ''">
      and csj.sop_follow_up_person_phone = #{sopFollowUpPersonPhone}
    </if>
    <if test="sopJourneyEnterTimeBegin != null and sopJourneyEnterTimeBegin != ''">
      and csj.sop_journey_enter_time &gt;= #{sopJourneyEnterTimeBegin}
    </if>
    <if test="sopJourneyEnterTimeEnd != null and sopJourneyEnterTimeEnd != ''">
      and csj.sop_journey_enter_time &lt;= #{sopJourneyEnterTimeEnd}
    </if>
  </sql>
  <select id="listCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO" resultMap="BOResultMap">
    select
      csj.id, csj.org_id, csj.one_id, csj.sop_journey_id, csj.sop_journey_stage,
      csj.sop_journey_enter_time, csj.sop_journey_stage_enter_time, csj.sop_follow_up_person_id,
      csj.sop_follow_up_person_name, csj.sop_follow_up_person_phone, csj.sop_follow_up_person_aiSpeech,
      csj.sop_follow_up_person_sms, csj.add_way,
      c.customer_name, c.gender, c.birthday, c.age, c.customer_phone, c.customer_email,
      c.id_number, c.nationality, c.province, c.city, c.region, c.address, c.marital_status,
      c.occupation, c.customer_annual_income, c.customer_company, c.education_level, c.notes, c.wechat_id,
      c.wechat_nickname, c.wechat_avatar_url, c.wechat_union_id,
      c.add_way as c_add_way
    from cdp_customer_sop_journey csj
    left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
    <where>
      <include refid="base_param" />
    </where>
  </select>
  <select id="statisticsCustomerSopJourney" parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO"
          resultType="cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyStatisticsDTO">
    select
        csj.sop_journey_id as sopJourneyId,
        csj.sop_journey_stage as sopJourneyStage,
        count(csj.id) as count
    from cdp_customer_sop_journey csj
    left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
    <where>
      <include refid="base_param" />
    </where>
    group by csj.sop_journey_id, csj.sop_journey_stage
  </select>
  <select id="customerSopJourneyCount" resultType="java.util.Map"
          parameterType="cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO">
    select
    csj.sop_journey_stage as sop_journey_stage,count(1) as count
    from cdp_customer_sop_journey csj
    left join cdp_customer c on csj.one_id = c.one_id and c.del_flag = 0
    <where>
      <include refid="base_param" />
    </where>
    group by csj.sop_journey_stage
  </select>

</mapper>