2026-01-05 15:46:59 +08:00
|
|
|
<?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.m2pool.lease.mapper.LeaseUserWalletDataMapper">
|
|
|
|
|
|
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseUserWalletData">
|
|
|
|
|
<id column="id" property="id" />
|
|
|
|
|
<result column="user_id" property="userId" />
|
|
|
|
|
<result column="from_address" property="fromAddress" />
|
|
|
|
|
<result column="balance" property="balance" />
|
|
|
|
|
<result column="to_address" property="toAddress" />
|
|
|
|
|
<result column="from_symbol" property="fromSymbol" />
|
|
|
|
|
<result column="from_chain" property="fromChain" />
|
|
|
|
|
<result column="to_symbol" property="toSymbol" />
|
|
|
|
|
<result column="to_chain" property="toChain" />
|
|
|
|
|
<result column="qrcode" property="qrcode" />
|
|
|
|
|
<result column="create_time" property="createTime" />
|
|
|
|
|
<result column="update_time" property="updateTime" />
|
|
|
|
|
<result column="del" property="del" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<!-- 通用查询结果列 -->
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
id, user_id, from_address, balance, to_address, from_symbol, from_chain, to_symbol, to_chain, qrcode, create_time, update_time, del
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据用户 ID 查询钱包信息 -->
|
|
|
|
|
<select id="selectByUserId" resultType="com.m2pool.lease.dto.UserWalletDataDto">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
user_id as userId,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
balance,
|
|
|
|
|
blocked_balance as blockedBalance,
|
|
|
|
|
qrcode,
|
|
|
|
|
to_address as toAddress,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain,
|
|
|
|
|
to_symbol as toSymbol,
|
|
|
|
|
to_chain as toChain,
|
|
|
|
|
create_time as createTime
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE auth_id = #{authId} AND del = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getWalletInfoByAddress" resultType="com.m2pool.lease.dto.UserWalletDataDto">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
user_id as userId,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
balance,
|
|
|
|
|
blocked_balance as blockedBalance,
|
|
|
|
|
qrcode,
|
|
|
|
|
to_address as toAddress,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain,
|
|
|
|
|
to_symbol as toSymbol,
|
|
|
|
|
to_chain as toChain,
|
|
|
|
|
create_time as createTime
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE user_id = #{userId} AND from_symbol = #{symbol} AND from_address = #{address} AND del = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getWalletInfoByChain" resultType="com.m2pool.lease.dto.UserWalletDataDto">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
user_id as userId,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
balance,
|
|
|
|
|
blocked_balance as blockedBalance,
|
|
|
|
|
qrcode,
|
|
|
|
|
to_address as toAddress,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain,
|
|
|
|
|
to_symbol as toSymbol,
|
|
|
|
|
to_chain as toChain,
|
|
|
|
|
create_time as createTime,
|
|
|
|
|
queue_id as queueId
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE auth_id = #{authId} AND from_chain = #{chain} AND del = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getWalletForBalanceIsZero" resultType="com.m2pool.lease.entity.LeaseUserWalletData">
|
|
|
|
|
SELECT
|
|
|
|
|
queue_id as queueId,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE balance = 0 AND del = 0 AND create_time <![CDATA[ <= ]]> DATE_SUB(NOW(), INTERVAL 6 MONTH) AND
|
|
|
|
|
(<foreach collection="list" item="item" separator="OR">
|
|
|
|
|
(`from_address` = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain})
|
|
|
|
|
</foreach>)
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectWalletByChainAndCoinAndUsername" resultType="com.m2pool.lease.entity.LeaseUserWalletData">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
balance,
|
|
|
|
|
blocked_balance as blockedBalance,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE del = 0 AND auth_id = #{authId} AND (
|
|
|
|
|
<foreach collection="list" item="item" separator="OR">
|
|
|
|
|
(from_chain = #{item.chain} AND from_symbol = #{item.coin} )
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-01-27 15:54:17 +08:00
|
|
|
<select id="selectBuyerWalletsByPayRecords" resultType="com.m2pool.lease.dto.BuyerWalletQueryDto">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
auth_id as authId,
|
|
|
|
|
from_address as fromAddress,
|
|
|
|
|
balance,
|
|
|
|
|
blocked_balance as blockedBalance,
|
|
|
|
|
to_address as toAddress,
|
|
|
|
|
from_symbol as fromSymbol,
|
|
|
|
|
from_chain as fromChain,
|
|
|
|
|
to_symbol as toSymbol,
|
|
|
|
|
to_chain as toChain,
|
|
|
|
|
blocked_balance as `lock`
|
|
|
|
|
FROM lease_user_wallet_data
|
|
|
|
|
WHERE del = 0
|
|
|
|
|
AND (from_address, from_symbol, from_chain) IN (
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.fromAddress}, #{item.fromSymbol}, #{item.fromChain})
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</select>
|
2026-01-05 15:46:59 +08:00
|
|
|
|
2026-01-27 15:54:17 +08:00
|
|
|
<update id="updateBalanceAndBlockBalanceById">
|
2026-01-06 13:56:23 +08:00
|
|
|
UPDATE lease_user_wallet_data
|
|
|
|
|
SET balance = CASE
|
|
|
|
|
<foreach collection="list" item="item">
|
2026-01-27 15:54:17 +08:00
|
|
|
WHEN id = #{item.id}
|
|
|
|
|
THEN #{item.balance}
|
2026-01-05 15:46:59 +08:00
|
|
|
</foreach>
|
2026-01-06 13:56:23 +08:00
|
|
|
ELSE balance
|
|
|
|
|
END,
|
|
|
|
|
blocked_balance = CASE
|
|
|
|
|
<foreach collection="list" item="item">
|
2026-01-27 15:54:17 +08:00
|
|
|
WHEN id = #{item.id}
|
|
|
|
|
THEN #{item.blockedBalance}
|
2026-01-06 13:56:23 +08:00
|
|
|
</foreach>
|
|
|
|
|
ELSE blocked_balance
|
|
|
|
|
END
|
2026-01-27 15:54:17 +08:00
|
|
|
WHERE id IN (
|
2026-01-06 13:56:23 +08:00
|
|
|
<foreach collection="list" item="item" separator=",">
|
2026-01-27 15:54:17 +08:00
|
|
|
#{item.id}
|
2026-01-06 13:56:23 +08:00
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
AND del = false
|
2026-01-27 15:54:17 +08:00
|
|
|
AND blocked_balance = CASE
|
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
|
WHEN id = #{item.id}
|
|
|
|
|
THEN #{item.lock}
|
|
|
|
|
</foreach>
|
|
|
|
|
ELSE blocked_balance
|
|
|
|
|
END
|
2026-01-05 15:46:59 +08:00
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
</mapper>
|