CompanyEmailHistoryMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. <update id="deleteEmailHistory">
  19. update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where email in
  20. <foreach item="email" collection="emailList" open="(" separator="," close=")">
  21. #{email}
  22. </foreach>
  23. </update>
  24. <update id="deleteEmailHistoryByIds">
  25. update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where id in
  26. <foreach item="id" collection="ids" open="(" separator="," close=")">
  27. #{id}
  28. </foreach>
  29. </update>
  30. <select id="searchCompanyEmailList" resultMap="BaseResultMap">
  31. SELECT
  32. cec.id,
  33. cec.company_id,
  34. c.company_name,
  35. cec.email,
  36. maxce.send_time,
  37. maxce.send_remark,
  38. maxce.send_status
  39. FROM
  40. PPW_EMAIL.company_email_config cec
  41. JOIN PPW_EMAIL.pvn_company_info c
  42. ON cec.company_id = c.company_id
  43. 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
  44. ON cec.email = maxce.email and cec.company_id = maxce.company_id
  45. WHERE cec.isvalid = 1 and c.isvalid=1
  46. <if test="companyName != null and companyName !=''">
  47. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
  48. </if>
  49. <if test="email != null and email !=''">
  50. and cec.email like concat('%',#{email},'%')
  51. </if>
  52. <if test="sendStatus != null">
  53. and maxce.send_status=#{sendStatus}
  54. </if>
  55. limit #{offset},#{pageSize}
  56. </select>
  57. <select id="countCompanyEmailList" resultType="java.lang.Long"
  58. parameterType="com.simuwang.base.pojo.dto.query.CompanyEmailPageQuery">
  59. SELECT
  60. count(cec.company_id)
  61. from
  62. PPW_EMAIL.company_email_config cec
  63. JOIN PPW_EMAIL.pvn_company_info c
  64. ON cec.company_id = c.company_id
  65. 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
  66. ON cec.email = maxce.email and cec.company_id = maxce.company_id
  67. WHERE cec.isvalid = 1 and c.isvalid=1
  68. <if test="companyName != null and companyName !=''">
  69. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
  70. </if>
  71. <if test="email != null and email !=''">
  72. and cec.email like concat('%',#{email},'%')
  73. </if>
  74. <if test="sendStatus != null">
  75. and maxce.send_status=#{sendStatus}
  76. </if>
  77. </select>
  78. <select id="searchEmailHistory" resultMap="BaseResultMap">
  79. SELECT distinct
  80. cesh.id,
  81. cec.company_id,
  82. c.company_name,
  83. cesh.email,
  84. cesh.send_time,
  85. cesh.send_remark,
  86. cesh.send_status
  87. FROM
  88. PPW_EMAIL.company_email_send_history cesh
  89. JOIN PPW_EMAIL.company_email_config cec
  90. ON cec.email = cesh.email
  91. JOIN PPW_EMAIL.pvn_company_info c
  92. ON cec.company_id = c.company_id
  93. WHERE cec.isvalid = 1
  94. AND cesh.isvalid = 1 and c.isvalid =1
  95. <if test="companyId != null and companyId !=''">
  96. and c.company_id=#{companyId}
  97. </if>
  98. limit #{offset},#{pageSize}
  99. </select>
  100. <select id="countCompanyEmailhistory" resultType="java.lang.Long"
  101. parameterType="com.simuwang.base.pojo.dto.query.CompanyEmailHistoryPageQuery">
  102. SELECT
  103. count(distinct cesh.id)
  104. FROM
  105. PPW_EMAIL.company_email_send_history cesh
  106. JOIN PPW_EMAIL.company_email_config cec
  107. ON cec.email = cesh.email
  108. JOIN PPW_EMAIL.pvn_company_info c
  109. ON cec.company_id = c.company_id
  110. WHERE cec.isvalid = 1
  111. AND cesh.isvalid = 1 and c.isvalid =1
  112. <if test="companyId != null and companyId !=''">
  113. and c.company_id=#{companyId}
  114. </if>
  115. </select>
  116. </mapper>