yujian
2019-12-19 626d711cb15896055c13fe344eb7fcc824589715
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?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.yeshi.fanli.dao.mybatis.UserInfoCountMapper">
 
    <resultMap id="UserGoldCoinMapVO" type="com.yeshi.fanli.vo.user.UserGoldCoinVO">
        <result column="id" property="uid" jdbcType="BIGINT" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="portrait" property="portrait" jdbcType="VARCHAR" />
        <result column="goldCoin" property="goldCoin"    jdbcType="INTEGER" />
    </resultMap>
    
    
    <select id="listByUserGoldCoin" resultMap="UserGoldCoinMapVO">
        SELECT IFNULL(SUM(d.`td_money`),0) AS goldCoin,u.`id`,u.`nick_name`,u.`portrait`
        FROM `yeshi_ec_integral_detail` d
        LEFT JOIN `yeshi_ec_user` u ON u.`id` = d.`td_uid`
        WHERE 1=1 
              <if test="type == 1">AND d.`td_money`<![CDATA[>]]> 0</if>
              <if test="type == 2">AND d.`td_money`<![CDATA[<]]> 0</if>
              <if test="key != null and key !='' ">AND d.`td_uid`LIKE '%${key}%'</if>
        GROUP BY d.`td_uid`
        ORDER BY goldCoin <if test="type == 1">DESC</if>
        LIMIT #{start},#{count}
    </select>
 
 
    <select id="countByUserGoldCoin" resultType="Long">
        SELECT IFNULL(COUNT(DISTINCT d.`td_uid`),0) FROM `yeshi_ec_integral_detail` d
        WHERE 1=1 
              <if test="type == 1">AND d.`td_money`<![CDATA[>]]> 0</if>
              <if test="type == 2">AND d.`td_money`<![CDATA[<]]> 0</if>
              <if test="key != null and key !='' ">AND d.`td_uid` LIKE '%${key}%'</if>
    </select>
    
    <select id="listByHasGoldCoin" resultMap="UserGoldCoinMapVO">
        SELECT IFNULL(t.`uie_gold_coin`,0) AS goldCoin,u.`id`,u.`nick_name`,u.`portrait`
        FROM `yeshi_ec_user_info_extra` t
        LEFT JOIN `yeshi_ec_user` u ON t.`uie_uid` = u.`id`
        WHERE 1=1 <if test="key != null and key !='' ">AND t.`uie_uid`LIKE '%${key}%'</if>
        ORDER BY t.`uie_gold_coin` DESC
        LIMIT #{start},#{count}
    </select>
 
    <select id="countByHasGoldCoin" resultType="Long">
        SELECT IFNULL(COUNT(t.`uie_id`),0)FROM `yeshi_ec_user_info_extra` t
        WHERE 1=1 <if test="key != null and key !='' ">AND t.`uie_uid`LIKE '%${key}%'</if>
    </select>
    
</mapper>