You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.9 KiB
82 lines
2.9 KiB
<?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.blockchain.server.btc.mapper.BtcWalletMapper"> |
|
<resultMap id="BtcWalletMap" type="com.blockchain.server.btc.dto.BtcWalletDTO"> |
|
<result property="tokenId" column="token_id"/> |
|
<result property="userOpenId" column="user_open_id"/> |
|
<result property="tokenSymbol" column="token_symbol"/> |
|
<result property="balance" column="balance"/> |
|
<result property="createTime" column="create_time"/> |
|
<result property="walletType" column="wallet_type"/> |
|
<result property="updateTime" column="update_time"/> |
|
<result property="freeBalance" column="free_balance"/> |
|
<result property="addr" column="addr"/> |
|
<result property="freezeBalance" column="freeze_balance"/> |
|
</resultMap> |
|
|
|
<sql id="tableName">dapp_btc_wallet</sql> |
|
|
|
<select id="selectByUserOpenId" resultMap="BtcWalletMap"> |
|
SELECT * FROM |
|
<include refid="tableName"/> |
|
WHERE user_open_id = #{userOpenId} AND token_id = #{tokenId} AND wallet_type = #{walletType} |
|
</select> |
|
|
|
<select id="selectAllByUserOpenId" resultMap="BtcWalletMap"> |
|
SELECT * FROM |
|
<include refid="tableName"/> |
|
WHERE user_open_id = #{userOpenId} AND wallet_type = #{walletType} |
|
</select> |
|
|
|
<select id="selectAll" resultMap="BtcWalletMap"> |
|
SELECT * FROM |
|
<include refid="tableName"/> |
|
WHERE user_open_id = #{userOpenId} |
|
</select> |
|
|
|
<select id="selectByAddr" resultMap="BtcWalletMap"> |
|
SELECT * FROM |
|
<include refid="tableName"/> |
|
WHERE addr = #{addr} |
|
AND token_id = #{tokenId} |
|
<if test="walletType != '' and walletType != null"> |
|
AND wallet_type = #{walletType} |
|
</if> |
|
</select> |
|
|
|
<update id="updateBalanceByAddrInRowLock"> |
|
UPDATE |
|
<include refid="tableName"/> |
|
SET |
|
balance = balance + #{totalAmount}, |
|
free_balance = free_balance + #{freeAmount}, |
|
freeze_balance = freeze_balance + #{freezeAmount}, |
|
update_time = #{modifyTime} |
|
WHERE addr = #{address} |
|
AND token_id = #{tokenId} |
|
AND balance + #{totalAmount} >= 0 |
|
AND free_balance + #{freeAmount} >= 0 |
|
AND freeze_balance + #{freezeAmount} >= 0 |
|
</update> |
|
|
|
<select id="getAllWalletAddr" resultType="String"> |
|
SELECT addr from |
|
<include refid="tableName"/> |
|
</select> |
|
|
|
<update id="updateWalletBalanceByUserOpenId"> |
|
UPDATE |
|
<include refid="tableName"/> |
|
wallet |
|
SET |
|
wallet.balance = wallet.freeze_balance + #{balance}, |
|
wallet.free_balance = #{balance}, |
|
wallet.update_time = #{modifyTime} |
|
WHERE |
|
wallet.user_open_id = #{userOpenId} |
|
AND wallet.token_symbol = #{tokenSymbol} |
|
AND wallet.wallet_type = #{walletType} |
|
</update> |
|
</mapper>
|
|
|