无关风月
2024-08-20 9f88b12d16c83963dad8fb8f79d9eeba2c311518
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
<?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.stylefeng.guns.modular.system.dao.InviteMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Invite">
        <id column="id" property="id" />
 
        <result column="userId" property="userId" />
 
        <result column="insertTime" property="insertTime" />
 
        <result column="amount" property="amount" />
 
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, code, orderNumber, userId, payTime, insetTime, payType, amount, couponId, realMoney, packageId
    </sql>
    <select id="findTeam" resultType="com.stylefeng.guns.modular.system.vo.TeamVO">
        SELECT t1.userId as id, SUM(t1.amount) AS amount,t2.name as name,t2.phone as phone
        FROM t_invite t1
        left join t_user t2 on t1.userId = t2.id
        where t1.giftUserId = #{req.id} and t1.type= 2
        <if test="req.startTime!=null and req.endTime != null">
            and (t1.insertTime BETWEEN #{req.startTime} and #{req.endTime} )
        </if>
        GROUP BY t1.userId
        order by amount desc
 
    </select>
    <select id="list" resultType="com.stylefeng.guns.modular.system.vo.CSVO">
        select SUM(t1.amount) AS amount,t2.name as userName
        from t_invite t1
        left join t_user t2 on t1.giftUserId = t2.id
        <where>
        <if test="startTime!=null and endTime != null">
            and (t1.insertTime BETWEEN #{startTime} and #{endTime} )
        </if>
        </where>
        group by t1.giftUserId
        ORDER BY amount desc
    </select>
 
</mapper>