TAppAssetMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.bussiness.mapper.TAppAssetMapper">
  6. <resultMap type="com.ruoyi.bussiness.domain.TAppAsset" id="TAppAssetResult">
  7. <result property="userId" column="user_id" />
  8. <result property="adress" column="adress" />
  9. <result property="symbol" column="symbol" />
  10. <result property="amout" column="amout" />
  11. <result property="occupiedAmount" column="occupied_amount" />
  12. <result property="availableAmount" column="available_amount" />
  13. <result property="type" column="type" />
  14. <result property="createBy" column="create_by" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateBy" column="update_by" />
  17. <result property="updateTime" column="update_time" />
  18. <result property="remark" column="remark" />
  19. <result property="searchValue" column="search_value" />
  20. </resultMap>
  21. <sql id="selectTAppAssetVo">
  22. select user_id, adress, symbol, amout, occupied_amount, available_amount, type, create_by, create_time, update_by, update_time, remark, search_value from t_app_asset
  23. </sql>
  24. <select id="selectTAppAssetList" parameterType="TAppAsset" resultMap="TAppAssetResult">
  25. select t.user_id, t.adress, t.symbol, t.amout,
  26. t.occupied_amount, t.available_amount, t.type, t.create_by, t.create_time, t.update_by, t.update_time,
  27. t.remark, t.search_value
  28. from t_app_asset t
  29. left join t_app_user u on t.user_id=u.user_id
  30. <where>
  31. <if test="adminParentIds != null and adminParentIds!=''">
  32. AND find_in_set(#{adminParentIds},u.admin_parent_ids)
  33. </if>
  34. <if test="userId != null"> and t.user_id = #{userId}</if>
  35. <if test="symbol != null"> and t.symbol = #{symbol}</if>
  36. <if test="adress != null and adress != ''"> and t.adress = #{adress}</if>
  37. <if test="amout != null "> and t.amout = #{amout}</if>
  38. <if test="type != null "> and t.type = #{type}</if>
  39. <if test="occupiedAmount != null "> and t.occupied_amount = #{occupiedAmount}</if>
  40. <if test="availableAmount != null "> and t.available_amount = #{availableAmount}</if>
  41. <if test="searchValue != null and searchValue != ''"> and t.search_value = #{searchValue}</if>
  42. <if test="params!=null and params!=''">
  43. <if test="params.amountMin!=null">
  44. and t.amout <![CDATA[ >= ]]> #{params.amountMin}
  45. </if>
  46. <if test="params.amountMax!=null">
  47. and t.amout <![CDATA[ <= ]]> #{params.amountMax}
  48. </if>
  49. <if test="params.occupiedAmountMin!=null">
  50. and t.occupied_amount <![CDATA[ >= ]]> #{params.occupiedAmountMin}
  51. </if>
  52. <if test="params.occupiedAmountMax!=null">
  53. and t.occupied_amount <![CDATA[ <= ]]> #{params.occupiedAmountMax}
  54. </if>
  55. <if test="params.availableAmountMin!=null">
  56. and t.available_amount <![CDATA[ >= ]]> #{params.availableAmountMin}
  57. </if>
  58. <if test="params.availableAmountMax!=null">
  59. and t.available_amount <![CDATA[ <= ]]> #{params.availableAmountMax}
  60. </if>
  61. <if test="params.startTime!=null">
  62. and t.create_time <![CDATA[ >= ]]> #{params.startTime}
  63. </if>
  64. <if test="params.endTime!=null">
  65. and t.create_time <![CDATA[ <= ]]> #{params.endTime}
  66. </if>
  67. </if>
  68. </where>
  69. order by t.create_time desc
  70. </select>
  71. <select id="selectTAppAssetByUserId" parameterType="Long" resultMap="TAppAssetResult">
  72. <include refid="selectTAppAssetVo"/>
  73. where user_id = #{userId}
  74. </select>
  75. <insert id="insertTAppAsset" parameterType="TAppAsset">
  76. insert into t_app_asset
  77. <trim prefix="(" suffix=")" suffixOverrides=",">
  78. <if test="userId != null">user_id,</if>
  79. <if test="adress != null">adress,</if>
  80. <if test="symbol != null">symbol,</if>
  81. <if test="amout != null">amout,</if>
  82. <if test="occupiedAmount != null">occupied_amount,</if>
  83. <if test="availableAmount != null">available_amount,</if>
  84. <if test="type != null">type,</if>
  85. <if test="createBy != null">create_by,</if>
  86. <if test="createTime != null">create_time,</if>
  87. <if test="updateBy != null">update_by,</if>
  88. <if test="updateTime != null">update_time,</if>
  89. <if test="remark != null">remark,</if>
  90. <if test="searchValue != null">search_value,</if>
  91. </trim>
  92. <trim prefix="values (" suffix=")" suffixOverrides=",">
  93. <if test="userId != null">#{userId},</if>
  94. <if test="adress != null">#{adress},</if>
  95. <if test="symbol != null">#{symbol},</if>
  96. <if test="amout != null">#{amout},</if>
  97. <if test="occupiedAmount != null">#{occupiedAmount},</if>
  98. <if test="availableAmount != null">#{availableAmount},</if>
  99. <if test="type != null">#{type},</if>
  100. <if test="createBy != null">#{createBy},</if>
  101. <if test="createTime != null">#{createTime},</if>
  102. <if test="updateBy != null">#{updateBy},</if>
  103. <if test="updateTime != null">#{updateTime},</if>
  104. <if test="remark != null">#{remark},</if>
  105. <if test="searchValue != null">#{searchValue},</if>
  106. </trim>
  107. </insert>
  108. <update id="updateTAppAsset" parameterType="TAppAsset">
  109. update t_app_asset
  110. <trim prefix="SET" suffixOverrides=",">
  111. <if test="adress != null">adress = #{adress},</if>
  112. <if test="amout != null">amout = #{amout},</if>
  113. <if test="occupiedAmount != null">occupied_amount = #{occupiedAmount},</if>
  114. <if test="availableAmount != null">available_amount = #{availableAmount},</if>
  115. <if test="createBy != null">create_by = #{createBy},</if>
  116. <if test="createTime != null">create_time = #{createTime},</if>
  117. <if test="updateBy != null">update_by = #{updateBy},</if>
  118. <if test="updateTime != null">update_time = #{updateTime},</if>
  119. <if test="remark != null">remark = #{remark},</if>
  120. <if test="searchValue != null">search_value = #{searchValue},</if>
  121. </trim>
  122. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  123. </update>
  124. <update id="updateByUserId" parameterType="com.ruoyi.bussiness.domain.TAppAsset">
  125. update t_app_asset
  126. <set>
  127. <if test="amout != null ">
  128. amout = #{amout},
  129. </if>
  130. <if test="occupiedAmount != null ">
  131. occupied_amount=#{occupiedAmount},
  132. </if>
  133. <if test="availableAmount != null ">
  134. available_amount=#{availableAmount},
  135. </if>
  136. update_time = now()
  137. </set>
  138. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  139. </update>
  140. <delete id="deleteTAppAssetByUserId" parameterType="Long">
  141. delete from t_app_asset where user_id = #{userId}
  142. </delete>
  143. <delete id="deleteTAppAssetByUserIds" parameterType="String">
  144. delete from t_app_asset where user_id in
  145. <foreach item="userId" collection="array" open="(" separator="," close=")">
  146. #{userId}
  147. </foreach>
  148. </delete>
  149. <update id="noSettlementAssetByUserId" parameterType="java.util.Map">
  150. update t_app_asset
  151. <set>
  152. available_amount = available_amount - #{money},
  153. occupied_amount= occupied_amount + #{money},
  154. update_time = now()
  155. </set>
  156. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  157. </update>
  158. <update id="reduceAssetByUserId" parameterType="java.util.Map">
  159. update t_app_asset
  160. <set>
  161. amout = amout - #{money},
  162. available_amount=available_amount-#{money},
  163. update_time = now()
  164. </set>
  165. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  166. </update>
  167. <update id="addAssetByUserId" parameterType="java.util.Map">
  168. update t_app_asset
  169. <set>
  170. amout = amout + #{money},
  171. available_amount=available_amount + #{money},
  172. update_time = now()
  173. </set>
  174. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  175. </update>
  176. <update id="occupiedAssetByUserId" parameterType="java.util.Map">
  177. update t_app_asset
  178. <set>
  179. available_amount = available_amount - #{money},
  180. occupied_amount= occupied_amount + #{money},
  181. update_time = now()
  182. </set>
  183. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  184. </update>
  185. <update id="settlementOccupiedCurrencyOrder"
  186. parameterType="java.util.Map">
  187. update t_app_asset
  188. <set>
  189. amout = amout - #{money},
  190. occupied_amount= occupied_amount - #{subtract},
  191. available_amount= available_amount +#{availableAmount},
  192. update_time = now()
  193. </set>
  194. where user_id = #{userId} and symbol =#{symbol} and type=#{type}
  195. </update>
  196. </mapper>