罗元桥
2021-08-05 cc1098fc00a50cb1591d182f04bc37066ff0a9e2
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
<?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.panzhihua.service_community.dao.ComActUserWalletTradeMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActUserWalletTradeDO">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="community_id" property="communityId" />
        <result column="service_id" property="serviceId" />
        <result column="amount" property="amount" />
        <result column="type" property="type" />
        <result column="remark" property="remark" />
        <result column="create_at" property="createAt" />
        <result column="create_by" property="createBy" />
        <result column="wallet_id" property="walletId" />
        <result column="change_type" property="changeType" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, community_id, service_id, amount, type, remark, create_at, create_by, wallet_id, change_type
    </sql>
 
    <select id="getUserWalletTradeList" resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeVO"
            parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeDTO">
        SELECT
            cauwt.id,
            ca.`name` AS communityName,
            cauwt.type,
            cauwt.remark,
            cauwt.change_type,
            cauwt.amount,
            cauwt.create_at
        FROM
            com_act_user_wallet_trade AS cauwt
            LEFT JOIN com_act AS ca ON ca.community_id = cauwt.community_id
            where cauwt.community_id = #{walletTradeDTO.communityId}
            and cauwt.user_id = #{walletTradeDTO.userId}
 
            order by cauwt.create_at desc
    </select>
 
    <select id="getUserWalletTradeAdmin" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeAdminVO">
        SELECT
            cauwt.id,
            su.user_id,
            cauwt.amount,
            cauwt.type,
            su.`name` AS userName,
            su.nick_name,
            cauwt.change_type,
            su.phone,
            cauwt.create_at,
            su1.`name` AS operationUserName
        FROM
            com_act_user_wallet_trade AS cauwt
            LEFT JOIN sys_user AS su ON su.user_id = cauwt.user_id
            LEFT JOIN sys_user AS su1 ON su1.user_id = cauwt.create_by
        <where>
            <if test="walletTradeDTO.communityId != null">
                and cauwt.community_id = #{walletTradeDTO.communityId}
            </if>
            <if test="walletTradeDTO.type != null">
                and cauwt.type = #{walletTradeDTO.type}
            </if>
            <if test="walletTradeDTO.name != null and walletTradeDTO.name != &quot;&quot;">
                AND (su.nick_name like concat (#{walletTradeDTO.name},'%') or su.name like concat (#{walletTradeDTO.name},'%'))
            </if>
            <if test="walletTradeDTO.phone != null and walletTradeDTO.phone != &quot;&quot;">
                AND su.phone like concat (#{walletTradeDTO.phone},'%')
            </if>
            <if test="walletTradeDTO.startTime != null and walletTradeDTO.startTime != &quot;&quot;">
                AND cauwt.create_at <![CDATA[>=]]> #{walletTradeDTO.startTime}
            </if>
            <if test="walletTradeDTO.endTime != null and walletTradeDTO.endTime != &quot;&quot;">
                AND cauwt.create_at <![CDATA[<=]]> #{walletTradeDTO.endTime}
            </if>
        </where>
        <if test="walletTradeDTO.sort == null">
            order by cauwt.create_at desc
        </if>
        <if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 1">
            order by cauwt.amount asc
        </if>
        <if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 2">
            order by cauwt.amount desc
        </if>
 
    </select>
 
</mapper>