From 1bbf36d28d57fcb0b759a60bd8433549d5abe056 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Mon, 14 Nov 2022 22:44:53 +0800
Subject: [PATCH] fix

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 100 insertions(+), 17 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 0aca67d..5e0f05a 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
@@ -19,9 +19,8 @@
 import cc.mrbird.febs.dapp.service.DappSystemService;
 import cc.mrbird.febs.dapp.service.DappWalletService;
 import cc.mrbird.febs.dapp.utils.BoxUtil;
-import cc.mrbird.febs.dapp.vo.ActiveNftListVo;
-import cc.mrbird.febs.dapp.vo.ApiMemberWalletCoinVo;
-import cc.mrbird.febs.dapp.vo.WalletInfoVo;
+import cc.mrbird.febs.dapp.vo.*;
+import cc.mrbird.febs.rabbit.producer.UsdtUpdateProducer;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
@@ -69,6 +68,7 @@
     private final MemberCoinWithdrawDao memberCoinWithdrawDao;
     private final IgtOnHookPlanOrderItemDao igtOnHookPlanOrderItemdao;
     private final DappBankDao dappBankDao;
+    private final UsdtUpdateProducer usdtUpdateProducer;
 
     private final RedisTemplate<String, Object> redisTemplate;
 
@@ -628,9 +628,55 @@
         memberCoinWithdrawEntity.setFeeAmount(BigDecimal.ZERO);
         memberCoinWithdrawEntity.setSymbol("USDT");
         memberCoinWithdrawEntity.setMemberId(memberIdOut);
-        memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING);
+        memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES);
         memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES);
         memberCoinWithdrawDao.insert(memberCoinWithdrawEntity);
+
+//        usdtUpdateProducer.sendMemberCoinInside(memberCoinWithdrawEntity.getId());
+        //转出账户,总额减少,冻结减少
+        dappWalletCoinDao.delTotalAndDelFrozenById(dappWalletCoinEntityOut.getId(),balance);
+
+        String isInside = memberCoinWithdrawEntity.getIsInside();
+        String content = "";
+        Integer type = 0;
+        if(MemberCoinWithdrawEntity.ISINSIDE_NO.equals(isInside)){
+            content = "提现";
+            type = 2;
+        }else{
+            content = "转账";
+            type = 4;
+        }
+        //转出账户生成一条账户资金变化记录
+        DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityOut = new DappAccountMoneyChangeEntity(memberIdOut,
+                dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+                balance.negate(),
+                dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).subtract(balance),
+                content,
+                type);
+        dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityOut);
+
+        //转入账户,总额增加,余额增加
+        //转账
+        if(MemberCoinWithdrawEntity.ISINSIDE_YES.equals(isInside)){
+            String addressIn = memberCoinWithdrawEntity.getAddress();
+            DappMemberEntity dappMemberEntityIn = dappMemberDao.selectMemberInfoByInviteId(addressIn);
+            if(ObjectUtil.isEmpty(dappMemberEntityIn)){
+                throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+            }
+            DappWalletCoinEntity dappWalletCoinEntityIn = dappWalletCoinDao.selectByMemberId(dappMemberEntityIn.getId());
+            Integer countIn = dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntityIn.getId(), memberCoinWithdrawEntity.getAmount());
+            if(1 != countIn){
+                throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+            }
+            //生成流水记录
+            DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityIn = new DappAccountMoneyChangeEntity(dappMemberEntityIn.getId(),
+                    dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+                    balance,
+                    dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).add(balance),
+                    "转账",
+                    4);
+            dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityIn);
+        }
         return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
     }
 
@@ -901,7 +947,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_IB.getId(),multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_IB.getId(), multiply, "盈利分成", 8,id);
+                            dappMemberEntityLEVEL_IB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply),"盈利分成", 8,id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -921,7 +968,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_FIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_FIB.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_FIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -942,7 +990,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_CIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_CIB.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_CIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -965,7 +1014,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_AIB.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -990,7 +1040,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_GIB.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1017,7 +1068,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_BP.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1046,7 +1098,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_SP.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1077,7 +1130,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_GP.getId(), multiply, "盈利分成", 8, id);
+                            dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1096,7 +1150,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_AIB.getId(), multiply, "流水佣金", 7, id);
+                            dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1111,7 +1166,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_GIB.getId(), multiply, "流水佣金", 7, id);
+                            dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1126,7 +1182,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_BP.getId(), multiply, "流水佣金", 7, id);
+                            dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1141,7 +1198,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_SP.getId(), multiply, "流水佣金", 7, id);
+                            dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1156,7 +1214,8 @@
                 if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
                     dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
                     DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                            dappMemberEntityLEVEL_GP.getId(), multiply, "流水佣金", 7, id);
+                            dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
                     dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
                     profitSharingTotal = profitSharingTotal.add(multiply);
                 }
@@ -1191,6 +1250,30 @@
         }
     }
 
+    private final MemberCoinChargeDao memberCoinChargeDao;
+
+    @Override
+    public IPage<AdminMoneyTotalVo> moneyTotal(DappAccountMoneyChangeEntity record, QueryRequest request) {
+        Page<DappAccountMoneyChangeEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
+        //获取充值提现的所有日期
+        IPage<AdminMoneyTotalVo> adminMoneyTotalVoIPage = dappAccountMoneyChangeDao.selectMoneyTotalInPage(record, page);
+        List<AdminMoneyTotalVo> records = adminMoneyTotalVoIPage.getRecords();
+        if(CollUtil.isNotEmpty(records)){
+            for(AdminMoneyTotalVo adminMoneyTotalVo : records){
+                Date createTime = adminMoneyTotalVo.getCreateTime();
+                //每日充值统计
+                AdminMemberChargeVo adminMemberChargeVos = memberCoinChargeDao.selectTotalAmountByCreateTimeAndInviteId(createTime,record.getDescription());
+                adminMoneyTotalVo.setTotalCharge(adminMemberChargeVos.getTotalCharge().setScale(2,BigDecimal.ROUND_DOWN));
+                adminMoneyTotalVo.setSheetIn(adminMemberChargeVos.getSheetIn());
+                //每日提现统计
+                AdminMemberWithdrawVo adminMemberWithdrawVo = memberCoinWithdrawDao.selectTotalAmountByCreateTimeAndInviteId(createTime,record.getDescription());
+                adminMoneyTotalVo.setTotalWithdraw(adminMemberWithdrawVo.getTotalWithdraw().setScale(2,BigDecimal.ROUND_DOWN));
+                adminMoneyTotalVo.setSheetOut(adminMemberWithdrawVo.getSheetOut());
+            }
+        }
+        return adminMoneyTotalVoIPage;
+    }
+
     public static void main(String[] args) {
 
         DateTime date = DateUtil.date();

--
Gitblit v1.9.1