SysUserAccountMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.ydtech.modules.admin.dao.SysUserAccountMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysUserAccount">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <id property="userId" column="user_id" jdbcType="VARCHAR"/>
  9. <result property="handlingFee" column="handling_fee" jdbcType="DECIMAL"/>
  10. <result property="documentary" column="documentary" jdbcType="DECIMAL"/>
  11. <result property="promotion" column="promotion" jdbcType="DECIMAL"/>
  12. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  13. <result property="name" column="name" jdbcType="VARCHAR"/>
  14. <result property="deptId" column="deptId" jdbcType="VARCHAR"/>
  15. <result property="deptName" column="deptName" jdbcType="VARCHAR"/>
  16. <result property="handlingAmountWithdrawal" column="handling_amount_withdrawal" jdbcType="DECIMAL"/>
  17. <result property="handlingAmountAccount" column="handling_amount_account" jdbcType="DECIMAL"/>
  18. <result property="handlingAmountPayment" column="handling_amount_payment" jdbcType="DECIMAL"/>
  19. <result property="documentaryAmountWithdrawal" column="documentary_amount_withdrawal" jdbcType="DECIMAL"/>
  20. <result property="documentaryAmountAccount" column="documentary_amount_account" jdbcType="DECIMAL"/>
  21. <result property="documentaryAmountpayment" column="documentary_amount_payment" jdbcType="DECIMAL"/>
  22. <result property="promotionAmountWithdrawal" column="promotion_amount_withdrawal" jdbcType="DECIMAL"/>
  23. <result property="promotionAmountAccount" column="promotion_amount_account" jdbcType="DECIMAL"/>
  24. <result property="promotionAmountPayment" column="promotion_amount_payment" jdbcType="DECIMAL"/>
  25. <result property="sumAmount" column="sum_amount" jdbcType="DECIMAL"/>
  26. <result property="sumAmountWithdrawal" column="sum_amount_withdrawal" jdbcType="DECIMAL"/>
  27. <result property="sumAmountAccount" column="sum_amount_account" jdbcType="DECIMAL"/>
  28. <result property="sumAmountPayment" column="sum_amount_payment" jdbcType="DECIMAL"/>
  29. <result property="managementSource" column="managementSource" jdbcType="VARCHAR"/>
  30. <result property="roleId" column="roleId" jdbcType="VARCHAR"/>
  31. <!-- <collection property="sysUserAccountCardList" ofType="com.ydtech.modules.admin.model.po.SysUserBankCard"
  32. resultMap="sysUserAccountCardList"/> -->
  33. </resultMap>
  34. <resultMap id="sysUserAccountCardList" type="com.ydtech.modules.admin.model.po.SysUserBankCard">
  35. <id property="id" column="id" jdbcType="VARCHAR"/>
  36. <result property="bankNumber" column="bank_number" jdbcType="VARCHAR"/>
  37. <result property="bankAccount" column="bank_account" jdbcType="VARCHAR"/>
  38. <result property="bankAddress" column="bank_address" jdbcType="VARCHAR"/>
  39. <result property="realUserName" column="real_user_name" jdbcType="VARCHAR"/>
  40. <result property="auditStatus" column="audit_status" jdbcType="VARCHAR"/>
  41. <result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
  42. </resultMap>
  43. <sql id="Base_Column_List">
  44. user_id,handling_fee,documentary,
  45. promotion,create_time
  46. </sql>
  47. <select id="queryPageOrder" resultType="com.ydtech.modules.admin.model.po.SysUserAccount">
  48. select
  49. a.user_id as "userId",
  50. a.handling_fee as "handlingFee",
  51. a.documentary as "documentary",
  52. a.promotion as "promotion",
  53. a.create_time as "createTime",
  54. a.handling_amount_withdrawal as "handlingAmountWithdrawal",
  55. a.handling_amount_account as "handlingAmountAccount",
  56. a.handling_amount_payment as "handlingAmountPayment",
  57. a.documentary_amount_withdrawal as "documentaryAmountWithdrawal",
  58. a.documentary_amount_account as "documentaryAmountAccount",
  59. a.documentary_amount_payment as "documentaryAmountPayment",
  60. a.promotion_amount_withdrawal as "promotionAmountWithdrawal",
  61. a.promotion_amount_account as "promotionAmountAccount",
  62. a.promotion_amount_payment as "promotionAmountPayment",
  63. b.dept_id as "deptId",
  64. b.name as "name",
  65. sd.name as "deptName"
  66. from
  67. sys_user_account a
  68. left join sys_user b on a.user_id = b.id
  69. left join sys_dept sd on sd.id =b.dept_id
  70. <where>
  71. <if test="sysUserAccountVo.userId != null and sysUserAccountVo.userId != ''">
  72. and a.user_id = #{sysUserAccountVo.userId}
  73. </if>
  74. <if test="sysUserAccountVo.deptId != null and sysUserAccountVo.deptId != ''">
  75. and b.dept_id like concat(#{sysUserAccountVo.deptId},'%')
  76. </if>
  77. </where>
  78. </select>
  79. <select id="getById" resultType="com.ydtech.modules.admin.model.po.SysUserAccount">
  80. select
  81. a.user_id as "userId",
  82. a.handling_fee as "handlingFee",
  83. a.documentary as "documentary",
  84. a.promotion as "promotion",
  85. a.create_time as "createTime",
  86. a.handling_amount_withdrawal as "handlingAmountWithdrawal",
  87. a.handling_amount_account as "handlingAmountAccount",
  88. a.handling_amount_payment as "handlingAmountPayment",
  89. a.documentary_amount_withdrawal as "documentaryAmountWithdrawal",
  90. a.documentary_amount_account as "documentaryAmountAccount",
  91. a.documentary_amount_payment as "documentaryAmountPayment",
  92. a.promotion_amount_withdrawal as "promotionAmountWithdrawal",
  93. a.promotion_amount_account as "promotionAmountAccount",
  94. a.promotion_amount_payment as "promotionAmountPayment",
  95. ifnull(a.sum_amount,0) as "sumAmount",
  96. ifnull(a.sum_amount_withdrawal,0) as "sumAmountWithdrawal",
  97. ifnull(a.sum_amount_account,0) as "sumAmountAccount",
  98. ifnull(a.sum_amount_payment,0) as "sumAmountPayment"
  99. from sys_user_account a
  100. <where>
  101. <if test="userId != null and userId != ''">
  102. and a.user_id = #{userId}
  103. </if>
  104. </where>
  105. </select>
  106. <select id="queryPageOrder1" resultMap="BaseResultMap">
  107. select
  108. a.user_id as id,
  109. a.user_id,
  110. a.handling_fee,
  111. a.documentary,
  112. a.promotion,
  113. a.create_time,
  114. a.handling_amount_withdrawal,
  115. a.handling_amount_account,
  116. a.handling_amount_payment,
  117. a.documentary_amount_withdrawal,
  118. a.documentary_amount_account,
  119. a.documentary_amount_payment,
  120. a.promotion_amount_withdrawal,
  121. a.promotion_amount_account,
  122. a.promotion_amount_payment,
  123. b.dept_id as deptId,
  124. b.name as name,
  125. sd.name as deptName,
  126. a.sum_amount,
  127. a.sum_amount_withdrawal,
  128. a.sum_amount_account,
  129. a.sum_amount_payment,
  130. sd.management_source as managementSource,
  131. role.role_id as roleId
  132. from
  133. sys_user_account a
  134. left join sys_user b on a.user_id = b.id
  135. left join sys_dept sd on sd.id = b.dept_id
  136. left join sys_user_role role on role.user_id = a.user_id
  137. <where>
  138. <if test="sysUserAccountVo.userId != null and sysUserAccountVo.userId != ''">
  139. and a.user_id = #{sysUserAccountVo.userId}
  140. </if>
  141. <if test="sysUserAccountVo.name != null and sysUserAccountVo.name != ''">
  142. and b.name = #{sysUserAccountVo.name}
  143. </if>
  144. <if test="sysUserAccountVo.deptId != null and sysUserAccountVo.deptId != ''">
  145. and b.dept_id like concat(#{sysUserAccountVo.deptId}, '%')
  146. </if>
  147. <if test="sysUserAccountVo.userName != null and sysUserAccountVo.userName != ''">
  148. and b.name = #{sysUserAccountVo.userName}
  149. </if>
  150. <if test="sysUserAccountVo.bankNumber != null and sysUserAccountVo.bankNumber != ''">
  151. and c.bank_number = #{sysUserAccountVo.bankNumber}
  152. </if>
  153. </where>
  154. </select>
  155. <select id="getGroupById" resultType="java.math.BigDecimal">
  156. select sum(sum_amount) from sys_user_account WHERE user_id in (
  157. select id from sys_user where manager_id = #{userId} or id = #{userId}
  158. )
  159. </select>
  160. <select id="queryCount" resultMap="BaseResultMap">
  161. select
  162. a.user_id,
  163. a.handling_fee,
  164. a.documentary,
  165. a.promotion,
  166. a.create_time,
  167. a.handling_amount_withdrawal,
  168. a.handling_amount_account,
  169. a.handling_amount_payment,
  170. a.documentary_amount_withdrawal,
  171. a.documentary_amount_account,
  172. a.documentary_amount_payment,
  173. a.promotion_amount_withdrawal,
  174. a.promotion_amount_account,
  175. a.promotion_amount_payment,
  176. b.dept_id as deptId,
  177. b.name as name,
  178. sd.name as deptName,
  179. sd.management_source as managementSource,
  180. role.role_id as roleId
  181. from
  182. sys_user_account a
  183. left join sys_user b on a.user_id = b.id
  184. left join sys_dept sd on sd.id = b.dept_id
  185. left join sys_user_role role on role.user_id = a.user_id
  186. <where>
  187. a.user_id not in (
  188. SELECT
  189. su.id AS userId
  190. FROM
  191. sys_user su
  192. LEFT JOIN sys_user_info info ON info.id = su.id
  193. LEFT JOIN sys_dept sd ON su.dept_id = sd.id
  194. LEFT JOIN sys_dept psd ON psd.id = sd.parent_id
  195. LEFT JOIN sys_user_role t3 ON su.id = t3.user_id
  196. LEFT JOIN sys_role t4 ON t3.role_id = t4.id
  197. AND sd.del_flag = '0'
  198. WHERE
  199. su.dept_id LIKE concat( '%', '99', '%' )
  200. AND t3.role_id IN ( 3 )
  201. AND sd.management_source = 3
  202. ORDER BY
  203. su.create_time DESC
  204. )
  205. </where>
  206. </select>
  207. <select id="queryCardListByUserId" resultMap="sysUserAccountCardList">
  208. select
  209. c.id,
  210. c.bank_number,
  211. c.bank_account,
  212. c.bank_address,
  213. c.del_flag,
  214. c.audit_status,
  215. c.real_user_name
  216. from
  217. sys_user_bank_card c
  218. where c.user_id =#{userId}
  219. </select>
  220. </mapper>