ScrmBusinessCardMapper.xml 7.47 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.ScrmBusinessCardMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.ScrmBusinessCard">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="card_name" jdbcType="VARCHAR" property="cardName"/>
        <result column="miniprogram_code" jdbcType="VARCHAR" property="miniprogramCode"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="staff_id" jdbcType="INTEGER" property="staffId"/>
        <result column="operation" jdbcType="VARCHAR" property="operation"/>
        <result column="skip_verify" jdbcType="INTEGER" property="skipVerify"/>
        <result column="business_uuid" jdbcType="VARCHAR" property="businessUuid"/>
        <result column="image" jdbcType="VARCHAR" property="image"/>
        <result column="state" jdbcType="VARCHAR" property="state"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
        <result column="qr_code" jdbcType="INTEGER" property="qrCode"/>
        <result column="config_id" jdbcType="VARCHAR" property="configId"/>
    </resultMap>
    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.entmicro.entity.ScrmBusinessCard">


        <!--
          WARNING - @mbg.generated
        -->
        <result column="tag_json" jdbcType="LONGVARCHAR" property="tagJson"/>
    </resultMap>

    <resultMap id="BaseRpcResponseMap" type="cn.com.glsx.entmicro.model.response.businessCard.BusinessCardRpcResponse">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="card_name" jdbcType="VARCHAR" property="cardName"/>
        <result column="miniprogram_code" jdbcType="VARCHAR" property="miniprogramCode"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="staff_id" jdbcType="INTEGER" property="staffId"/>
        <result column="staffName" jdbcType="VARCHAR" property="staffName"/>
        <result column="staffPhone" jdbcType="VARCHAR" property="staffPhone"/>
        <result column="operation" jdbcType="VARCHAR" property="operation"/>
        <result column="skip_verify" jdbcType="INTEGER" property="skipVerify"/>
        <result column="business_uuid" jdbcType="VARCHAR" property="businessUuid"/>
        <result column="image" jdbcType="VARCHAR" property="image"/>
        <result column="state" jdbcType="VARCHAR" property="state"/>
        <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="tag_json" jdbcType="VARCHAR" property="tagJson"/>
        <result column="auto_welcome" jdbcType="INTEGER" property="autoWelcome"/>
        <result column="config_id" jdbcType="VARCHAR" property="configId"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, card_name, miniprogram_code, remark, staff_id, `operation`, skip_verify,
        business_uuid, image, `state`,
        del_flag, merchant_id, created_time, created_by, updated_time, updated_by
    </sql>
    <sql id="Blob_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        tag_json
    </sql>
    <select id="getBusinessCardPageByCondition"
            resultMap="BaseRpcResponseMap">
        select
            t.id,
            t.card_name,
            t.miniprogram_code,
            t.remark,
            t.staff_id,
            t.skip_verify,
            t.business_uuid,
            t.image,
            t.`state`,
            t.merchant_id,
            t.created_time,
            t.created_by,
            t.updated_time,
            t.updated_by,
            t.tag_json,
            t.auto_welcome,
            t1.staff_name as staffName,
            t1.staff_phone as staffPhone
        from scrm_business_card t
        LEFT JOIN entmicro_staff t1 ON t1.id = t.staff_id AND t1.del_flag = 0
        left join scrm_business_card_record t2 on t.id = t2.card_id AND t2.del_flag = 0
        where t.del_flag = 0
        <if test="condition.staffName != null and condition.staffName != ''">
            AND t1.staff_name like concat('%',#{condition.staffName},'%')
        </if>
        <if test="condition.cardName != null and condition.cardName != ''">
            AND t.card_name like concat('%',#{condition.cardName},'%')
        </if>
        <if test="condition.followStaff != null and condition.followStaff != ''">
            AND t.follow_staff like concat('%',#{condition.followStaff},'%')
        </if>
        <if test="condition.statisticStartTime != null">
            AND TO_DAYS(t2.last_time) <![CDATA[>=]]> TO_DAYS(#{condition.statisticStartTime})
        </if>
        <if test="condition.statisticEndTime != null">
            AND TO_DAYS(t2.last_time)  <![CDATA[<=]]> TO_DAYS(#{condition.statisticEndTime})
        </if>
            and t.merchant_id = #{condition.merchantId}
        group by t.id
        order by t.created_time desc
    </select>
    <select id="findCardById"
            resultMap="BaseRpcResponseMap">
        select t.id,
            t.card_name,
            t.miniprogram_code,
            t.remark,
            t.staff_id,
            t.skip_verify,
            t.business_uuid,
            t.image,
            t.`state`,
            t.merchant_id,
            t.created_time,
            t.created_by,
            t.updated_time,
            t.updated_by,
            t.tag_json,
            t.auto_welcome,
            t.operation,
            t.qr_code,
            t1.staff_name  as staffName,
            t1.staff_phone as staffPhone,
            t.config_id
        from scrm_business_card t
                 LEFT JOIN entmicro_staff t1 ON t1.id = t.staff_id AND t1.del_flag = 0
        where t.del_flag = 0
          and t.id = #{cardId}
        group by t.id
    </select>
  <select id="findBusinessCardByPhone"
          resultType="cn.com.glsx.entmicro.model.response.businessCard.BusinessCardRpcResponse">
      select t2.staff_phone as staffPhone,t1.id as id,t1.merchant_id as merchantId,t1.created_time as createdTime from scrm_business_card t1
      left join entmicro_staff t2 on t1.staff_id =t2.id
      left join entmicro_staff_depart_relation t3 on t3.relevance_merchant=t1.merchant_id and t3.del_flag =0
      where t1.del_flag =0 and t2.staff_phone=#{phone}
      group by t1.id
      order by t1.id desc
      limit 1

  </select>
</mapper>