You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.7 KiB

<?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.charge.task.dao.LabelDOMapper" >
<resultMap id="BaseResultMap" type="com.charge.task.model.LabelDO" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="TINYINT" />
<result column="memo" property="memo" jdbcType="VARCHAR" />
<result column="user_type" property="userType" jdbcType="TINYINT" />
<result column="user_count" property="userCount" jdbcType="INTEGER" />
<result column="company_count" property="companyCount" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="TINYINT" />
<result column="operator_name" property="operatorName" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="config_json" property="configJson" jdbcType="LONGVARCHAR" />
</resultMap>
<resultMap id="LabelUserDTOMap" type="com.charge.task.dto.LabelUserDTO">
<id column="userId" property="userId" jdbcType="BIGINT"/>
<result column="chargeDegree" property="chargeDegree" jdbcType="DECIMAL"/>
<result column="userType" property="userType" jdbcType="VARCHAR"/>
</resultMap>
<select id="getLabelByType" resultMap="BaseResultMap">
select * from t_label where state = 1 and type = #{type}
</select>
<select id="getLabelUserCountCompany" resultType="java.lang.Integer">
select count(u.id) from t_user u
left join t_label_relation re on u.user_owner_id = re.subordinate_id
where u.state &lt;&gt; '2' and u.user_type = '3' and re.label_id = #{id}
</select>
<select id="getLabelUserList" resultMap="LabelUserDTOMap">
select u.id as userId,
chargeTable.chargeDgree as chargeDegree,
u.user_type as userType
from t_user u left join (
SELECT
eco.user_id AS id,
IFNULL( ROUND( sum( charge_degree ), 2 ), 0 ) AS chargeDgree
FROM
t_equipment_charge_order eco
WHERE
eco.state = 3
GROUP BY
eco.user_id
UNION
SELECT
id AS id,
0 AS chargeDgree
FROM
t_user
where id not in (select DISTINCT( `user_id`) from `t_equipment_charge_order` WHERE state = 3)
) AS chargeTable ON chargeTable.id = u.id
where u.state &lt;&gt; '2'
<if test='userType != null and userType != "" and userType != "0"'>
and u.user_type = #{userType}
</if>
<if test='degreeStartType != null and degreeStartType == 1'>
and chargeTable.chargeDgree &gt; #{degreeStart}
</if>
<if test='degreeStartType != null and degreeStartType == 2'>
and chargeTable.chargeDgree &gt;= #{degreeStart}
</if>
<if test='degreeEndType != null and degreeEndType == 1'>
and chargeTable.chargeDgree &lt; #{degreeEnd}
</if>
<if test='degreeEndType != null and degreeEndType == 2'>
and chargeTable.chargeDgree &lt;= #{degreeEnd}
</if>
<if test='registerStartType != null and registerStartType == 1'>
and u.reg_time &gt; #{registerStart}
</if>
<if test='registerStartType != null and registerStartType == 2'>
and u.reg_time &gt;= #{registerStart}
</if>
<if test='registerEndType != null and registerEndType == 1'>
and u.reg_time &lt; #{registerEnd}
</if>
<if test='registerEndType != null and registerEndType == 2'>
and u.reg_time &lt;= #{registerEnd}
</if>
</select>
</mapper>