xiaoyong931011
2021-07-14 8d08ca6bdfc3dd61b0aaa7daa27308c3d59f0df1
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
<?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.PayInfoMapper">
 
    <resultMap id="MoneyDetailMap" type="com.xzx.gc.model.user.MoneyDetailVo">
        <result column="sum_count" jdbcType="INTEGER" property="sumCount"/>
        <result column="sum_money" jdbcType="VARCHAR" property="sumMoney"/>
        <result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
    </resultMap>
 
    <resultMap id="UserShareInfoMap" type="com.xzx.gc.model.user.UserShareInfoVo">
        <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone"/>
        <result column="invite_count" jdbcType="VARCHAR" property="inviteCount"/>
    </resultMap>
 
    <resultMap id="UserPayInfoMap" type="com.xzx.gc.model.pay.PayInfoVo">
        <result column="pay_order_id" jdbcType="VARCHAR" property="payOrderId"/>
        <result column="order_id" jdbcType="VARCHAR" property="orderId"/>
        <result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="create_time" jdbcType="VARCHAR" property="createTime"/>
        <result column="pay_type" jdbcType="VARCHAR" property="payType"/>
        <result column="open_id" jdbcType="VARCHAR" property="openId"/>
        <result column="pay_type_name" jdbcType="VARCHAR" property="payTypeName"/>
        <result column="examine_time" jdbcType="VARCHAR" property="examineTime"/>
        <result column="unpass_reason" jdbcType="VARCHAR" property="unpassReason"/>
        <result column="wxpay_flag" jdbcType="INTEGER" property="wxpayFlag"/>
        <result column="pay_flag" jdbcType="INTEGER" property="payFlag"/>
 
    </resultMap>
 
    <!-- 支付信息录入 -->
    <insert id="payInfoAdd" parameterType="map">
        insert into xzx_pay_info(pay_order_id,order_id,create_user_id,money,
                                 account_id,pay_type,open_id,status,create_time)
        values (#{payOrderId},#{orderId},#{createUserId},#{money},
                #{accountId},#{payType},#{openId},#{status},#{createTime})
    </insert>
 
    <insert id="addPayInfo">
        INSERT INTO `xzx_pay_info` (`pay_order_id`, `order_id`, `create_user_id`, `money`,
                                    `account_id`, `pay_type`, `open_id`, `status`, `create_time`, `check_num`, `pay_img`, `pay_time`)
        VALUES (#{payOrderId}, NULL, #{createUserId}, #{money}, #{accountId},
                               '1', NULL, #{status}, SYSDATE(), NULL, #{payImg}, #{payTime})
    </insert>
 
    <insert id="addPayInfo1">
        INSERT INTO `xzx_pay_info` (`pay_order_id`, `order_id`, `create_user_id`, `money`,
                                    `account_id`, `pay_type`, `open_id`, `status`, `create_time`, `check_num`, `pay_img`, `pay_time`)
        VALUES (#{payOrderId}, NULL, #{createUserId}, #{money}, #{accountId},
                               #{payType}, NULL, #{status}, SYSDATE(), NULL, #{payImg}, #{payTime})
    </insert>
 
    <select id="queryCollectorWM"   resultType="java.lang.String">
        select IFNULL(sum(money),0) from xzx_pay_info
        where pay_type =13 and create_user_id=#{userId}
    </select>
 
    <select id="queryUserMoneyStatInfo" parameterType="map" resultMap="MoneyDetailMap">
        select create_user_id,count(*) sum_count,sum(cast(money as DECIMAL(9,2))) sum_money from xzx_pay_info
        where pay_type=#{payType} and create_user_id=#{createUserId}
        <if test="txFlag!=null">
            and status=4
        </if>
        group by create_user_id
    </select>
 
 
 
 
 
    <select id="queryUserPayAll" resultMap="UserPayInfoMap">
        SELECT
            *
        FROM
            (
                SELECT
                    a.pay_order_id,
                    a.create_user_id,
                    a.create_time,
                    a.money,
                    a.pay_type,
                    a.STATUS,
                    a.fee,
                    b.config_value_name pay_type_name
                FROM
                    xzx_pay_info a
                    LEFT JOIN xzx_sys_config_info b ON a.pay_type = b.config_value
                                                       AND b.config_type_code = 'PAY_TYPE'
                WHERE
                    a.create_user_id = #{createUserId}
                UNION ALL
                SELECT
                    a.pay_order_id,
                    a.create_user_id,
                    a.create_time,
                    a.money,
                    a.pay_type,
                    a.STATUS,
                    "0" as fee,
                    b.config_value_name pay_type_name
                FROM
                    xzx_pay_request_info a
                    LEFT JOIN xzx_sys_config_info b ON a.pay_type = b.config_value
                                                       AND b.config_type_code = 'PAY_TYPE'
                WHERE
                    a.create_user_id = #{createUserId}
            ) a
        ORDER BY
            a.create_time DESC
    </select>
 
 
    <select id="queryDetailsPresentation" resultType="com.xzx.gc.model.admin.PartnerPayMsgModel">
        select x.flowNo,x.payName,x.payTime,x.money,x.partnerName,x.payStatus,x.mobilePhone,x.partnerType,x.delFlag from (
        select a.pay_order_id as flowNo,'充值' as payName,a.create_time as payTime,a.money as money,b.partner_name as
        partnerName,b.del_flag as delFlag,
        a.status as payStatus,b.mobile_phone as mobilePhone,b.partner_type as partnerType
        from xzx_pay_info a
        LEFT JOIN xzx_city_partner b ON a.create_user_id = b.user_id
        where 1=1 and a.pay_type=1 and b.user_id is not null
 
        <if test="userId != null and userId != ''">
            and a.create_user_id =#{userId}
        </if>
 
        <if test="payType != null and payType != ''">
            and a.pay_type = #{payType}
        </if>
 
        <if test="payStatus != null and payStatus != ''">
            and a.status = #{payStatus}
        </if>
 
        <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="name != null and name != ''">
            and (b.partner_name like concat("%",#{name} ,"%") or b.mobile_phone like concat("%",#{name} ,"%"))
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and b.id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")" >
                #{id}
            </foreach>
        </if>
 
        UNION ALL
        select c.pay_order_id as flowNo,'提现' as payName,c.create_time as payTime,c.money as money,d.partner_name as
        partnerName,d.del_flag as delFlag,
        c.status as payStatus,d.mobile_phone as mobilePhone,d.partner_type as partnerType
        from xzx_pay_request_info c
        LEFT JOIN xzx_city_partner d ON c.create_user_id=d.user_id
        where 1=1 and c.pay_type=4 and d.user_id is not null
 
        <if test="userId != null and userId != ''">
            and c.create_user_id =#{userId}
        </if>
 
        <if test="payType != null and payType != ''">
            and c.pay_type = #{payType}
        </if>
 
        <if test="payStatus != null and payStatus != ''">
            and c.status = #{payStatus}
        </if>
 
        <if test="startTime != null and startTime != ''">
            and c.create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and c.create_time &lt;= #{endTime}
        </if>
 
        <if test="name != null and name != ''">
            and (d.partner_name like concat("%",#{name} ,"%") or d.mobile_phone like concat("%",#{name} ,"%"))
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and d.id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
 
        ) x order by x.payTime desc
 
    </select>
 
    <select id="queryPayInfoById" resultType="com.xzx.gc.model.admin.PayInfoModel">
        select *
        from xzx_pay_info
        where pay_order_id = #{payOrderId}
    </select>
 
    <update id="updatePayInfoPass">
        update xzx_pay_info set
        status=#{status}
        <if test="unpassReason != null and unpassReason != ''">
            , unpass_reason=#{unpassReason}
        </if>
        where pay_order_id=#{payOrderId}
    </update>
</mapper>