MassChatDetailMapper.xml 2.85 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.MassChatDetailMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.MassChatDetail">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="staff_id" jdbcType="INTEGER" property="staffId" />
    <result column="chat_id" jdbcType="VARCHAR" property="chatId" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, staff_id, chat_id, `status`, send_time, del_flag
  </sql>
  <select id="selectBystaffIds" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/> scrm_mass_chat_detail
    where staff_id in
    <foreach collection="staffIds" index="staffId" open="(" close=")" separator=",">
      #{staffId}
    </foreach>
    and del_flag = 0;
  </select>

  <select id="countCustomerSender" resultType="cn.com.glsx.entmicro.entity.mass.MassStatisticItemEntity">
    SELECT COUNT(*) AS dataCount,a.`status` AS dataType FROM `scrm_mass_chat_detail` a
    LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
    <where>
      b.mass_id=#{massId}
      GROUP BY a.`status`
    </where>
  </select>

  <select id="searchMassGroupDetailList" resultType="cn.com.glsx.entmicro.entity.mass.MassChatItemEntity">
    SELECT a.`id`,b.`staff_id` as staffId,b.`mass_id` as massId,a.`chat_id` as chatId,a.`status`,a.`send_time` as sendTime,c.merchant_id as merchantId,a.staff_relation_id as staffRelationId
    FROM `scrm_mass_chat_detail` a
    LEFT JOIN `scrm_mass_detail_staff` b ON b.`id`=a.`staff_relation_id`
    LEFT JOIN `scrm_mass` c ON c.id=b.`mass_id`
    <where>
      b.`mass_id`=#{searchRequest.massId}
      <if test="searchRequest.status!=null">
        and a.`status`=#{searchRequest.status}
      </if>
      <if test="searchRequest.staffId!=null" >
        AND b.`staff_id` = #{searchRequest.staffId}
      </if>
    </where>
  </select>
    <select id="countChats" resultType="java.lang.Integer">
    SELECT
      COUNT(1)
    FROM
      `scrm_mass_chat_detail` c
    WHERE c.`staff_relation_id` IN
      (SELECT
        id
      FROM
        `scrm_mass_detail_staff` s
      WHERE s.`mass_id` = #{massId})
    </select>

    <update id="updateMassDetailChatSendResult" >
    UPDATE `scrm_mass_chat_detail` a,`scrm_mass_detail_staff` b
    SET a.`status`=#{status},a.`send_time`=#{sendTime}
    <where>
      a.`staff_relation_id`=b.`id` AND b.`id`=#{staffRelationId} AND a.`chat_id`=#{chatId}
    </where>
  </update>

</mapper>