Pu Zhibing
2025-04-22 fd7b8fb7c89832c28a838b0449bbb8a392433ee2
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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.ruoyi.account.mapper.UserPointMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.UserPoint">
        <id column="id" property="id" />
        <result column="type" property="type" />
        <result column="change_direction" property="changeDirection" />
        <result column="variable_point" property="variablePoint" />
        <result column="create_time" property="createTime" />
        <result column="app_user_id" property="appUserId" />
        <result column="object_id" property="objectId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, type, historical_point, variable_point, create_time, app_user_id, object_id
    </sql>
 
    <sql id="userPointList">
        SELECT
        tau.`name` userName,
        tau.phone,
        tup.type,
        tup.create_time,
        tup.variable_point,
        tup.change_direction
        FROM
        (select * from t_user_point union all select * from t_user_point_copy) tup
        LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id
        <where>
            tup.type not in (8, 9, 14) and tau.status != 3 and tau.del_flag = 0
            <if test="userPoint.appUserId != null and userPoint.appUserId != ''">
                AND tup.app_user_id = #{userPoint.appUserId}
            </if>
            <if test="userPoint.userName != null and userPoint.userName != ''">
                AND tau.`name` LIKE concat('%',#{userPoint.userName},'%')
            </if>
            <if test="userPoint.phone != null and userPoint.phone != ''">
                AND tau.phone LIKE concat('%',#{userPoint.phone},'%')
            </if>
            <if test="userPoint.type != null and userPoint.type != ''">
                AND tup.type = #{userPoint.type}
            </if>
            <if test="userPoint.startTime != null and userPoint.endTime != null">
                AND tup.create_time BETWEEN #{userPoint.startTime} AND #{userPoint.endTime}
            </if>
        </where>
        order by tup.create_time desc
    </sql>
 
    <select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint">
        <include refid="userPointList"/>
    </select>
    <select id="selectUserPoint" resultType="com.ruoyi.account.api.model.UserPoint">
        <include refid="userPointList"/>
    </select>
 
    
    
    <select id="getUserPointDetail" resultType="com.ruoyi.account.vo.UserPointDetailVO">
        select * from (
            select
            type,
            historical_point as historicalPoint,
            balance,
            variable_point as variablePoint,
            change_direction as changeDirection,
            DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime,
            transfer_user_id as transferUserId,
            receive_user_id as receiveUserId,
            object_id as objectId
            from t_user_point where app_user_id = #{userId}
            <if test="null != startTime and null != endTime">
                and create_time between #{startTime} and #{endTime}
            </if>
            <if test="null != type">
                and type = #{type}
            </if>
            union all
            select
            type,
            historical_point as historicalPoint,
            balance,
            variable_point as variablePoint,
            change_direction as changeDirection,
            DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime,
            transfer_user_id as transferUserId,
            receive_user_id as receiveUserId,
            object_id as objectId
            from t_user_point_copy where app_user_id = #{userId}
            <if test="null != startTime and null != endTime">
                and create_time between #{startTime} and #{endTime}
            </if>
            <if test="null != type">
                and type = #{type}
            </if>
        ) as a order by a.createTime desc
    </select>
</mapper>