1
0

CompanyEmailHistoryMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.simuwang.base.mapper.CompanyEmailSendHistoryMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.CompanyEmailSendHistoryDO">
  5. <id column="id" property="id"/>
  6. <result column="company_id" property="companyId"/>
  7. <result column="company_name" property="companyName"/>
  8. <result column="email" property="email"/>
  9. <result column="send_status" property="sendStatus"/>
  10. <result column="send_time" property="sendTime"/>
  11. <result column="send_remark" property="sendRemark"/>
  12. <result column="isvalid" property="isvalid"/>
  13. <result column="createtime" property="createTime"/>
  14. <result column="updatetime" property="updateTime"/>
  15. <result column="creatorid" property="creatorId"/>
  16. <result column="updaterid" property="updaterId"/>
  17. </resultMap>
  18. <insert id="saveCompanyEmailSendHistory"
  19. parameterType="com.simuwang.base.pojo.dos.CompanyEmailSendHistoryDO">
  20. insert into PPW_EMAIL.company_email_send_history(company_id,email,send_status,send_time,send_remark,isvalid,createtime,updatetime,creatorid,updaterid)
  21. values (#{companyId},#{email},#{sendStatus},#{sendTime},#{sendRemark},#{isvalid},#{createTime},#{updateTime},#{creatorId},#{updaterId})
  22. </insert>
  23. <update id="deleteEmailHistory">
  24. update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where email in
  25. <foreach item="email" collection="emailList" open="(" separator="," close=")">
  26. #{email}
  27. </foreach>
  28. </update>
  29. <update id="deleteEmailHistoryByIds">
  30. update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where id in
  31. <foreach item="id" collection="ids" open="(" separator="," close=")">
  32. #{id}
  33. </foreach>
  34. </update>
  35. <select id="searchCompanyEmailList" resultMap="BaseResultMap">
  36. SELECT
  37. cec.id,
  38. cec.company_id,
  39. c.company_name,
  40. cec.email,
  41. maxce.send_time,
  42. maxce.send_remark,
  43. ifnull(maxce.send_status,-1) as send_status
  44. FROM
  45. PPW_EMAIL.company_email_config cec
  46. JOIN PPW_EMAIL.pvn_company_info c
  47. ON cec.company_id = c.company_id
  48. LEFT JOIN (select me.email as email,max(me.send_time) as send_time,me.company_id,me.send_remark,me.send_status from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email,me.company_id) maxce
  49. ON cec.email = maxce.email and cec.company_id = maxce.company_id
  50. WHERE cec.isvalid = 1 and c.isvalid=1
  51. <if test="companyName != null and companyName !=''">
  52. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
  53. </if>
  54. <if test="email != null and email !=''">
  55. and cec.email like concat('%',#{email},'%')
  56. </if>
  57. <if test="sendStatus != null">
  58. and maxce.send_status=#{sendStatus}
  59. </if>
  60. order by maxce.send_time desc
  61. limit #{offset},#{pageSize}
  62. </select>
  63. <select id="countCompanyEmailList" resultType="java.lang.Long"
  64. parameterType="com.simuwang.base.pojo.dto.query.CompanyEmailPageQuery">
  65. SELECT
  66. count(cec.company_id)
  67. from
  68. PPW_EMAIL.company_email_config cec
  69. JOIN PPW_EMAIL.pvn_company_info c
  70. ON cec.company_id = c.company_id
  71. LEFT JOIN (select me.email as email,max(me.send_time) as send_time,me.company_id,me.send_remark,me.send_status from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email,me.company_id) maxce
  72. ON cec.email = maxce.email and cec.company_id = maxce.company_id
  73. WHERE cec.isvalid = 1 and c.isvalid=1
  74. <if test="companyName != null and companyName !=''">
  75. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
  76. </if>
  77. <if test="email != null and email !=''">
  78. and cec.email like concat('%',#{email},'%')
  79. </if>
  80. <if test="sendStatus != null">
  81. and maxce.send_status=#{sendStatus}
  82. </if>
  83. </select>
  84. <select id="searchEmailHistory" resultMap="BaseResultMap">
  85. SELECT distinct
  86. cesh.id,
  87. cec.company_id,
  88. c.company_name,
  89. cesh.email,
  90. cesh.send_time,
  91. cesh.send_remark,
  92. cesh.send_status
  93. FROM
  94. PPW_EMAIL.company_email_send_history cesh
  95. JOIN PPW_EMAIL.company_email_config cec
  96. ON cec.email = cesh.email
  97. JOIN PPW_EMAIL.pvn_company_info c
  98. ON cec.company_id = c.company_id
  99. WHERE cec.isvalid = 1
  100. AND cesh.isvalid = 1 and c.isvalid =1
  101. <if test="companyId != null and companyId !=''">
  102. and c.company_id=#{companyId}
  103. </if>
  104. limit #{offset},#{pageSize}
  105. </select>
  106. <select id="countCompanyEmailhistory" resultType="java.lang.Long"
  107. parameterType="com.simuwang.base.pojo.dto.query.CompanyEmailHistoryPageQuery">
  108. SELECT
  109. count(distinct cesh.id)
  110. FROM
  111. PPW_EMAIL.company_email_send_history cesh
  112. JOIN PPW_EMAIL.company_email_config cec
  113. ON cec.email = cesh.email
  114. JOIN PPW_EMAIL.pvn_company_info c
  115. ON cec.company_id = c.company_id
  116. WHERE cec.isvalid = 1
  117. AND cesh.isvalid = 1 and c.isvalid =1
  118. <if test="companyId != null and companyId !=''">
  119. and c.company_id=#{companyId}
  120. </if>
  121. </select>
  122. </mapper>