From 9cc3cf1059d45956f2def7b2b4beb7a112e85c85 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Sat, 22 Oct 2022 18:24:28 +0800
Subject: [PATCH] 20221021

---
 src/main/resources/mapper/dapp/DappWalletCoinDao.xml |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/dapp/DappWalletCoinDao.xml b/src/main/resources/mapper/dapp/DappWalletCoinDao.xml
index fc226e9..b3fe6f7 100644
--- a/src/main/resources/mapper/dapp/DappWalletCoinDao.xml
+++ b/src/main/resources/mapper/dapp/DappWalletCoinDao.xml
@@ -3,6 +3,110 @@
 <mapper namespace="cc.mrbird.febs.dapp.mapper.DappWalletCoinDao">
 
     <select id="selectByMemberId" resultType="cc.mrbird.febs.dapp.entity.DappWalletCoinEntity">
-        select * from dapp_wallet_coin where member_id=#{memberId}
+        select * from dapp_wallet_coin where member_id=#{memberId} limit 1 for update
     </select>
+
+    <select id="selectInPage" resultType="cc.mrbird.febs.dapp.entity.DappWalletCoinEntity">
+        select a.*, b.address address from dapp_wallet_coin a
+        inner join dapp_member b on a.member_id=b.id
+        <where>
+            <if test="record.currentUser != null">
+                and b.referer_id = (select invite_id from dapp_user_member_relate where user_id=#{record.currentUser})
+            </if>
+            <if test="record.address != '' and record.address != null">
+                and b.address = #{record.address}
+            </if>
+        </where>
+    </select>
+
+    <update id="addAvailableAndDelFrozenById">
+        update dapp_wallet_coin
+        set
+            available_amount = available_amount + #{balance},
+            frozen_amount = frozen_amount - #{balance}
+        where
+            id = #{id}
+          and frozen_amount - #{balance} <![CDATA[ >= ]]> 0
+    </update>
+
+    <update id="addFrozenAndDelAvailableById">
+        update dapp_wallet_coin
+        set
+            available_amount = available_amount - #{balance},
+            frozen_amount = frozen_amount + #{balance}
+        where
+            id = #{id}
+          and available_amount - #{balance} <![CDATA[ >= ]]> 0
+    </update>
+
+    <update id="delTotalAndDelFrozenById">
+        update dapp_wallet_coin
+        set
+            total_amount = total_amount - #{balance},
+            frozen_amount = frozen_amount - #{balance}
+        where
+              id = #{id}
+          and total_amount - #{balance} <![CDATA[ >= ]]> 0
+          and frozen_amount - #{balance} <![CDATA[ >= ]]> 0
+    </update>
+
+    <update id="addTotalAndaddAvailableById">
+        update dapp_wallet_coin
+        set
+            total_amount = total_amount + #{balance},
+            available_amount = available_amount + #{balance}
+        where
+              id = #{id}
+    </update>
+
+    <update id="delAvailableDelTotalById">
+        update dapp_wallet_coin
+        set
+            total_amount = total_amount - #{balance},
+            available_amount = available_amount - #{balance}
+        where
+              id = #{id}
+           and total_amount - #{balance} <![CDATA[ >= ]]> 0
+    </update>
+
+
+    <select id="selectWalletCoinBymIdAndCode" resultType="cc.mrbird.febs.dapp.entity.DappWalletCoinEntity">
+        select * from member_wallet_coin where member_id = #{memberId} and wallet_code = #{walletCode}
+    </select>
+
+    <update id="updateFrozenBalance" parameterType="map">
+        UPDATE member_wallet_coin
+        SET available_balance = available_balance - #{amount},
+            frozen_balance = frozen_balance + #{amount}
+        WHERE
+            id = #{id}
+          AND member_id = #{memberId}
+    </update>
+
+    <update id="subFrozenBalance" parameterType="map">
+        UPDATE member_wallet_coin
+        SET available_balance = available_balance + #{amount},
+            frozen_balance = frozen_balance - #{amount}
+        WHERE
+            id = #{id}
+          AND member_id = #{memberId}
+    </update>
+
+
+    <update id="updateBlockBalance">
+        update member_wallet_coin
+        set
+            available_balance = IFNULL(available_balance, 0) + #{availableBalance},
+            total_balance = IFNULL(total_balance, 0) + #{availableBalance},
+            early_balance = IFNULL(early_balance, 0) + #{earlyBalance},
+            block_number  = IFNULL(block_number, 0) + #{blockNumber}
+        where id=#{id}
+    </update>
+
+    <update id="reduceFrozenBalance">
+        update member_wallet_coin
+        set frozen_balance = frozen_balance - #{amount},
+            total_balance = total_balance - #{amount}
+        where id=#{id}
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1