Helius
2021-11-26 4017fe347792c7e28695c455a40874f0c647cc9b
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
<?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.fish.dao.MemberAccountGoldDao">
 
    <select id="selectAccountGoldByMemberId" resultType="com.xcong.excoin.modules.fish.entity.MemberAccountGold">
        select a.* from member_account_gold a where a.member_id = #{memberId}
    </select>
 
    <update id="updateTotalBalanceAndAvailableBalance" parameterType="map">
        update member_account_gold
        <set>
            <if test="availableBalance != null">
                available_balance = (
                case when  IFNULL(available_balance, 0) + #{availableBalance}>0 then  IFNULL(available_balance, 0) + #{availableBalance} else 0 end
                ),
            </if>
            <if test="totalBalance != null">
                total_balance = (
                case when  IFNULL(total_balance, 0) + #{totalBalance}>0 then  IFNULL(total_balance, 0) + #{totalBalance} else 0 end
                ),
            </if>
            <if test="frozenBalance != null">
                frozen_balance = (
                case when  IFNULL(frozen_balance, 0) + #{frozenBalance}>0 then  IFNULL(frozen_balance, 0) + #{frozenBalance} else 0 end
                ),
            </if>
        </set>
        where id=#{id}
    </update>
 
    <select id="selectAccountGoldVoByMemberId" resultType="com.xcong.excoin.modules.fish.vo.GoldAccountVo">
        select a.* from member_account_gold a where a.member_id = #{memberId}
    </select>
 
    <select id="selectByMemberIdForLock" resultType="com.xcong.excoin.modules.fish.entity.MemberAccountGold">
        select a.* from member_account_gold a where a.member_id = #{memberId} for update
    </select>
</mapper>