DeletionInfoMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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.daq.DeletionInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.DeletionInfoDO">
  5. <id column="id" property="id"/>
  6. <result column="fund_id" property="fundId"/>
  7. <result column="channel_id" property="channelId"/>
  8. <result column="channel_name" property="channelName"/>
  9. <result column="deletion_date" property="deletionDate"/>
  10. <result column="deletion_type" property="deletionType"/>
  11. <result column="company_name" property="companyName"/>
  12. <result column="fund_name" property="fundName"/>
  13. <result column="deletion_num" property="deletionNum"/>
  14. <result column="processed_num" property="processedNum"/>
  15. <result column="isvalid" property="isvalid"/>
  16. <result column="creatorid" property="creatorId"/>
  17. <result column="createtime" property="createTime"/>
  18. <result column="updaterid" property="updaterId"/>
  19. <result column="updatetime" property="updateTime"/>
  20. <result column="is_send" property="isSend"/>
  21. </resultMap>
  22. <insert id="saveDeletionInfoDO" parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
  23. insert into deletion_info(fund_id,deletion_type,deletion_date,isvalid,createtime,updatetime,is_send,channel_id)
  24. values (#{fundId},#{deletionType},#{deletionDate},#{isvalid},#{createTime},#{updateTime},#{isSend},#{channelId})
  25. </insert>
  26. <insert id="batchSaveDeletionInfoDO">
  27. insert into deletion_info(fund_id,deletion_type,deletion_date,isvalid,createtime,updatetime,is_send,channel_id)
  28. values
  29. <foreach collection="itemDoList" item="itemDo" index="index" separator=",">
  30. (#{itemDo.fundId},#{itemDo.deletionType},#{itemDo.deletionDate},#{itemDo.isvalid},#{itemDo.createTime},#{itemDo.updateTime},#{itemDo.isSend},#{itemDo.channelId})
  31. </foreach>
  32. </insert>
  33. <update id="update" parameterType="com.simuwang.base.pojo.dos.FundDeletionInfoDO">
  34. update deletion_info set fund_id=#{fundId},deletion_type=#{deletionType},deletion_date=#{deletionDate},remark=#{remark},updatetime=#{updateTime}
  35. where id=#{id} and isvalid=1
  36. </update>
  37. <update id="batchUpdate">
  38. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  39. update deletion_info
  40. <set>
  41. fund_id=#{itemDo.fundId},
  42. deletion_type = #{itemDo.deletionType},
  43. deletion_date=#{itemDo.deletionDate},
  44. remark=#{itemDo.remark},
  45. updatetime=now(),
  46. updaterid=#{itemDo.updaterId}
  47. </set>
  48. where isvalid = 1 and id=#{itemDo.id} and channel_id=#{itemDo.channelId}
  49. </foreach>
  50. </update>
  51. <update id="updateRemark">
  52. update deletion_info set remark=#{remark},updaterid=#{updaterId} where isvalid=1 and remark is null
  53. <if test="fundId != null and fundId !=''">
  54. and fund_id=#{fundId}
  55. </if>
  56. <if test="deletionType != null and deletionType !=''">
  57. and deletion_type=#{deletionType}
  58. </if>
  59. <if test="deletionDate != null and deletionDate !=''">
  60. and deletion_date=#{deletionDate}
  61. </if>
  62. <if test="channelId != null and channelId !=''">
  63. and channel_id=#{channelId}
  64. </if>
  65. </update>
  66. <delete id="deleteDeletionRemark">
  67. update deletion_info set isvalid=0,updatetime=now() where isvalid=1 and fund_id=#{fundId} and deletion_type=#{deletionType}
  68. and deletion_date in
  69. <foreach item="tradeDate" collection="list" open="(" separator="," close=")">
  70. #{tradeDate}
  71. </foreach>
  72. </delete>
  73. <delete id="deleteDeletion">
  74. update deletion_info set isvalid=0,updatetime=now() where isvalid=1 and fund_id=#{fundId} and channel_id=#{channelId} and deletion_type=#{deletionType} and remark is null
  75. </delete>
  76. <select id="searchDeletionList" resultMap="BaseResultMap"
  77. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  78. SELECT
  79. d.fund_id,
  80. info.fund_name,
  81. c.company_name,
  82. d.deletion_type,
  83. ddn.deletion_num,
  84. ddp.processed_num,
  85. d.last_deletion_date,
  86. ci.id as channel_id,
  87. ci.channel_name
  88. FROM
  89. (select de.channel_id,de.fund_id,de.deletion_type,max(de.deletion_date) as last_deletion_date from deletion_info de where de.isvalid=1
  90. group by de.fund_id,de.deletion_type,de.channel_id) d
  91. LEFT JOIN pvn_fund_info info
  92. ON d.fund_id = info.fund_id and info.isvalid=1
  93. LEFT JOIN pvn_company_info c
  94. ON info.trust_id = c.company_id and c.isvalid=1
  95. LEFT JOIN
  96. (SELECT di.channel_id,
  97. di.fund_id,
  98. di.deletion_type,
  99. COUNT(di.fund_id) AS deletion_num
  100. FROM
  101. deletion_info di
  102. WHERE di.isvalid = 1
  103. AND di.remark IS NULL
  104. GROUP BY di.channel_id,di.fund_id,
  105. di.deletion_type) ddn
  106. ON ddn.fund_id = d.fund_id
  107. AND d.deletion_type = ddn.deletion_type and d.channel_id = ddn.channel_id
  108. LEFT JOIN
  109. (SELECT dip.channel_id,
  110. dip.fund_id,
  111. dip.deletion_type,
  112. COUNT(dip.fund_id) AS processed_num
  113. FROM
  114. deletion_info dip
  115. WHERE dip.isvalid = 1
  116. AND dip.remark IS NOT NULL
  117. GROUP BY dip.channel_id,dip.fund_id,
  118. dip.deletion_type) ddp
  119. ON ddp.fund_id = d.fund_id
  120. AND d.deletion_type = ddp.deletion_type and d.channel_id = ddp.channel_id
  121. left join channel_info ci
  122. on ci.id = d.channel_id and ci.isvalid=1
  123. WHERE 1=1
  124. <if test="companyName != null and companyName !=''">
  125. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  126. </if>
  127. <if test="fundName != null and fundName !=''">
  128. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  129. </if>
  130. <if test="deletionType != null and deletionType != -1">
  131. and d.deletion_type=#{deletionType}
  132. </if>
  133. <if test="deletionStartNum != null and deletionStartNum != ''">
  134. and ddn.deletion_num >= #{deletionStartNum}
  135. </if>
  136. <if test="channelName != null and channelName != ''">
  137. and ci.channel_name = #{channelName}
  138. </if>
  139. <if test="deletionEndNum != null and deletionEndNum != ''">
  140. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  141. </if>
  142. <choose>
  143. <when test="sort != null and sort !='' and sort=='lastDeletionDate' and order != null and order !=''">
  144. order by d.last_deletion_date ${order}
  145. </when>
  146. <otherwise>
  147. order by d.last_deletion_date desc
  148. </otherwise>
  149. </choose>
  150. limit #{offset},#{pageSize}
  151. </select>
  152. <select id="countDeletion" resultType="java.lang.Long"
  153. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  154. select count(1) from
  155. (select de.channel_id,de.fund_id,de.deletion_type,max(de.deletion_date) as last_deletion_date from deletion_info de where de.isvalid=1
  156. group by de.fund_id,de.deletion_type,de.channel_id) d
  157. LEFT JOIN pvn_fund_info info
  158. ON d.fund_id = info.fund_id and info.isvalid=1
  159. LEFT JOIN pvn_company_info c
  160. ON info.trust_id = c.company_id and c.isvalid=1
  161. LEFT JOIN
  162. (SELECT di.channel_id,
  163. di.fund_id,
  164. di.deletion_type,
  165. COUNT(di.fund_id) AS deletion_num
  166. FROM
  167. deletion_info di
  168. WHERE di.isvalid = 1
  169. AND di.remark IS NULL
  170. GROUP BY di.channel_id,di.fund_id,
  171. di.deletion_type) ddn
  172. ON ddn.fund_id = d.fund_id
  173. AND d.deletion_type = ddn.deletion_type and d.channel_id = ddn.channel_id
  174. LEFT JOIN
  175. (SELECT dip.channel_id,
  176. dip.fund_id,
  177. dip.deletion_type,
  178. COUNT(dip.fund_id) AS processed_num
  179. FROM
  180. deletion_info dip
  181. WHERE dip.isvalid = 1
  182. AND dip.remark IS NOT NULL
  183. GROUP BY dip.channel_id,dip.fund_id,
  184. dip.deletion_type) ddp
  185. ON ddp.fund_id = d.fund_id
  186. AND d.deletion_type = ddp.deletion_type and d.channel_id = ddp.channel_id
  187. left join channel_info ci
  188. on ci.id = d.channel_id and ci.isvalid=1
  189. WHERE 1=1
  190. <if test="companyName != null and companyName !=''">
  191. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  192. </if>
  193. <if test="fundName != null and fundName !=''">
  194. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  195. </if>
  196. <if test="deletionType != null and deletionType != -1">
  197. and d.deletion_type=#{deletionType}
  198. </if>
  199. <if test="deletionStartNum != null and deletionStartNum != ''">
  200. and ddn.deletion_num >= #{deletionStartNum}
  201. </if>
  202. <if test="channelName != null and channelName != ''">
  203. and ci.channel_name = #{channelName}
  204. </if>
  205. <if test="deletionEndNum != null and deletionEndNum != ''">
  206. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  207. </if>
  208. </select>
  209. <select id="getLastDeletionDateByFundId" resultType="java.lang.String">
  210. select max(deletion_date) from deletion_info where fund_id=#{fundId} and deletion_type=#{deletionType}
  211. </select>
  212. <resultMap id="BaseMap" type="com.simuwang.base.pojo.dos.FundDeletionInfoDO">
  213. <id column="id" property="id"/>
  214. <result column="fund_id" property="fundId"/>
  215. <result column="fund_name" property="fundName"/>
  216. <result column="deletion_date" property="deletionDate"/>
  217. <result column="deletion_type" property="deletionType"/>
  218. <result column="remark" property="remark"/>
  219. <result column="isvalid" property="isvalid"/>
  220. <result column="creatorid" property="creatorId"/>
  221. <result column="createtime" property="createTime"/>
  222. <result column="updaterid" property="updaterId"/>
  223. <result column="updatetime" property="updateTime"/>
  224. </resultMap>
  225. <select id="searchFundDeletionList" resultMap="BaseMap"
  226. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  227. SELECT
  228. d.id,
  229. d.fund_id,
  230. info.fund_name,
  231. d.deletion_type,
  232. d.deletion_date,
  233. d.remark,
  234. d.isvalid,
  235. d.creatorid,
  236. d.updaterid,
  237. d.createtime,
  238. d.updatetime
  239. FROM
  240. deletion_info d
  241. left join pvn_fund_info info
  242. on d.fund_id =info.fund_id and info.isvalid=1
  243. WHERE d.isvalid = 1
  244. AND d.fund_id = #{fundId}
  245. AND d.deletion_type = #{deletionType}
  246. AND d.channel_id = #{channelId}
  247. ORDER BY deletion_date DESC
  248. limit #{offset},#{pageSize}
  249. </select>
  250. <select id="countFundDeletionList" resultType="java.lang.Long"
  251. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  252. select count(d.id)
  253. FROM
  254. deletion_info d
  255. left join pvn_fund_info info
  256. on d.fund_id =info.fund_id and info.isvalid=1
  257. WHERE d.isvalid = 1
  258. AND d.fund_id = #{fundId}
  259. AND d.deletion_type = #{deletionType}
  260. AND d.channel_id = #{channelId}
  261. ORDER BY deletion_date DESC
  262. </select>
  263. <select id="selectFundDeletionInfoVOList" resultType="com.simuwang.base.pojo.dos.FundDeletionInfoDO"
  264. parameterType="java.util.List">
  265. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime,channel_id
  266. from deletion_info where isvalid=1 and remark is null
  267. <if test="fundId != null and fundId !=''">
  268. and fund_id = #{fundId}
  269. </if>
  270. <if test="deletionType != null">
  271. and deletion_type=#{deletionType}
  272. </if>
  273. order by fund_id desc,deletion_type desc ,deletion_date desc
  274. </select>
  275. <select id="getDeletionInfoDO" resultType="com.simuwang.base.pojo.dos.DeletionInfoDO"
  276. parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
  277. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime,channel_id
  278. from deletion_info where fund_id=#{fundId} and deletion_type=#{deletionType} and channel_id=#{channelId} and deletion_date in
  279. <foreach item="tradeDate" collection="list" open="(" separator="," close=")">
  280. #{tradeDate}
  281. </foreach>
  282. </select>
  283. <resultMap id="BaseEmailMap" type="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  284. <result column="fund_id" property="fundId"/>
  285. <result column="fund_name" property="fundName"/>
  286. <result column="company_name" property="companyName"/>
  287. <result column="deletion_date" property="deletionDate"/>
  288. <result column="deletion_type" property="deletionType"/>
  289. <result column="channel_id" property="channelId"/>
  290. <result column="channel_name" property="channelName"/>
  291. </resultMap>
  292. <select id="selectDeletionInfoByFundId" resultMap="BaseEmailMap">
  293. select info.fund_id,info.fund_name,c.company_name,d.deletion_type,d.deletion_date,ci.id as channel_id,ci.channel_name
  294. from deletion_info d
  295. join pvn_fund_info info on d.fund_id=info.fund_id
  296. join pvn_company_info c on c.company_id=info.trust_id
  297. left join channel_info ci on ci.id=d.channel_id and ci.isvalid=1
  298. where d.isvalid=1 and info.isvalid=1 and c.isvalid=1 and d.remark is null and d.is_send=0
  299. and d.fund_id in
  300. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  301. #{fundId}
  302. </foreach>
  303. order by info.fund_id desc,d.deletion_type desc,d.deletion_date desc
  304. </select>
  305. <select id="countFundDeletion" resultType="java.lang.Integer">
  306. select count(1) from deletion_info where isvalid=1 and fund_id =#{fundId} and remark is null
  307. </select>
  308. <select id="selectDeletionDetailByFundId" resultType="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  309. select info.fund_id,info.fund_name,c.company_name,d.deletion_type,d.deletion_date,ci.id as channel_id,ci.channel_name
  310. from deletion_info d
  311. join pvn_fund_info info on d.fund_id=info.fund_id
  312. left join pvn_company_info c on c.company_id=info.trust_id and c.isvalid=1
  313. left join channel_info ci on ci.id=d.channel_id and ci.isvalid=1
  314. where d.isvalid=1 and info.isvalid=1 and d.remark is null and d.is_send=0
  315. and d.fund_id = #{fundId} and d.createtime >= #{updateTime}
  316. order by info.fund_id desc,d.deletion_type desc,d.deletion_date desc
  317. </select>
  318. <update id="updateSendStatusByFundId">
  319. update deletion_info d set d.is_send=1,d.updatetime=now() where d.isvalid=1
  320. and d.fund_id in
  321. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  322. #{fundId}
  323. </foreach>
  324. </update>
  325. <update id="updateDeletionInfoDO">
  326. update deletion_info d set isvalid=1,updatetime=now() where id=#{id}
  327. </update>
  328. <update id="batchUpdateDeletionInfoDO">
  329. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  330. update deletion_info
  331. <set>
  332. fund_id=#{itemDo.fundId},
  333. deletion_type = #{itemDo.deletionType},
  334. deletion_date=#{itemDo.deletionDate},
  335. remark=#{itemDo.remark},
  336. updatetime=now(),
  337. isvalid=#{itemDo.isvalid},
  338. updaterid=#{itemDo.updaterId}
  339. </set>
  340. where id=#{itemDo.id}
  341. </foreach>
  342. </update>
  343. <update id="batchUpdateRemark">
  344. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  345. update deletion_info set remark=#{itemDo.remark},updaterid=#{itemDo.updaterId} where isvalid=1 and remark is null and channel_id=#{itemDo.channelId}
  346. <if test="itemDo.fundId != null and itemDo.fundId !=''">
  347. and fund_id=#{itemDo.fundId}
  348. </if>
  349. <if test="itemDo.deletionType != null and itemDo.deletionType !=''">
  350. and deletion_type=#{itemDo.deletionType}
  351. </if>
  352. <if test="itemDo.deletionDate != null and itemDo.deletionDate !=''">
  353. and deletion_date=#{itemDo.deletionDate}
  354. </if>
  355. </foreach>
  356. </update>
  357. </mapper>