<?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="mailCallRecordServiceDaoImpl">
|
|
<!-- 保存邮寄信电联记录信息 -->
|
<insert id="saveMailCallRecord" parameterType="Map">
|
insert into mail_call_record(
|
mail_id, call_date, call_result, call_contact, caller, remark
|
) values (
|
#{mailId}, #{callDate}, #{callResult}, #{callContact}, #{caller}, #{remark}
|
)
|
</insert>
|
|
<!-- 批量保存邮寄信电联记录信息 -->
|
<insert id="batchSaveMailCallRecord" parameterType="Map">
|
insert into mail_call_record(
|
mail_id, call_date, call_result, call_contact, caller, remark
|
) values
|
<foreach collection="mailCallRecordList" item="item" separator=",">
|
( #{item.mailId}, #{item.callDate}, #{item.callResult}, #{item.callContact}, #{item.caller}, #{item.remark} )
|
</foreach>
|
</insert>
|
|
<!-- 查询邮寄信电联记录信息 -->
|
<select id="getMailCallRecord" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.mail_id mailId,
|
t.call_date callDate,
|
t.call_result callResult,
|
t.call_contact callContact,
|
t.caller caller,
|
t.remark remark,
|
t.create_time createTime,
|
t.update_time updateTime
|
from mail_call_record t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
<if test="callDate != null">
|
and t.call_date = #{callDate}
|
</if>
|
<if test="callResult != null and callResult != ''">
|
and t.call_result = #{callResult}
|
</if>
|
<if test="callContact != null and callContact != ''">
|
and t.call_contact = #{callContact}
|
</if>
|
<if test="caller != null and caller != ''">
|
and t.caller = #{caller}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
<if test="startUpdateTime != null">
|
and t.update_time >= #{startUpdateTime}
|
</if>
|
<if test="endUpdateTime != null">
|
and t.update_time <= #{endUpdateTime}
|
</if>
|
order by t.id desc
|
<if test="page != -1 and page != null">
|
limit #{page}, #{row}
|
</if>
|
</select>
|
|
<!-- 更新邮寄信电联记录信息 -->
|
<update id="updateMailCallRecord" parameterType="Map">
|
update mail_call_record t
|
<set>
|
<if test="mailId != null and mailId != ''">
|
t.mail_id = #{mailId},
|
</if>
|
<if test="callDate != null">
|
t.call_date = #{callDate},
|
</if>
|
<if test="callResult != null and callResult != ''">
|
t.call_result = #{callResult},
|
</if>
|
<if test="callContact != null and callContact != ''">
|
t.call_contact = #{callContact},
|
</if>
|
<if test="caller != null and caller != ''">
|
t.caller = #{caller},
|
</if>
|
<if test="remark != null">
|
t.remark = #{remark},
|
</if>
|
t.update_time = CURRENT_TIMESTAMP
|
</set>
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
</update>
|
|
<!-- 删除邮寄信电联记录信息 -->
|
<delete id="deleteMailCallRecord" parameterType="Map">
|
delete from mail_call_record t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
<if test="callResult != null and callResult != ''">
|
and t.call_result = #{callResult}
|
</if>
|
</delete>
|
|
<!-- 查询邮寄信电联记录数量 -->
|
<select id="queryMailCallRecordCount" parameterType="Map" resultType="Map">
|
select count(1) count
|
from mail_call_record t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
<if test="callResult != null and callResult != ''">
|
and t.call_result = #{callResult}
|
</if>
|
<if test="callContact != null and callContact != ''">
|
and t.call_contact = #{callContact}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
<if test="startUpdateTime != null">
|
and t.update_time >= #{startUpdateTime}
|
</if>
|
<if test="endUpdateTime != null">
|
and t.update_time <= #{endUpdateTime}
|
</if>
|
</select>
|
|
<!-- 查询邮寄信电联记录统计信息 -->
|
<select id="queryMailCallRecordStatistics" parameterType="Map" resultType="Map">
|
select
|
count(1) as total_count,
|
min(t.create_time) as earliest_create_time,
|
max(t.create_time) as latest_create_time,
|
min(t.update_time) as earliest_update_time,
|
max(t.update_time) as latest_update_time
|
from mail_call_record t
|
where 1 = 1
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
<if test="callResult != null and callResult != ''">
|
and t.call_result = #{callResult}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
</select>
|
|
<!-- 按年月分组统计邮寄信电联记录数量 -->
|
<select id="queryMailCallRecordByMonth" parameterType="Map" resultType="Map">
|
select
|
date_format(t.create_time, '%Y-%m') as month,
|
count(1) as count,
|
count(distinct t.mail_id) as mail_count
|
from mail_call_record t
|
where 1 = 1
|
<if test="mailId != null and mailId != ''">
|
and t.mail_id = #{mailId}
|
</if>
|
<if test="callResult != null and callResult != ''">
|
and t.call_result = #{callResult}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
group by date_format(t.create_time, '%Y-%m')
|
order by month desc
|
</select>
|
|
<!-- 根据mail_id查询最新的邮寄信电联记录信息 -->
|
<select id="getLatestMailCallRecordByMailId" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.mail_id mailId,
|
t.call_date callDate,
|
t.call_result callResult,
|
t.call_contact callContact,
|
t.caller caller,
|
t.remark remark,
|
t.create_time createTime,
|
t.update_time updateTime
|
from mail_call_record t
|
where t.mail_id = #{mailId}
|
order by t.update_time desc
|
limit 1
|
</select>
|
|
</mapper>
|