From cb0eefdc3573b633f18f242abe30f3a9b94e6153 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 14 Mar 2022 18:00:27 +0800
Subject: [PATCH] 20222223

---
 src/main/resources/mapper/member/MemberWalletCoinDao.xml |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/member/MemberWalletCoinDao.xml b/src/main/resources/mapper/member/MemberWalletCoinDao.xml
index e7fd894..13be502 100644
--- a/src/main/resources/mapper/member/MemberWalletCoinDao.xml
+++ b/src/main/resources/mapper/member/MemberWalletCoinDao.xml
@@ -43,17 +43,29 @@
 		update member_wallet_coin
 		<set>
 			<if test="availableBalance != null">
-				available_balance = IFNULL(available_balance, 0) + #{availableBalance},
+				available_balance = (
+				case when  IFNULL(available_balance, 0) + #{availableBalance}>0 then  IFNULL(available_balance, 0) + #{availableBalance} else 0 end
+				),
 			</if>
 			<if test="totalBalance != null">
-				total_balance = IFNULL(total_balance, 0) + #{totalBalance},
+				total_balance = (
+				case when  IFNULL(total_balance, 0) + #{totalBalance}>0 then  IFNULL(total_balance, 0) + #{totalBalance} else 0 end
+				),
 			</if>
 			<if test="frozenBalance != null">
-				frozen_balance = IFNULL(frozen_balance, 0) + #{frozenBalance},
+				frozen_balance = (
+				case when  IFNULL(frozen_balance, 0) + #{frozenBalance}>0 then  IFNULL(frozen_balance, 0) + #{frozenBalance} else 0 end
+				),
 			</if>
 		</set>
 		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