From 03bd618f5f3055f0a558a65b28a67fd604b27a1e Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sat, 22 Oct 2022 23:49:46 +0800
Subject: [PATCH] fxi

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |   63 ++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
index b97b157..5d0d33e 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -65,6 +65,7 @@
     private final DappNftActivationDao dappNftActivationDao;
     private final DappMemberService dappMemberService;
     private final MemberCoinWithdrawDao memberCoinWithdrawDao;
+    private final IgtOnHookPlanOrderItemDao igtOnHookPlanOrderItemdao;
 
     private final RedisTemplate<String, Object> redisTemplate;
 
@@ -563,15 +564,8 @@
             return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
         }
         //判断内部转账规则
-        DataDictionaryCustom withdrawTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_TIMES.getType(), DataDictionaryEnum.WITHDRAW_TIMES.getCode());
-//
-//        DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
-//        //todo 获取用户的总收益
-//        BigDecimal totalProfitOut = new BigDecimal("0.3");
-//        BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
-//        if(outAccountProfit.compareTo(totalProfitOut) > 0){
-//            return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
-//        }
+
+
         DataDictionaryCustom accountRelationDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.ACCOUNT_RELATION.getType(), DataDictionaryEnum.ACCOUNT_RELATION.getCode());
         Integer accountRelation = Integer.parseInt(accountRelationDic.getValue());
         if(1 == accountRelation){
@@ -580,14 +574,36 @@
                 return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_005"));
             }
         }
-//        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SERVICE_FEE.getType(), DataDictionaryEnum.SERVICE_FEE.getCode());
-//        Integer serviceFee = Integer.parseInt(serviceFeeDic.getValue());
         //查询转出会员
         //转出会员当前余额要大于等于划转金额
         DappWalletCoinEntity dappWalletCoinEntityOut = dappWalletCoinDao.selectByMemberId(memberIdOut);
         BigDecimal availableAmountOut = dappWalletCoinEntityOut.getAvailableAmount().setScale(4,BigDecimal.ROUND_DOWN);
         if(availableAmountOut.compareTo(balance) < 0){
             return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_002"));
+        }
+        /**
+         * 提取金额小于收益,则不受限制
+         * 否则,计算收益占本金的比例。符合条件允许提现
+         */
+        //获取用户的总收益
+        BigDecimal totalProfitOut = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberIdOut,1,2);
+        if(balance.compareTo(totalProfitOut) > 0){
+            BigDecimal totalAmount = dappWalletCoinEntityOut.getTotalAmount();
+            //用户总收益率
+            BigDecimal divide = totalProfitOut.divide(totalAmount);
+            //提现条件收益率
+            DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
+            BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
+            if(divide.compareTo(outAccountProfit) < 0){
+                return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+            }
+        }
+        //提现次数
+        DataDictionaryCustom withdrawTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_TIMES.getType(), DataDictionaryEnum.WITHDRAW_TIMES.getCode());
+        Integer withdrawTimes = Integer.parseInt(withdrawTimesDic.getValue());
+        Integer withdrawTimesReal = memberCoinWithdrawDao.selectByMemberIdAndCreateTime(memberIdOut,DateUtil.format(DateUtil.date(),"yyyy-MM-dd"));
+        if(withdrawTimesReal >= withdrawTimes){
+            return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
         }
         //转出账户,余额减少,冻结增加
         Integer countOut = dappWalletCoinDao.addFrozenAndDelAvailableById(dappWalletCoinEntityOut.getId(), balance);
@@ -662,14 +678,25 @@
         if(!aBoolean){
             return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
         }
-        //提现条件收益率
-        DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
-        //todo 获取用户的总收益
-        BigDecimal totalProfitOut = new BigDecimal("0.3");
-        BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
-        if(outAccountProfit.compareTo(totalProfitOut) > 0){
-            return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+
+        /**
+         * 提取金额小于收益,则不受限制
+         * 否则,计算收益占本金的比例。符合条件允许提现
+         */
+        //获取用户的总收益
+        BigDecimal totalProfit = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberId,1,2);
+        if(balance.compareTo(totalProfit) >= 0){
+            BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount();
+            //用户总收益率
+            BigDecimal divide = totalProfit.divide(totalAmount);
+            //提现条件收益率
+            DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
+            BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
+            if(divide.compareTo(outAccountProfit) < 0){
+                return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+            }
         }
+
         //余额减少冻结增加
         Integer count = dappWalletCoinDao.addFrozenAndDelAvailableById(memberId, balance);
         if(1 != count){

--
Gitblit v1.9.1