SysDeptAccountMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.ydtech.modules.admin.dao.SysDeptAccountMapper">
  4. <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.dto.SysDeptAccountDto">
  5. <id column="dept_id" jdbcType="VARCHAR" property="deptId"/>
  6. <result column="name" jdbcType="VARCHAR" property="deptName"/>
  7. <result column="management_fee" jdbcType="DECIMAL" property="managementFee"/>
  8. <result column="create_date" jdbcType="TIMESTAMP" property="createTime"/>
  9. <result column="waitAmount" jdbcType="DECIMAL" property="waitAmount"/>
  10. <result column="totalAmount" jdbcType="DECIMAL" property="totalAmount"/>
  11. </resultMap>
  12. <select id="getDept" resultMap="BaseResultMap">
  13. SELECT
  14. a.dept_id,
  15. any_value(b.name) as name,
  16. a.management_fee,
  17. DATE(a.create_time) as create_date,
  18. SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
  19. SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
  20. FROM
  21. sys_dept_account a
  22. LEFT JOIN sys_dept b ON a.dept_id = b.id
  23. LEFT JOIN sys_dept_account_withdraw c on a.dept_id = c.dept_id
  24. where
  25. b.del_flag = 0
  26. <if test="sysDeptAccountDto.deptId != null and sysDeptAccountDto.deptId != ''">
  27. AND a.dept_id like concat(#{sysDeptAccountDto.deptId},'%')
  28. </if>
  29. <if test="sysDeptAccountDto.deptName != null and sysDeptAccountDto.deptName != ''">
  30. AND b.name like concat(#{sysDeptAccountDto.deptName},'%')
  31. </if>
  32. group by a.dept_id
  33. </select>
  34. <resultMap id="SysAccountByUserMap" type="com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo">
  35. <id column="id" jdbcType="VARCHAR" property="deptId"/>
  36. <result column="name" jdbcType="VARCHAR" property="deptName"/>
  37. <result column="comLevel" jdbcType="VARCHAR" property="comLevel"/>
  38. <result column="comattribute" jdbcType="VARCHAR" property="comattribute"/>
  39. <result column="comtype" jdbcType="VARCHAR" property="comtype"/>
  40. <result column="management_fee" jdbcType="DECIMAL" property="managementFee"/>
  41. <result column="withdraw_user" jdbcType="VARCHAR" property="userId"/>
  42. </resultMap>
  43. <select id="getDeptAccountByUser" resultMap="SysAccountByUserMap">
  44. SELECT
  45. a.id,
  46. a.name,
  47. a.comlevel,
  48. a.comattribute,
  49. a.comtype,
  50. b.management_fee,
  51. a.withdraw_user,
  52. SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
  53. SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
  54. FROM
  55. sys_dept a
  56. RIGHT JOIN sys_dept_account b ON a.id = b.dept_id
  57. LEFT JOIN sys_dept_account_withdraw c on a.id = c.dept_id
  58. where
  59. a.del_flag = 0
  60. <if test="userId != null and userId != ''">
  61. AND a.withdraw_user = #{userId}
  62. </if>
  63. group by a.id
  64. </select>
  65. <select id="getDeptAccountByDept" resultMap="SysAccountByUserMap">
  66. SELECT
  67. a.id,
  68. a.name,
  69. a.comlevel,
  70. a.comattribute,
  71. a.comtype,
  72. b.management_fee,
  73. a.withdraw_user
  74. FROM
  75. sys_dept a
  76. RIGHT JOIN sys_dept_account b ON a.id = b.dept_id
  77. where
  78. a.del_flag = 0
  79. <if test="deptId != null and deptId != ''">
  80. AND a.id = #{deptId}
  81. </if>
  82. </select>
  83. </mapper>