DeletionInfoMapper.xml 19 KB

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