Files
usdt/ruoyi-system/src/main/resources/mapper/system/UsdtOrdersMapper.xml
T
lu7213 0ff174e872 订单支付成功时,事务化写入 USDT 收入流水。
归集明细成功时,事务化写入 USDT 支出流水。
使用唯一幂等键防止订单重扫、归集重试产生重复流水。
新增按应用、币种、时间范围以及日/月/年维度的统计接口。
管理员和商户接口均改为只读,移除流水新增、修改、删除入口。
商户查询由后端强制限定当前用户。
2026-10-13 10:32:18 -04:00

156 lines
8.2 KiB
XML

<?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.ruoyi.system.mapper.UsdtOrdersMapper">
<resultMap type="UsdtOrders" id="UsdtOrdersResult">
<result property="id" column="id" />
<result property="tradeId" column="trade_id" />
<result property="orderId" column="order_id" />
<result property="blockTransactionId" column="block_transaction_id" />
<result property="actualAmount" column="actual_amount" />
<result property="amount" column="amount" />
<result property="token" column="token" />
<result property="status" column="status" />
<result property="notifyUrl" column="notify_url" />
<result property="redirectUrl" column="redirect_url" />
<result property="callbackNum" column="callback_num" />
<result property="callbackConfirm" column="callback_confirm" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
<result property="appId" column="app_id" />
<result property="settlementStatus" column="settlement_status" />
<result property="userId" column="user_id" />
<result property="orderType" column="order_type" />
</resultMap>
<sql id="selectUsdtOrdersVo">
select id, trade_id, order_id,order_type, block_transaction_id, actual_amount, amount, token, status, notify_url, redirect_url, callback_num, callback_confirm, created_at, updated_at, deleted_at, app_id, settlement_status, user_id from orders
</sql>
<select id="selectUsdtOrdersList" parameterType="UsdtOrders" resultMap="UsdtOrdersResult">
<include refid="selectUsdtOrdersVo"/>
<where>
<if test="tradeId != null and tradeId != ''"> and trade_id like concat('%', #{tradeId}, '%')</if>
<if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%')</if>
<if test="token != null and token != ''"> and token = #{token}</if>
<if test="status != null "> and status = #{status}</if>
<if test="callbackConfirm != null "> and callback_confirm = #{callbackConfirm}</if>
<if test="appId != null "> and app_id = #{appId}</if>
<if test="settlementStatus != null "> and settlement_status = #{settlementStatus}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="orderType != null "> and order_type = #{orderType}</if>
</where>
</select>
<select id="selectUsdtOrdersById" parameterType="Long" resultMap="UsdtOrdersResult">
<include refid="selectUsdtOrdersVo"/>
where id = #{id}
</select>
<select id="selectByIdForUpdate" resultType="com.ruoyi.system.domain.UsdtOrdersPlus">
select id, trade_id, order_id, block_transaction_id, actual_amount, amount, token,
status, notify_url, redirect_url, callback_num, callback_confirm, created_at,
updated_at, deleted_at, app_id, settlement_status, user_id, order_type
from orders
where id = #{id}
for update
</select>
<select id="countPaidByTransactionId" resultType="int">
select count(1)
from orders
where block_transaction_id = #{transactionId}
and status = 2
and id != #{excludeOrderId}
</select>
<update id="markOrderPaid">
update orders
set block_transaction_id = #{transactionId}, status = 2, updated_at = #{updatedAt}
where id = #{id} and status = 1
</update>
<insert id="insertUsdtOrders" parameterType="UsdtOrders" useGeneratedKeys="true" keyProperty="id">
insert into orders
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tradeId != null and tradeId != ''">trade_id,</if>
<if test="orderId != null and orderId != ''">order_id,</if>
<if test="blockTransactionId != null">block_transaction_id,</if>
<if test="actualAmount != null">actual_amount,</if>
<if test="amount != null">amount,</if>
<if test="token != null and token != ''">token,</if>
<if test="status != null">status,</if>
<if test="notifyUrl != null and notifyUrl != ''">notify_url,</if>
<if test="redirectUrl != null">redirect_url,</if>
<if test="callbackNum != null">callback_num,</if>
<if test="callbackConfirm != null">callback_confirm,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="deletedAt != null">deleted_at,</if>
<if test="appId != null">app_id,</if>
<if test="settlementStatus != null">settlement_status,</if>
<if test="userId != null">user_id,</if>
<if test="orderType != null">order_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tradeId != null and tradeId != ''">#{tradeId},</if>
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="blockTransactionId != null">#{blockTransactionId},</if>
<if test="actualAmount != null">#{actualAmount},</if>
<if test="amount != null">#{amount},</if>
<if test="token != null and token != ''">#{token},</if>
<if test="status != null">#{status},</if>
<if test="notifyUrl != null and notifyUrl != ''">#{notifyUrl},</if>
<if test="redirectUrl != null">#{redirectUrl},</if>
<if test="callbackNum != null">#{callbackNum},</if>
<if test="callbackConfirm != null">#{callbackConfirm},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="deletedAt != null">#{deletedAt},</if>
<if test="appId != null">#{appId},</if>
<if test="settlementStatus != null">#{settlementStatus},</if>
<if test="userId != null">#{userId},</if>
<if test="orderType != null">#{orderType},</if>
</trim>
</insert>
<update id="updateUsdtOrders" parameterType="UsdtOrders">
update orders
<trim prefix="SET" suffixOverrides=",">
<if test="tradeId != null and tradeId != ''">trade_id = #{tradeId},</if>
<if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
<if test="blockTransactionId != null">block_transaction_id = #{blockTransactionId},</if>
<if test="actualAmount != null">actual_amount = #{actualAmount},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="token != null and token != ''">token = #{token},</if>
<if test="status != null">status = #{status},</if>
<if test="notifyUrl != null and notifyUrl != ''">notify_url = #{notifyUrl},</if>
<if test="redirectUrl != null">redirect_url = #{redirectUrl},</if>
<if test="callbackNum != null">callback_num = #{callbackNum},</if>
<if test="callbackConfirm != null">callback_confirm = #{callbackConfirm},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
<if test="appId != null">app_id = #{appId},</if>
<if test="settlementStatus != null">settlement_status = #{settlementStatus},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="orderType != null">order_type = #{orderType},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUsdtOrdersById" parameterType="Long">
delete from orders where id = #{id}
</delete>
<delete id="deleteUsdtOrdersByIds" parameterType="String">
delete from orders where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>