| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.admin.dao.SysDeptAccountMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.dto.SysDeptAccountDto">
- <id column="dept_id" jdbcType="VARCHAR" property="deptId"/>
- <result column="name" jdbcType="VARCHAR" property="deptName"/>
- <result column="management_fee" jdbcType="DECIMAL" property="managementFee"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="waitAmount" jdbcType="DECIMAL" property="waitAmount"/>
- <result column="totalAmount" jdbcType="DECIMAL" property="totalAmount"/>
- </resultMap>
- <select id="getDept" resultMap="BaseResultMap">
- SELECT
- a.dept_id,
- b.NAME,
- a.management_fee,
- DATE(a.create_time) as create_date,
- SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
- SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
- FROM
- sys_dept_account a
- LEFT JOIN sys_dept b ON a.dept_id = b.id
- LEFT JOIN sys_dept_account_withdraw c on a.dept_id = c.dept_id
- where
- b.del_flag = 0
- <if test="sysDeptAccountDto.deptId != null and sysDeptAccountDto.deptId != ''">
- AND a.dept_id like concat(#{sysDeptAccountDto.deptId},'%')
- </if>
- <if test="sysDeptAccountDto.deptName != null and sysDeptAccountDto.deptName != ''">
- AND b.name like concat(#{sysDeptAccountDto.deptName},'%')
- </if>
- group by a.dept_id
- </select>
- <resultMap id="SysAccountByUserMap" type="com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo">
- <id column="id" jdbcType="VARCHAR" property="deptId"/>
- <result column="name" jdbcType="VARCHAR" property="deptName"/>
- <result column="comLevel" jdbcType="VARCHAR" property="comLevel"/>
- <result column="comattribute" jdbcType="VARCHAR" property="comattribute"/>
- <result column="comtype" jdbcType="VARCHAR" property="comtype"/>
- <result column="management_fee" jdbcType="DECIMAL" property="managementFee"/>
- <result column="withdraw_user" jdbcType="VARCHAR" property="userId"/>
- </resultMap>
- <select id="getDeptAccountByUser" resultMap="SysAccountByUserMap">
- SELECT
- a.id,
- a.name,
- a.comlevel,
- a.comattribute,
- a.comtype,
- b.management_fee,
- a.withdraw_user,
- SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
- SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
- FROM
- sys_dept a
- RIGHT JOIN sys_dept_account b ON a.id = b.dept_id
- LEFT JOIN sys_dept_account_withdraw c on a.id = c.dept_id
- where
- a.del_flag = 0
- <if test="userId != null and userId != ''">
- AND a.withdraw_user = #{userId}
- </if>
- group by a.id
- </select>
- <select id="getDeptAccountByDept" resultMap="SysAccountByUserMap">
- SELECT
- a.id,
- a.name,
- a.comlevel,
- a.comattribute,
- a.comtype,
- b.management_fee,
- a.withdraw_user
- FROM
- sys_dept a
- RIGHT JOIN sys_dept_account b ON a.id = b.dept_id
- where
- a.del_flag = 0
- <if test="deptId != null and deptId != ''">
- AND a.id = #{deptId}
- </if>
- </select>
- </mapper>
|