DracImCustomerCollectionMapper.xml 5.07 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.DracImCustomerCollectionMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.DracImCustomerCollection">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="im_id" jdbcType="VARCHAR" property="imId"/>
        <result column="customer_id" jdbcType="INTEGER" property="customerId"/>
        <result column="phone" jdbcType="INTEGER" property="phone"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>
    <resultMap id="resultMap" type="cn.com.glsx.entmicro.model.response.DracImCustomerCollectionResponse">
        <!--
          WARNING - @mbg.generated
        -->
        <result column="im_id" jdbcType="VARCHAR" property="imId"/>
        <result column="customer_id" jdbcType="INTEGER" property="customerId"/>
        <result column="customer_name" jdbcType="INTEGER" property="customerName"/>
        <result column="phone" jdbcType="INTEGER" property="phone"/>
        <result column="content" jdbcType="VARCHAR" property="content"/>
        <result column="del_flag" jdbcType="INTEGER" property="status"/>
        <result column="updated_time" jdbcType="INTEGER" property="sendTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, im_id, customer_id, phone, del_flag, created_by, created_time, updated_by, updated_time
    </sql>
    <update id="updateStatus">
        update drac_im_customer_collection
        set del_flag=1,
        updated_time=now()
        where im_id=#{imId}
    </update>
    <select id="findByUuid" resultMap="resultMap">
           select t2.*,t3.content from drac_im_info t1
        left join drac_im_customer_collection t2 on t1.id=t2.im_id
        left join drac_im_message_config t3 on t1.id=t3.im_id
        where
        t1.im_uid=#{uuid}
    </select>
    <select id="findByDracId"
            resultMap="resultMap">
        select t2.*,t3.content from drac_im_info t1
        left join drac_im_customer_collection t2 on t1.id=t2.im_id
        left join drac_im_message_config t3 on t1.id=t3.im_id
        where
        t1.id=#{id}
    </select>
    <select id="findAllByPage"
            resultMap="resultMap">
        select t1.*,t3.content from drac_im_customer_collection t1
        left join drac_im_info t2 on t1.im_id=t2.id
        left join drac_im_message_config t3 on t2.id=t3.im_id
        where 1=1 and t2.merchant_id=#{condition.merchantId}
        <if test="condition.phone != null">
            and t1.phone like concat('%',#{condition.phone},'%')
        </if>
        <if test="condition.status != null">
            and t1.del_flag=#{condition.status}
        </if>
        order by t1.created_time desc
    </select>
    <select id="findByIdAndPhone"
            resultType="cn.com.glsx.entmicro.model.response.DracImCustomerCollectionResponse">
        select id as id,code_id as codeId,phone as phone from drac_im_customer_collection where im_id=#{imId}
        and phone=#{phone}
    </select>
    <select id="findMessageStatic" resultType="java.lang.Integer">
        select count(1) from drac_im_customer_collection t1
        left join drac_im_info t2 on t1.im_id=t2.id
        left join drac_im_message_config t3 on t2.id=t3.im_id
        where 1=1 and t2.merchant_id=#{merchantId}
        <if test="status != null">
            and t1.del_flag=#{status}
        </if>
    </select>
    <select id="findPhoneByState" resultType="java.lang.String">
        select phone from  drac_im_customer_collection t1
         left join drac_channel_code t2 on t1.code_id=t2.id
         where t2.code_state=#{state}
    </select>
    <select id="dracCustomerConditionPageSearch" resultMap="resultMap" parameterType="cn.com.glsx.entmicro.model.request.drainage.DracImCustomerSearchPagelRequest">
        SELECT c.id,c.`im_id`,c.`customer_id`,c.`phone`,c.`code_id`,c.`del_flag`,c.`created_by`,
        c.`created_time`,c.`updated_by`,c.`updated_time`,c.`customer_name`,m.`content`
        FROM `drac_im_customer_collection` c
        LEFT JOIN `drac_im_message_config` m ON m.`im_id`=c.`im_id`
        where c.`im_id`=#{condition.id}
        <if test="condition.phone!=null and condition.phone!=''">
            and c.`phone` like CONCAT('%',#{condition.phone},'%')
        </if>
        <if test="condition.status!=null">
            and c.`del_flag` = #{condition.status}
        </if>
        <if test="condition.customerName!=null and condition.customerName!=''">
            and c.`customer_name` like CONCAT('%',#{condition.customerName},'%')
        </if>
    </select>
</mapper>