xiaoyong931011
2021-07-21 1d03a9e224dc0ce11d47bede74da9db2189d663c
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?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.xzx.gc.user.mapper.PartnerAccountLogMapper">
  <resultMap id="BaseResultMap" type="com.xzx.gc.entity.PartnerAccountLog">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="account_id" jdbcType="VARCHAR" property="accountId" />
    <result column="flow_no" jdbcType="VARCHAR" property="flowNo" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="money" jdbcType="VARCHAR" property="money" />
    <result column="account_money" jdbcType="VARCHAR" property="accountMoney" />
    <result column="hbb" jdbcType="VARCHAR" property="hbb" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
    <result column="role_name" jdbcType="VARCHAR" property="roleName" />
    <result column="approver" jdbcType="VARCHAR" property="approver" />
    <result column="approver_time" jdbcType="VARCHAR" property="approverTime" />
    <result column="approver_status" jdbcType="VARCHAR" property="approverStatus" />
    <result column="del_flag"  property="delFlag" />
    <result column="update_time" jdbcType="VARCHAR" property="updateTime" />
  </resultMap>
 
  <update id="updateParterAccountLog" parameterType="com.xzx.gc.model.admin.PartnerAccountLogModel">
    update xzx_partner_account_log set approver=#{approver} ,approver_time=#{approverTime},
    approver_status=#{approverStatus}, update_time=#{updateTime}
    <if test="hbb!= null and hbb!=''">
      , hbb = #{hbb}
    </if>
    <if test="accountMoney!= null and accountMoney!=''">
      , account_money=#{accountMoney}
    </if>
    where flow_no=#{flowNo}
  </update>
 
    <select id="queryAllPartnerType" resultType="java.util.Map">
        select a.type from xzx_partner_account_log a where 1=1 and a.type is not null group by a.type
    </select>
 
    <select id="queryAllAccountType" resultType="java.util.Map">
        select channel_type as type from xzx_account_log where 1=1 and channel_type is not null group by channel_type
    </select>
 
    <select id="queryPartnerAccountLog" resultType="com.xzx.gc.model.admin.PartnerAccountLogModel">
        select flow_no as flowNo,IFNULL(account_money,0) as account,
        hbb as money,IFNULL(money,0) as hbb,
        user_name as userName,user_phone as userPhone,
        type,role_name as roleName ,approver,approver_time,create_time
        from xzx_partner_account_log where account_id=#{accountId}
 
        <if test="startTime != null and startTime != ''">
            and create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and create_time &lt;= #{endTime}
        </if>
 
        <if test="type != null and type != ''">
            and type=#{type}
        </if>
 
        <if test="userName != null and userName != ''">
            and (user_name like concat("%",#{userName} ,"%") or user_phone like concat("%",#{userName} ,"%"))
        </if>
 
    </select>
    <select id="queryAdminAccountLog" resultType="com.xzx.gc.model.admin.PartnerAccountLogModel">
        SELECT
        a.create_time,
        a.flow_no AS flowNo,
        IFNULL( a.new_money, 0 ) AS newMoney,
        IFNULL( a.money, 0 ) AS money,
        IFNULL( a.new_hbb, 0 ) AS newHbb,
        IFNULL( a.hbb, 0 ) AS hbb,
        IFNULL( a.old_money, 0 ) AS oldMoney,
        IFNULL( a.old_money, 0 ) AS accountMoney,
        ifnull(ifnull(IFNULL(c.`name`,from_base64(b.nick_name)),d.partner_name),'平台管理员') AS userName,
        ifnull(ifnull(IFNULL( c.mobile_phone, b.mobile_phone ),d.mobile_phone),'--') AS userPhone,
        a.type,
        a.create_user_type AS roleName,
        a.create_user_id
        FROM
        xzx_platform_account_log a
        LEFT JOIN xzx_user_info b on a.create_user_id=b.user_id
        LEFT JOIN xzx_user_other_info c on a.create_user_id=c.user_id
        LEFT JOIN xzx_city_partner d on a.create_user_id=d.id
 
        where 1=1
        <if test="startTime != null and startTime != ''">
            and a.create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and a.create_time &lt;= #{endTime}
        </if>
 
        <if test="type != null and type != ''">
            and a.type=#{type}
        </if>
        <if test="userName != null and userName != ''">
            and  ifnull(ifnull(IFNULL(c.`name`,from_base64(b.nick_name)),d.partner_name),'平台管理员') like concat("%",#{userName} ,"%")
        </if>
    </select>
 
    <select id="queryPartnerLog" resultType="com.xzx.gc.model.admin.AccountLogModel">
        select x.userName,x.mobilePhone,x.userType,x.oldMoney,x.newMoney,x.createTime,x.channelType,
        x.oldLimit,x.newLimit,x.roleType from
 
        (SELECT
        '' as userName,
        '' as mobilePhone,
        '' as userType,
        '1' as roleType,
        ifnull( a.account_money, 0 ) AS oldMoney,
        a.hbb AS newMoney,
        a.create_time AS createTime,
        a.type AS channelType,
        a.old_limit as oldLimit,
        a.new_limit as newLimit
        FROM
        xzx_partner_account_log a
        LEFT JOIN xzx_partner_account d ON a.account_id = d.account
        WHERE
        1 =1
        <if test="startTime != null and startTime != ''">
            and a.create_time<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and a.create_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="typeList != null and typeList.size() != 0">
            and a.type in
            <foreach collection="typeList" index="index" item="type" separator="," open="(" close=")">
                #{type}
            </foreach>
        </if>
        <if test="channelType != null and channelType != ''">
            and a.type=#{channelType}
        </if>
        <if test="accountId != null and accountId != ''">
            and a.account_id=#{accountId}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and d.partner_id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
 
        UNION ALL
 
        select
        IFNULL(c.name, n.nick_name) as userName,
        IFNULL(c.mobile_phone, n.mobile_phone) as mobilePhone,
        IFNULL(c.user_type, '1') as userType,
        '0' as roleType,
        ifnull( a.old_money, 0 ) AS oldMoney,
        a.new_money AS newMoney,
        a.create_time AS createTime,
        a.channel_type AS channelType,
        a.old_limit as oldLimit,
        a.new_limit as newLimit
        from xzx_account_log a
        left join xzx_account_info d on a.account_id = d.account_id
        left join (select
        k.name,
        k.mobile_phone,
        k.user_type,
        k.user_id,
        k.partner_id
        from xzx_user_other_info k
        where k.del_flag = 0) c on a.create_user_id = c.user_id
        left join (select
        m.mobile_phone,
        m.nick_name,
        m.user_id
        from xzx_user_info m
        where m.del_flag = 0) n on a.create_user_id = n.user_id
        where d.del_flag = 0
 
        <if test="startTime != null and startTime != ''">
            and a.create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and a.create_time &lt;= #{endTime}
        </if>
 
        <if test="type != null and type != ''">
            and a.type=#{type}
        </if>
 
        <if test="userName != null and userName != ''">
            and (c.name like concat("%",#{userName} ,"%") or c.mobile_phone like concat("%",#{userName},"%") or
            n.mobile_phone like concat("%",#{userName},"%"))
        </if>
 
 
        <if test="typeList != null and typeList.size() != 0">
            and a.channel_type in
            <foreach collection="typeList" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
 
        <if test="channelType != null and channelType != ''">
            and a.channel_type=#{channelType}
        </if>
 
        <if test="accountId != null and accountId != ''">
            and a.account_id=#{accountId}
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and c.partner_id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        ) x
        order by x.createTime desc
 
    </select>
 
 
</mapper>