update 优化订单支付定时任务批量修改金额相关sql
This commit is contained in:
@@ -447,14 +447,34 @@
|
||||
|
||||
|
||||
<update id="updateBatchSaleNumbers">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_machine
|
||||
SET
|
||||
sale_out_numbers = sale_out_numbers - #{item.saleOutNumbers},
|
||||
can_sale_numbers = can_sale_numbers + #{item.canSaleNumbers}
|
||||
WHERE
|
||||
id = #{item.id}
|
||||
</foreach>
|
||||
UPDATE lease_machine
|
||||
SET
|
||||
sale_out_numbers = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN sale_out_numbers - #{item.saleOutNumbers}
|
||||
</foreach>
|
||||
ELSE sale_out_numbers
|
||||
END,
|
||||
can_sale_numbers = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN can_sale_numbers + #{item.canSaleNumbers}
|
||||
</foreach>
|
||||
ELSE can_sale_numbers
|
||||
END,
|
||||
sale_state = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN false
|
||||
</foreach>
|
||||
ELSE sale_state
|
||||
END
|
||||
WHERE id IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
|
||||
<select id="checkHasSaleMachineByShopId" resultType="java.lang.Integer">
|
||||
@@ -467,5 +487,19 @@
|
||||
and `sale_state` = 1
|
||||
and `del` = 0
|
||||
</select>
|
||||
<select id="getProductListForShopWalletConfig"
|
||||
resultType="com.m2pool.lease.dto.v2.MachineForWalletConfigDto">
|
||||
SELECT
|
||||
lpm.id as productMachineId,
|
||||
lpm.`user`,
|
||||
lpm.type,
|
||||
lpm.miner,
|
||||
lpm.state,
|
||||
lpm.sale_state as saleState
|
||||
FROM
|
||||
lease_machine lpm
|
||||
WHERE
|
||||
del = false AND lpm.shop_id = #{shopId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -90,11 +90,31 @@
|
||||
</select>
|
||||
|
||||
<update id="updateBalance">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_shop_config
|
||||
SET balance = balance + #{item.realAmount}
|
||||
WHERE pay_address = #{item.fromAddress} AND pay_coin = #{item.fromSymbol} AND chain = #{item.fromChain} AND del = false
|
||||
</foreach>
|
||||
UPDATE lease_shop_config
|
||||
SET balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN pay_address = #{item.fromAddress} AND pay_coin = #{item.fromSymbol} AND chain = #{item.fromChain} AND del = false
|
||||
THEN balance + #{item.realAmount}
|
||||
</foreach>
|
||||
ELSE balance
|
||||
END
|
||||
WHERE pay_address IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromAddress}
|
||||
</foreach>
|
||||
)
|
||||
AND pay_coin IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromSymbol}
|
||||
</foreach>
|
||||
)
|
||||
AND chain IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromChain}
|
||||
</foreach>
|
||||
)
|
||||
AND del = false
|
||||
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -108,12 +108,37 @@
|
||||
|
||||
|
||||
<update id="updateBalanceAndBlockBalance">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_user_wallet_data
|
||||
SET balance = balance - #{item.realAmount},
|
||||
blocked_balance = blocked_balance - #{item.blockAmount}
|
||||
WHERE from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
UPDATE lease_user_wallet_data
|
||||
SET balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
THEN balance - #{item.realAmount}
|
||||
</foreach>
|
||||
ELSE balance
|
||||
END,
|
||||
blocked_balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
THEN blocked_balance - #{item.blockAmount}
|
||||
</foreach>
|
||||
ELSE blocked_balance
|
||||
END
|
||||
WHERE from_address IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromAddress}
|
||||
</foreach>
|
||||
)
|
||||
AND from_symbol IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromSymbol}
|
||||
</foreach>
|
||||
)
|
||||
AND from_chain IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromChain}
|
||||
</foreach>
|
||||
)
|
||||
AND del = false
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user