From 1ce0aef813257a1c8949371fb1fbf3df7a3e87d7 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Thu, 30 Nov 2023 17:01:49 +0800
Subject: [PATCH] 预约列表

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
index ed4476f..1f2f630 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
@@ -281,21 +281,23 @@
         BigDecimal nftFeePercent = ObjectUtil.isEmpty(nftFeeDic) ? new BigDecimal(20) : new BigDecimal(nftFeeDic.getValue());
         nftFeePercent = nftFeePercent.divide(new BigDecimal(100),4,BigDecimal.ROUND_DOWN);
         BigDecimal nftFee = nftCnt.multiply(nftFeePercent);
-        BigDecimal nftCntAva = nftCnt.subtract(nftFee);
-
         DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.FCM_PRICE.getType(),
                 DataDictionaryEnum.FCM_PRICE.getCode());
         BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
         BigDecimal fcmFeeCnt = nftFee.divide(fcmPrice, 2, BigDecimal.ROUND_DOWN);
+        if(BigDecimal.ZERO.compareTo(mallMemberAmount.getTrendsNft()) >= 0
+            || fcmFeeCnt.compareTo(mallMemberAmount.getFcmCntAva()) > 0){
+            throw new FebsException("手续费不足");
+        }
 
         String orderNo = MallUtils.getOrderNum("NFT");
         MallProductSell mallProductSell = new MallProductSell();
         mallProductSell.setMemberId(memberId);
         mallProductSell.setOrderNo(orderNo);
         mallProductSell.setNftTotal(nftCnt);
-        mallProductSell.setNftCnt(nftCntAva);
-        mallProductSell.setNftCntAva(nftCntAva);
+        mallProductSell.setNftCnt(nftCnt);
+        mallProductSell.setNftCntAva(nftCnt);
         mallProductSell.setNftFee(nftFee);
         mallProductSell.setFcmFee(fcmFeeCnt);
         mallProductSell.setState(ProductEnum.PRODUCT_SELL_ON_GOING.getValue());
@@ -309,7 +311,7 @@
         mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmountFcm);
 
         MallMemberAmount mallMemberAmountFrozenNFT = mallMemberAmountMapper.selectByMemberId(memberId);
-        mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCntAva));
+        mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCnt));
         mallMemberAmountMapper.updateFrozenNftById(mallMemberAmountFrozenNFT);
         iMallMoneyFlowService.addMoneyFlow(
                 memberId,
@@ -327,15 +329,6 @@
                 mallMember.getId(),
                 FlowTypeNewEnum.FCM_COIN.getValue(),
                 MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getDescrition());
-        iMallMoneyFlowService.addMoneyFlow(
-                memberId,
-                nftFee.negate(),
-                MoneyFlowTypeNewEnum.NFT_OUT_FEE.getValue(),
-                orderNo,
-                mallMember.getId(),
-                FlowTypeNewEnum.NFT.getValue(),
-                MoneyFlowTypeNewEnum.NFT_OUT_FEE.getDescrition());
-
         agentProducer.sendFcmNFTExchangeMsg(fcmFeeCnt.toString());
         return new FebsResponse().success();
     }

--
Gitblit v1.9.1