DistributionMapper.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.DistributionMapper">
  4. <resultMap id="BaseMap" type="com.simuwang.base.pojo.dos.DistributionDO">
  5. <id column="id" property="id"/>
  6. <result column="fund_id" property="fundId"/>
  7. <result column="distribute_date" property="distributeDate"/>
  8. <result column="distribute_type" property="distributeType"/>
  9. <result column="distribution" property="distribution"/>
  10. <result column="isvalid" property="isvalid"/>
  11. <result column="creatorid" property="creatorId"/>
  12. <result column="createtime" property="createTime"/>
  13. <result column="updaterid" property="updaterId"/>
  14. <result column="updatetime" property="updateTime"/>
  15. </resultMap>
  16. <resultMap id="BasePageMap" type="com.simuwang.base.pojo.dos.DistributionTablePageDO">
  17. <id column="id" property="id"/>
  18. <result column="fund_name" property="fundName"/>
  19. <result column="company_name" property="companyName"/>
  20. <result column="register_number" property="registerNumber"/>
  21. <result column="fund_id" property="fundId"/>
  22. <result column="distribute_date" property="distributeDate"/>
  23. <result column="distribute_type" property="distributeType"/>
  24. <result column="distribution" property="distribution"/>
  25. <result column="nav" property="nav"/>
  26. <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
  27. <result column="isvalid" property="isvalid"/>
  28. <result column="creatorid" property="creatorId"/>
  29. <result column="createtime" property="createTime"/>
  30. <result column="updaterid" property="updaterId"/>
  31. <result column="updatetime" property="updateTime"/>
  32. </resultMap>
  33. <insert id="saveDistribution" parameterType="com.simuwang.base.pojo.dos.DistributionDO">
  34. insert into distribution(fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid)
  35. values (#{fundId},#{distributeDate},#{distributeType},#{distribution},#{isvalid},#{creatorId},#{createTime},#{updateTime},#{updaterId})
  36. </insert>
  37. <update id="updateDistributionById" parameterType="com.simuwang.base.pojo.dos.DistributionDO">
  38. update distribution set distribute_date=#{distributeDate},distribute_type=#{distributeType},distribution=#{distribution},updatetime=#{updateTime},updaterid=#{updaterId}
  39. where id=#{id} and isvalid =1
  40. </update>
  41. <delete id="deleteDistribution" parameterType="com.simuwang.base.pojo.vo.IdListVO">
  42. update distribution set isvalid =0,updatetime=now(),updaterid=#{updaterId} where isvalid =1 and id in
  43. <foreach item="id" collection="ids" open="(" separator="," close=")">
  44. #{id}
  45. </foreach>
  46. </delete>
  47. <select id="searchDistributionList" resultMap="BasePageMap"
  48. parameterType="com.simuwang.base.pojo.dto.query.DistributionPageQuery">
  49. SELECT DISTINCT
  50. d.id,
  51. d.fund_id,
  52. info.fund_name,
  53. info.register_number,
  54. c.company_name,
  55. d.distribute_date,
  56. d.distribute_type,
  57. d.distribution,
  58. n.nav,
  59. n.cumulative_nav_withdrawal,
  60. d.updatetime,
  61. d.isvalid,
  62. d.creatorid,
  63. d.createtime,
  64. d.updatetime
  65. FROM
  66. distribution d
  67. JOIN pvn_fund_info info
  68. ON d.fund_id = info.fund_id
  69. left JOIN pvn_company_info c
  70. ON info.trust_id = c.company_id AND c.isvalid = 1
  71. JOIN nav n
  72. ON n.fund_id = d.fund_id and d.distribute_date=n.price_date
  73. AND n.isvalid = 1
  74. WHERE d.isvalid = 1
  75. AND info.isvalid = 1
  76. <if test="companyName != null and companyName !=''">
  77. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  78. </if>
  79. <if test="fundName != null and fundName !=''">
  80. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%'))
  81. </if>
  82. <if test="distributeType != null">
  83. and d.distribute_type = #{distributeType}
  84. </if>
  85. <if test="startDate != null and startDate !=''">
  86. and d.distribute_date >= #{startDate}
  87. </if>
  88. <if test="endDate != null and endDate !=''">
  89. and d.distribute_date <![CDATA[ <= ]]> #{endDate}
  90. </if>
  91. <choose>
  92. <when test="sort != null and sort !='' and sort=='distributeDate' and order != null and order !=''">
  93. order by d.distribute_date ${order}
  94. </when>
  95. <otherwise>
  96. order by d.distribute_date desc
  97. </otherwise>
  98. </choose>
  99. limit #{offset},#{pageSize}
  100. </select>
  101. <select id="countDistributionList" resultType="java.lang.Long"
  102. parameterType="com.simuwang.base.pojo.dto.query.DistributionPageQuery">
  103. select count(distinct d.id)
  104. FROM
  105. distribution d
  106. JOIN pvn_fund_info info
  107. ON d.fund_id = info.fund_id
  108. left JOIN pvn_company_info c
  109. ON info.trust_id = c.company_id AND c.isvalid = 1
  110. JOIN nav n
  111. ON n.fund_id = d.fund_id and d.distribute_date=n.price_date
  112. WHERE d.isvalid = 1 AND info.isvalid = 1
  113. AND n.isvalid = 1
  114. <if test="companyName != null and companyName !=''">
  115. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  116. </if>
  117. <if test="fundName != null and fundName !=''">
  118. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%'))
  119. </if>
  120. <if test="distributeType != null">
  121. and d.distribute_type = #{distributeType}
  122. </if>
  123. <if test="startDate != null and startDate !=''">
  124. and d.distribute_date >= #{startDate}
  125. </if>
  126. <if test="endDate != null and endDate !=''">
  127. and d.distribute_date <![CDATA[ <= ]]> #{endDate}
  128. </if>
  129. </select>
  130. <select id="selectDistributionById" resultMap="BaseMap"
  131. parameterType="java.lang.Integer">
  132. select id,fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid
  133. from distribution where isvalid =1 and id=#{id}
  134. </select>
  135. <select id="selectDistributionByDate" resultMap="BaseMap">
  136. select id,fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid
  137. from distribution where isvalid =1 and fund_id=#{fundId} and distribute_date=#{distributeDate}
  138. </select>
  139. <select id="getDistributionByFundId" resultMap="BaseMap">
  140. select id,fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid
  141. from distribution where isvalid =1 and fund_id=#{fundId} and distribute_type=#{distributeType}
  142. </select>
  143. <select id="getSumDistributeByFundId" resultType="java.math.BigDecimal" parameterType="java.lang.String">
  144. select sum(distribution) from distribution where isvalid =1 and fund_id=#{fundId} and distribute_date <![CDATA[ <= ]]> #{distributeDate}
  145. </select>
  146. <select id="countDistributionTotal" resultType="java.lang.Long">
  147. select count(1) from distribution where isvalid =1
  148. </select>
  149. <select id="selectDistributeListByTime" resultMap="BaseMap">
  150. select id,fund_id,distribute_date,distribute_type,distribution,isvalid,creatorid,createtime,updatetime,updaterid
  151. from distribution where updatetime <![CDATA[ <= ]]> #{endDate}
  152. <if test="startDate != null and startDate !=''">
  153. and updatetime >= #{startDate}
  154. </if>
  155. order by updatetime desc
  156. </select>
  157. </mapper>