| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?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="com.fs.company.mapper.CompanySmsLogsMapper">
- <resultMap type="CompanySmsLogs" id="CompanySmsLogsResult">
- <result property="logsId" column="logs_id" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="customerId" column="customer_id" />
- <result property="tempId" column="temp_id" />
- <result property="tempCode" column="temp_code" />
- <result property="phone" column="phone" />
- <result property="content" column="content" />
- <result property="createTime" column="create_time" />
- <result property="sendTime" column="send_time" />
- <result property="status" column="status" />
- <result property="mid" column="mid" />
- <result property="stat" column="stat" />
- <result property="replyContent" column="reply_content" />
- <result property="number" column="number" />
- <result property="type" column="type" />
- <result property="sopSmsLogId" column="sop_sms_log_id" />
- <result property="smsIndex" column="sms_index" />
- </resultMap>
- <sql id="selectCompanySmsLogsVo">
- select logs_id, company_id,type, company_user_id, customer_id, temp_id, temp_code, phone, content,
- create_time, send_time, status,mid,stat,reply_content,number,sop_sms_log_id,sms_index
- from company_sms_logs
- </sql>
- <select id="selectCompanySmsLogsById" parameterType="Long" resultMap="CompanySmsLogsResult">
- <include refid="selectCompanySmsLogsVo"/>
- where logs_id = #{logsId}
- </select>
- <insert id="insertCompanySmsLogs" parameterType="CompanySmsLogs" useGeneratedKeys="true" keyProperty="logsId">
- insert into company_sms_logs
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="customerId != null">customer_id,</if>
- <if test="tempId != null">temp_id,</if>
- <if test="tempCode != null">temp_code,</if>
- <if test="phone != null">phone,</if>
- <if test="content != null">content,</if>
- <if test="createTime != null">create_time,</if>
- <if test="sendTime != null">send_time,</if>
- <if test="status != null">status,</if>
- <if test="mid != null">mid,</if>
- <if test="stat != null">stat,</if>
- <if test="replyContent != null">reply_content,</if>
- <if test="number != null">number,</if>
- <if test="type != null">type,</if>
- <if test="sopSmsLogId != null">sop_sms_log_id,</if>
- <if test="smsIndex != null">sms_index,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="customerId != null">#{customerId},</if>
- <if test="tempId != null">#{tempId},</if>
- <if test="tempCode != null">#{tempCode},</if>
- <if test="phone != null">#{phone},</if>
- <if test="content != null">#{content},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="sendTime != null">#{sendTime},</if>
- <if test="status != null">#{status},</if>
- <if test="mid != null">#{mid},</if>
- <if test="stat != null">#{stat},</if>
- <if test="replyContent != null">#{replyContent},</if>
- <if test="number != null">#{number},</if>
- <if test="type != null">#{type},</if>
- <if test="sopSmsLogId != null">#{sopSmsLogId},</if>
- <if test="smsIndex != null">#{smsIndex},</if>
- </trim>
- </insert>
- <update id="updateCompanySmsLogs" parameterType="CompanySmsLogs">
- update company_sms_logs
- <trim prefix="SET" suffixOverrides=",">
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="customerId != null">customer_id = #{customerId},</if>
- <if test="tempId != null">temp_id = #{tempId},</if>
- <if test="tempCode != null">temp_code = #{tempCode},</if>
- <if test="phone != null">phone = #{phone},</if>
- <if test="content != null">content = #{content},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="sendTime != null">send_time = #{sendTime},</if>
- <if test="status != null">status = #{status},</if>
- <if test="mid != null">mid = #{mid},</if>
- <if test="stat != null">stat = #{stat},</if>
- <if test="replyContent != null">reply_content = #{replyContent},</if>
- <if test="number != null">number = #{number},</if>
- <if test="type != null">type = #{type},</if>
- <if test="sopSmsLogId != null">sop_sms_log_id = #{sopSmsLogId},</if>
- </trim>
- where logs_id = #{logsId}
- </update>
- <delete id="deleteCompanySmsLogsById" parameterType="Long">
- delete from company_sms_logs where logs_id = #{logsId}
- </delete>
- <delete id="deleteCompanySmsLogsByIds" parameterType="String">
- delete from company_sms_logs where logs_id in
- <foreach item="logsId" collection="array" open="(" separator="," close=")">
- #{logsId}
- </foreach>
- </delete>
- <select id="selectSmsLogsCounts" resultType="com.alibaba.fastjson.JSONObject">
- SELECT count(t.company_user_id ) AS smsCount,count( IF ( t.status =1,1, NULL ) ) AS successCount, t.type
- FROM
- (
- SELECT DATE_FORMAT( s.create_time, #{sqlDateFormat} ) AS type, s.company_user_id,s.status
- FROM
- company_sms_logs AS s
- WHERE
- (DATE_FORMAT(s.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
- AND s.company_user_id IN
- <foreach item="item" collection="userIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- ) t
- GROUP BY t.type
- </select>
- <select id="selectCompanySmsLogsListQueryYsytg" resultType="com.fs.company.vo.CompanySmsLogsQueryVO">
- SELECT
- csl.logs_id AS logsId,
- c.company_name AS companyName,
- cu.user_name AS companyUserName,
- csl.temp_code AS tempCode,
- csl.phone AS phone,
- csl.number AS number,
- csl.status AS status,
- csl.type AS type,
- csl.content AS content,
- <!-- 根据optionType动态选择关联字段 -->
- <choose>
- <when test="dto.optionType == 1">
- fuc.course_name AS courseName,
- fucv.title AS videoTitle,
- </when>
- <otherwise>
- NULL AS courseName,
- NULL AS videoTitle,
- </otherwise>
- </choose>
- csl.create_time AS createTime,
- csl.send_time AS sendTime
- FROM
- company_sms_logs csl
- LEFT JOIN company c ON csl.company_id = c.company_id
- LEFT JOIN company_user cu ON csl.company_user_id = cu.user_id
- <!-- 根据optionType动态关联不同的表 -->
- <choose>
- <when test="dto.optionType == 1">
- LEFT JOIN qw_course_link_send_msg_log qclog ON csl.logs_id = qclog.company_sms_logs_id
- LEFT JOIN fs_user_course fuc ON fuc.course_id = qclog.course_id
- LEFT JOIN fs_user_course_video fucv ON fucv.video_id = qclog.video_id
- </when>
- <when test="dto.optionType == 2">
- LEFT JOIN qw_acquisition_send_msg_log qalog ON csl.logs_id = qalog.company_sms_logs_id
- </when>
- </choose>
- <where>
- <if test="dto.companyId != null">
- AND csl.company_id = #{dto.companyId}
- </if>
- <if test="dto.status != null">
- AND csl.status = #{dto.status}
- </if>
- <if test="dto.companyUserName != null and dto.companyUserName != ''">
- AND cu.nick_name LIKE CONCAT('%', #{dto.companyUserName}, '%')
- </if>
- <if test="dto.phone != null and dto.phone != ''">
- AND csl.phone LIKE CONCAT('%', #{dto.phone}, '%')
- </if>
- <if test="dto.tempCode != null and dto.tempCode != ''">
- AND csl.temp_code = #{dto.tempCode}
- </if>
- <if test="dto.type != null and dto.type != ''">
- AND csl.type = #{dto.type}
- </if>
- <if test="dto.beginCreateTime != null">
- AND csl.create_time >= #{dto.beginCreateTime}
- </if>
- <if test="dto.endCreateTime != null">
- AND csl.create_time <= #{dto.endCreateTime}
- </if>
- <!-- 课程链接类型特有查询条件 -->
- <if test="dto.optionType == 1">
- <if test="dto.courseId != null">
- AND fuc.course_id = #{dto.courseId}
- </if>
- <if test="dto.videoId != null">
- AND fucv.video_id = #{dto.videoId}
- </if>
- </if>
- </where>
- ORDER BY csl.create_time DESC
- </select>
- </mapper>
|