mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.ComActUserWalletMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActUserWalletDO">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="community_id" property="communityId" />
        <result column="income_amount" property="incomeAmount" />
        <result column="available_amount" property="availableAmount" />
        <result column="settlement_amount" property="settlementAmount" />
        <result column="easy_count" property="easyCount" />
        <result column="create_at" property="createAt" />
        <result column="update_at" property="updateAt" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, community_id, income_amount, available_amount, settlement_amount, easy_count, create_at, update_at
    </sql>
 
    <select id="getCommunityName" resultType="Map">
        SELECT
            ca.`name`,
            sua.content
        FROM
            com_act AS ca
            LEFT JOIN sys_user_agreement AS sua ON sua.community_id = ca.community_id
        WHERE
            ca.community_id = ${communityId} and sua.type = #{type}
    </select>
 
    <select id="getAgreementContent" resultType="Map">
        SELECT
            ca.`name`,
            sua.content
        FROM
            sys_user_agreement AS sua
            LEFT JOIN com_act AS ca ON sua.community_id = ca.community_id
        WHERE
            sua.community_id = ${communityId} and sua.type = #{type}
    </select>
 
    <select id="getWalletRanking" resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletRankingVO">
        SELECT
            su.`name` as userName,
            su.nick_name,
            su.image_url,
            cauw.income_amount,
            (select count(id) from com_act_easy_photo where sponsor_id = cauw.user_id and community_id = ${walletTradeDTO.communityId}) as easyCount
        FROM
            com_act_user_wallet AS cauw
            LEFT JOIN sys_user AS su ON su.user_id = cauw.user_id
            where cauw.community_id = ${walletTradeDTO.communityId}
        ORDER BY
            cauw.income_amount DESC
    </select>
 
    <select id="getUserWalletList" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletAdminVO">
        SELECT
            cauw.id,
            su.user_id,
            su.`name` AS userName,
            su.nick_name,
            su.phone,
            cauw.income_amount,
            cauw.available_amount,
            cauw.settlement_amount
        FROM
            com_act_user_wallet AS cauw
            LEFT JOIN sys_user AS su ON su.user_id = cauw.user_id
        <where>
            <if test="pageWalletAdminDTO.communityId != null">
                AND cauw.community_id = ${pageWalletAdminDTO.communityId}
            </if>
            <if test="pageWalletAdminDTO.name != null and pageWalletAdminDTO.name != &quot;&quot;">
                AND (su.nick_name like concat (#{pageWalletAdminDTO.name},'%') or su.name like concat (#{pageWalletAdminDTO.name},'%'))
            </if>
            <if test="pageWalletAdminDTO.phone != null and pageWalletAdminDTO.phone != &quot;&quot;">
                AND su.phone = #{pageWalletAdminDTO.phone}
            </if>
        </where>
        order by cauw.create_at desc
    </select>
 
    <insert id="insertSysAgreement">
        insert into sys_user_agreement(`type`,content,create_at,`name`,community_id) values (#{type},#{content},now(),#{name},#{communityId})
    </insert>
 
</mapper>