From a5f55c1fa8b7969de39e3916d669fd4f7bebba7a Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Fri, 05 Jan 2024 11:27:46 +0800
Subject: [PATCH] 团队列表

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java |   68 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 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 1d12048..73143de 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
@@ -699,4 +699,72 @@
         ApiOrderBuyRecordInfoVo apiOrderBuyRecordInfoVo = mallProductBuyRecordMapper.selectByBuyRecordId(productBuyRecordId);
         return new FebsResponse().success().data(apiOrderBuyRecordInfoVo);
     }
+
+    @Override
+    @Transactional
+    public FebsResponse transGfd(ApiTransGfdDto transGfdDto) {
+        Long memberId = LoginUserUtil.getLoginUser().getId();
+        BigDecimal cnt = transGfdDto.getCnt();//兑换数量
+
+        MallMember mallMember = memberMapper.selectById(memberId);
+        String tradePassword = SecureUtil.md5(transGfdDto.getTradePassword());
+        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
+        if(aBoolean){
+            throw new FebsException("用户已冻结");
+        }
+        if(!tradePassword.equals(mallMember.getTradePassword())){
+            throw new FebsException("请输入正确的交易密码");
+        }
+        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
+        Integer type = transGfdDto.getType();
+        String orderNo = MallUtils.getOrderNum("GSD");
+        if(1 == type){//NFT兑换GFD
+            BigDecimal trendsNft = mallMemberAmount.getTrendsNft();
+            if(BigDecimal.ZERO.compareTo(trendsNft) >= 0){
+                throw new FebsException("NFT不足");
+            }
+            if(cnt.compareTo(trendsNft) > 0){
+                throw new FebsException("NFT不足");
+            }
+            mallMemberAmount.setTrendsNft(trendsNft.subtract(cnt));
+            mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(cnt));
+            mallMemberAmountMapper.updateTrendsNftAndGsdById(mallMemberAmount);
+            iMallMoneyFlowService.addMoneyFlow(
+                    memberId,
+                    cnt,
+                    MoneyFlowTypeNewEnum.NFT_GSD.getValue(),
+                    orderNo,
+                    mallMember.getId(),
+                    FlowTypeNewEnum.GSD.getValue(),
+                    MoneyFlowTypeNewEnum.NFT_GSD.getDescrition());
+
+        }
+        if(2 == type){//GFA兑换GFD
+            BigDecimal fcmCntAva = mallMemberAmount.getFcmCntAva();
+            if(BigDecimal.ZERO.compareTo(fcmCntAva) >= 0){
+                throw new FebsException("代币不足");
+            }
+            if(cnt.compareTo(fcmCntAva) > 0){
+                throw new FebsException("代币不足");
+            }
+            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 gsdCnt = fcmPrice.multiply(cnt);
+            mallMemberAmount.setFcmCntAva(fcmCntAva.subtract(cnt));
+            mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(gsdCnt));
+            mallMemberAmountMapper.updateFcmCntAvaAndGsdById(mallMemberAmount);
+            iMallMoneyFlowService.addMoneyFlow(
+                    memberId,
+                    cnt,
+                    MoneyFlowTypeNewEnum.GFA_GSD.getValue(),
+                    orderNo,
+                    mallMember.getId(),
+                    FlowTypeNewEnum.GSD.getValue(),
+                    MoneyFlowTypeNewEnum.GFA_GSD.getDescrition());
+
+        }
+        return new FebsResponse().success();
+    }
 }

--
Gitblit v1.9.1