流水记录优化
This commit is contained in:
1 parent
dcd8eadd20
commit
abdafd5c9d
11 files changed
+238
-28
No files matched your search
@@ -143,6 +143,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
on duplicate key update id = id
|
||||
</insert>
|
||||
|
||||
<select id="countByIdempotencyKey" resultType="int">
|
||||
select count(1) from apps_balance_ledger where idempotency_key = #{idempotencyKey}
|
||||
</select>
|
||||
|
||||
<sql id="statisticsConditions">
|
||||
1 = 1
|
||||
<if test="appId != null">and app_id = #{appId}</if>
|
||||
|
||||
@@ -59,19 +59,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
for update
|
||||
</select>
|
||||
|
||||
<select id="countPaidByTransactionId" resultType="int">
|
||||
<select id="countByTransactionId" resultType="int">
|
||||
select count(1)
|
||||
from orders
|
||||
where block_transaction_id = #{transactionId}
|
||||
and status = 2
|
||||
and id != #{excludeOrderId}
|
||||
</select>
|
||||
|
||||
<update id="markPaymentDetected">
|
||||
update orders
|
||||
set block_transaction_id = #{transactionId}, updated_at = #{updatedAt}
|
||||
where id = #{id}
|
||||
and status = 1
|
||||
and (block_transaction_id is null or block_transaction_id = '' or block_transaction_id = #{transactionId})
|
||||
and not exists (
|
||||
select 1
|
||||
from (select id, block_transaction_id from orders) existing_order
|
||||
where existing_order.id != #{id}
|
||||
and existing_order.block_transaction_id = #{transactionId}
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="markOrderPaid">
|
||||
update orders
|
||||
set block_transaction_id = #{transactionId}, status = 2, updated_at = #{updatedAt}
|
||||
where id = #{id} and status = 1
|
||||
</update>
|
||||
|
||||
<select id="selectOrderIdsRequiringSettlement" resultType="long">
|
||||
select o.id
|
||||
from orders o
|
||||
where o.deleted_at is null
|
||||
and o.block_transaction_id is not null
|
||||
and o.block_transaction_id != ''
|
||||
and (
|
||||
o.status = 1
|
||||
or (o.status = 2 and (not exists (
|
||||
select 1 from wallet_address_ledger w
|
||||
where w.idempotency_key = concat('ORDER_RECEIVE:', o.id, ':USDT')
|
||||
)
|
||||
or not exists (
|
||||
select 1 from apps_balance_ledger a
|
||||
where a.idempotency_key = concat('ORDER_RECEIVE:', o.id, ':USDT')
|
||||
)
|
||||
or not exists (
|
||||
select 1 from apps_balance_ledger f
|
||||
where f.idempotency_key = concat('ORDER_FEE:', o.id, ':TRX')
|
||||
)))
|
||||
)
|
||||
order by o.id
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<insert id="insertUsdtOrders" parameterType="UsdtOrders" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into orders
|
||||
|
||||
@@ -197,6 +197,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
on duplicate key update id = id
|
||||
</insert>
|
||||
|
||||
<select id="countByIdempotencyKey" resultType="int">
|
||||
select count(1) from wallet_address_ledger where idempotency_key = #{idempotencyKey}
|
||||
</select>
|
||||
|
||||
<sql id="statisticsConditions">
|
||||
status = 1
|
||||
<if test="appId != null">and app_id = #{appId}</if>
|
||||
|
||||
Reference in new issue
Block a user