Helius
2021-06-16 4e51778362c2130598a4c73ec4cebe6629dbc53f
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
<?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.pay.mapper.AccountMapper">
 
    <resultMap id="AccountMap" type="com.xzx.gc.model.admin.UserAccountModel">
        <result column="account_id" jdbcType="VARCHAR" property="accountId"/>
        <result column="account_name" jdbcType="VARCHAR" property="accountName"/>
        <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <result column="pay_password" jdbcType="VARCHAR" property="payPassword"/>
        <result column="freeze_money" jdbcType="VARCHAR" property="freezeMoney"/>
        <result column="withdraw_money" jdbcType="VARCHAR" property="withdrawMoney"/>
        <result column="overdraft_limit" jdbcType="VARCHAR" property="overdraftLimit"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="error_times" jdbcType="INTEGER" property="errorTimes"/>
        <result column="last_error_time" jdbcType="VARCHAR" property="lastErrorTime"/>
        <result column="fixed_limit" jdbcType="VARCHAR" property="fixedLimit"/>
    </resultMap>
 
 
    <!-- 回收员的透支金额减少 -->
    <update id="updateLimitByOrder" parameterType="map">
        update xzx_account_info
        set overdraft_limit = cast((cast(overdraft_limit as DECIMAL(9,2))+#{money}) as CHAR),update_time=now()
        where user_id=#{userId} and del_flag=0 and is_prohibit='0'
    </update>
 
    <!-- 回收员的透支金额减少 -->
    <update id="updateMoneyAndLimit" parameterType="map">
        update xzx_account_info
        set money = cast((cast(money as DECIMAL(9,2))+#{money}) as CHAR),
        overdraft_limit = cast(#{limit} as CHAR),update_time=now()
        where user_id=#{userId} and del_flag=0 and is_prohibit='0'
    </update>
 
 
    <update id="updateAccountOverdrawPrice">
        update xzx_account_info set
        overdraft_limit=#{newOverdrawPrice}.
        fixed_limit=#{newOverdrawPrice}
        where del_flag=0 and overdraft_limit=#{oldOverdrawPrice}
        and user_id in
        <foreach collection="orderIds" index="index" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
    </update>
 
 
    <select id="queryAccountInfo" resultMap="AccountMap">
        select account_id,account_name,user_id,pay_password,money,freeze_money,withdraw_money,overdraft_limit,del_flag,error_times,last_error_time,fixed_limit from xzx_account_info where del_flag=0
        <if test="userId != null and userId != ''">
            AND user_id=#{userId}
        </if>
        <if test="phone != null and phone != ''">
            AND account_name=#{phone}
        </if>
    </select>
 
    <update id="updateOverdrawPriceByUserId">
        update xzx_account_info
        set fixed_limit = fixed_limit + #{money}, overdraft_limit = overdraft_limit + #{money}
        where del_flag = 0 and account_id = #{accountId}
    </update>
 
    <update id="updateAccountMoneyDouble">
        update `xzx_account_info` set money=#{money}
        where account_id=#{accountId}
    </update>
 
    <update id="updateLimitByUserId">
        update xzx_account_info
        set overdraft_limit = fixed_limit
        where del_flag = 0 and account_id = #{accountId}
    </update>
 
    <select id="getAccountByUserId" resultType="com.xzx.gc.model.admin.UserAccountModel">
        select *
        from xzx_account_info
        where user_id = #{userId} and del_flag = 0
    </select>
 
    <update id="updateUserAccount">
        update xzx_account_info
        set money = #{money}, overdraft_limit = #{overdraftLimit}
        where user_id = #{userId} and del_flag = 0
    </update>
 
</mapper>