From 1410c2c53a44f66a3dd06b5fc3d9e8152a1d4bf1 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 15 Jun 2021 16:32:41 +0800
Subject: [PATCH] modify

---
 src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java
index 13677f2..706d26e 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java
@@ -52,6 +52,7 @@
         if ("1".equals(status)) {
             return Result.fail("无法购买");
         }
+        String total = redisUtils.getString("bzz_coin_total");
 
         MemberEntity loginUser = LoginUserUtils.getAppLoginUser();
         BigDecimal price = new BigDecimal(66);
@@ -60,6 +61,10 @@
         MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(loginUser.getId(), CoinTypeEnum.USDT.name());
         if (amount.compareTo(wallet.getAvailableBalance()) > 0) {
             return Result.fail("可用金额不足");
+        }
+
+        if (Integer.parseInt(total) < gbzAddDto.getCount()) {
+            return Result.fail("BZZ数量不足");
         }
 
         GbzOrderEntity gbzOrder = new GbzOrderEntity();
@@ -73,7 +78,7 @@
         gbzOrderDao.insert(gbzOrder);
 
         memberWalletCoinDao.updateBlockBalance(wallet.getId(), amount.negate(), BigDecimal.ZERO, 0);
-
+        redisUtils.set("bzz_coin_total", Integer.parseInt(total) - gbzAddDto.getCount());
         LogRecordUtils.insertMemberAccountMoneyChange(loginUser.getId(), "购买BZZ", amount, "USDT", 1, 1);
         return Result.ok("购买成功");
     }
@@ -124,6 +129,8 @@
         MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum
                 .BZZ.name());
         memberWalletCoinDao.updateBlockBalance(wallet.getId(), totalAmount, BigDecimal.ZERO, 0);
+
+        gbzOrderDao.updateStatus(member.getId());
         LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取BZZ到资产", totalAmount, "BZZ", 1, 1);
         return Result.ok("提取成功");
     }

--
Gitblit v1.9.1