xiaoyong931011
2021-04-23 d4488a987cccd3ddd51a202a9f8aa71d3cdcbced
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
102
103
104
105
106
107
108
<?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.xcong.excoin.modules.agent.mapper.MemberMapper">
 
 
    <select id="selectMemberListInPage" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
        select
            a.*,
            CONCAT(e.first_name, e.second_name) account,
            b.total_balance contractTotal,
            c.available_balance coinTotal,
            d.total_balance agentTotal
        from member a
        left join (select member_id, sum(total_balance) total_balance from member_wallet_contract group by member_id) b on a.id=b.member_id
        left join member_wallet_coin c on a.id=c.member_id and c.wallet_code='USDT'
        left join member_wallet_agent d on a.id=d.member_id
        left join member_authentication e on a.id=e.member_id
        <where>
            <if test="record != null">
                <if test="record.inviteId !=null and record.inviteId!=''">
                    and find_in_set(#{record.inviteId}, a.referer_ids)
                </if>
                <if test="record.startTime!=null">
                    and a.create_time >=#{record.startTime}
                </if>
                <if test="record.endTime!=null">
                    and #{record.endTime} >= a.create_time
                </if>
                <if test="record.account!=null and record.account!=''">
                    and (a.phone = #{record.account} or a.email = #{record.account} or a.invite_id=#{record.account})
                </if>
                <if test="record.accountStatus!=null and record.accountStatus!=''  or record.accountStatus == 0" >
                    and a.account_status = #{record.accountStatus}
                </if>
                <if test="record.accountType != null">
                    and a.account_type = #{record.accountType}
                </if>
                <if test="record.certifyStatus != null">
                    and a.certify_status = #{record.certifyStatus}
                </if>
            </if>
        </where>
        order by create_time desc
    </select>
 
 
    <select id="selectMemberByInviteIdAndRefererId" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
        select * from member
        where invite_id=#{inviteId} and referer_id=#{refererId}
    </select>
 
    <select id="selectMemberFeeAmountTotal" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
        select
            a.create_time,
            a.phone,
            a.email,
            a.referer_id,
            a.invite_id,
            concat(c.first_name, c.second_name) account,
            b.openFeeAmount openFeeAmount,
            d.holdAmount closeFeeAmount,
            d.closingFeeAmount holdFeeAmount,
            d.rewardAmount loseOrProfit
        from member a
        inner join member_authentication c on a.id=c.member_id
        inner join (select member_id, sum(opening_fee_amount) openFeeAmount from contract_order where order_type in (1,2) and order_status=1 group by member_id) b on a.id=b.member_id
        inner join (select
                   member_id,
                   sum(closing_fee_amount) closingFeeAmount,
                   sum(hold_amount) holdAmount,
                   sum(reward_amount) rewardAmount
            from contract_order where order_type in (3,4) and order_status=1 group by member_id) d on a.id=d.member_id
        where find_in_set(#{record.refererIds}, a.referer_ids)
        <if test="record.account!=null and record.account!=''">
            and (a.phone=#{record.account} or a.email=#{record.account} or a.invite_id=#{record.account})
        </if>
        <if test="record.refererId!=null and record.refererId!=''">
            and a.referer_id=#{record.refererId}
        </if>
        group by a.create_time,a.phone, a.email
        order by a.create_time desc
    </select>
 
    <select id="selectMemberAssetsList" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
        select
            CONCAT(e.first_name, e.second_name) account,
            a.phone,
            a.email,
            a.invite_id,
            a.referer_id,
            b.total_balance contractTotal,
            c.available_balance coinTotal,
            d.total_balance agentTotal
        from member a
        left join (select member_id, sum(total_balance) total_balance from member_wallet_contract group by member_id) b on a.id=b.member_id
        left join member_wallet_coin c on a.id=c.member_id and c.wallet_code='USDT'
        left join member_wallet_agent d on a.id=d.member_id
        left join member_authentication e on a.id=e.member_id
        where find_in_set(#{record.refererIds}, a.referer_ids)
        <if test="record.account!=null and record.account!=''">
            and (a.phone=#{record.account} or a.email=#{record.account} or a.invite_id=#{record.account})
        </if>
        <if test="record.refererId!=null and record.refererId!=''">
            and a.referer_id=#{record.refererId}
        </if>
        order by a.create_time desc
    </select>
</mapper>