From ff6b4ca2a45e57df38f5d6e5f55456854f7d455c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 02 Dec 2022 14:09:43 +0800
Subject: [PATCH] 20221130

---
 src/main/resources/templates/febs/views/dapp/member.html                    |   26 +++++---
 src/main/java/cc/mrbird/febs/dapp/vo/AdminSystemProfitFlowListVo.java       |    2 
 src/main/resources/mapper/dapp/DappFundFlowDao.xml                          |    6 ++
 src/main/resources/templates/febs/views/dapp/member-teamInfo.html           |    2 
 src/main/resources/templates/febs/views/dapp/system-profit.html             |    8 ++
 src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java |   30 ++++++++-
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java   |   18 +++++
 src/main/resources/templates/febs/views/dapp/system-profit-flow.html        |    1 
 src/main/resources/templates/febs/views/dapp/money-change-flow.html         |   45 +++++++++++++-
 src/main/resources/mapper/dapp/DappSystemProfitDao.xml                      |    4 +
 src/main/java/cc/mrbird/febs/dapp/entity/DappMemberEntity.java              |   19 ++++++
 11 files changed, 139 insertions(+), 22 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java b/src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java
index 5d085b1..ef4b1fe 100644
--- a/src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java
+++ b/src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java
@@ -1,20 +1,23 @@
 package cc.mrbird.febs.dapp.controller;
 
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.controller.BaseController;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.common.utils.FebsUtil;
 import cc.mrbird.febs.dapp.entity.DappAccountMoneyChangeEntity;
 import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
+import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
 import cc.mrbird.febs.dapp.service.DappWalletService;
+import cc.mrbird.febs.rabbit.producer.ChainProducer;
 import cc.mrbird.febs.system.entity.User;
+import cn.hutool.core.util.ObjectUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.constraints.NotNull;
 
 /**
  * @author 
@@ -28,6 +31,8 @@
 public class MemberMoneyFlowController extends BaseController {
 
     private final DappWalletService dappWalletService;
+    private final DappFundFlowDao dappFundFlowDao;
+    private final ChainProducer chainProducer;
 
     @RequestMapping(value = "/fundFlow")
     public FebsResponse fundFlow(DappFundFlowEntity dappFundFlowEntity, QueryRequest request) {
@@ -42,4 +47,21 @@
     public FebsResponse accountMoneyChangeFlow(DappAccountMoneyChangeEntity record, QueryRequest request) {
         return new FebsResponse().success().data(getDataTable(dappWalletService.accountMoneyChangeInPage(record, request)));
     }
+
+    /**
+     * 流水管理-手动转账
+     */
+    @GetMapping("transferManual/{id}")
+    @ControllerEndpoint(operation = "版本管理---删除", exceptionMessage = "删除失败")
+    public FebsResponse transferManual(@NotNull(message = "{required}") @PathVariable Long id) {
+        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id);
+        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
+            return new FebsResponse().fail().message("数据不存在");
+        }
+        if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == dappFundFlowEntity.getStatus()){
+            return new FebsResponse().fail().message("已转账,无法再次操作");
+        }
+        chainProducer.sendBnbTransferMsg(id);
+        return new FebsResponse().success().message("操作成功,请稍后查看");
+    }
 }
diff --git a/src/main/java/cc/mrbird/febs/dapp/entity/DappMemberEntity.java b/src/main/java/cc/mrbird/febs/dapp/entity/DappMemberEntity.java
index bfb0b1b..c827265 100644
--- a/src/main/java/cc/mrbird/febs/dapp/entity/DappMemberEntity.java
+++ b/src/main/java/cc/mrbird/febs/dapp/entity/DappMemberEntity.java
@@ -5,6 +5,7 @@
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.web3j.abi.datatypes.Int;
 
@@ -92,4 +93,22 @@
 
     @TableField(exist = false)
     private BigDecimal availableAmount;
+
+    @ApiModelProperty(value = "直推奖金(直推收益)")
+
+    @TableField(exist = false)
+    private BigDecimal directProfit;
+
+    @ApiModelProperty(value = "平级奖金(层级收益)")
+
+    @TableField(exist = false)
+    private BigDecimal levelProfit;
+
+    @ApiModelProperty(value = "幸运奖金(动能收益)")
+
+    @TableField(exist = false)
+    private BigDecimal luckyProfit;
+
+    @TableField(exist = false)
+    private Long systemProfitId;
 }
diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
index 42c051f..17ae581 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
@@ -201,7 +201,23 @@
         if (currentUser.getDeptId() == null) {
             member.setCurrentUser(currentUser.getUserId());
         }
-        return dappMemberDao.selectInPage(member, page);
+        IPage<DappMemberEntity> dappMemberEntityIPage = dappMemberDao.selectInPage(member, page);
+        List<DappMemberEntity> records = dappMemberEntityIPage.getRecords();
+        if(CollUtil.isNotEmpty(records)){
+            for(DappMemberEntity memberEntity : records){
+                Long memberId = memberEntity.getId();
+
+                DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberId,DappSystemProfit.STATE_IN);
+                memberEntity.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId());
+                BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2);
+                memberEntity.setDirectProfit(directProfit);
+                BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,4,2);
+                memberEntity.setLevelProfit(levelProfit);
+                BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,7,2);
+                memberEntity.setLuckyProfit(luckyProfit);
+            }
+        }
+        return dappMemberEntityIPage;
     }
 
     @Override
diff --git a/src/main/java/cc/mrbird/febs/dapp/vo/AdminSystemProfitFlowListVo.java b/src/main/java/cc/mrbird/febs/dapp/vo/AdminSystemProfitFlowListVo.java
index efb4213..c16da67 100644
--- a/src/main/java/cc/mrbird/febs/dapp/vo/AdminSystemProfitFlowListVo.java
+++ b/src/main/java/cc/mrbird/febs/dapp/vo/AdminSystemProfitFlowListVo.java
@@ -20,4 +20,6 @@
     private Integer status;
 
     private Integer type;
+
+    private String fromHash;
 }
diff --git a/src/main/resources/mapper/dapp/DappFundFlowDao.xml b/src/main/resources/mapper/dapp/DappFundFlowDao.xml
index fee7713..f8ed207 100644
--- a/src/main/resources/mapper/dapp/DappFundFlowDao.xml
+++ b/src/main/resources/mapper/dapp/DappFundFlowDao.xml
@@ -21,6 +21,12 @@
             <if test="record.memberId != null">
                 and a.member_id=#{record.memberId}
             </if>
+            <if test="record.fromHash != '' and record.fromHash != null">
+                and a.from_hash = #{record.fromHash}
+            </if>
+            <if test="record.systemProfitId != '' and record.systemProfitId != null">
+                and a.system_profit_id = #{record.systemProfitId}
+            </if>
         </where>
         order by a.create_time desc, a.id desc
     </select>
diff --git a/src/main/resources/mapper/dapp/DappSystemProfitDao.xml b/src/main/resources/mapper/dapp/DappSystemProfitDao.xml
index 295147f..44434cf 100644
--- a/src/main/resources/mapper/dapp/DappSystemProfitDao.xml
+++ b/src/main/resources/mapper/dapp/DappSystemProfitDao.xml
@@ -66,6 +66,9 @@
              dapp_system_profit a
         inner join dapp_member b on a.member_id = b.id
         <where>
+            <if test="record.id != '' and record.id != null">
+                and a.id = #{record.id}
+            </if>
             <if test="record.address != '' and record.address != null">
                 and b.address = #{record.address}
             </if>
@@ -81,6 +84,7 @@
         a.create_time createTime,
         a.amount amount,
         a.status status,
+        a.from_hash fromHash,
         a.type type,
         b.address address
         from
diff --git a/src/main/resources/templates/febs/views/dapp/member-teamInfo.html b/src/main/resources/templates/febs/views/dapp/member-teamInfo.html
index 0200fd6..cc3b67f 100644
--- a/src/main/resources/templates/febs/views/dapp/member-teamInfo.html
+++ b/src/main/resources/templates/febs/views/dapp/member-teamInfo.html
@@ -32,7 +32,7 @@
                     {field: 'address', title: '地址', minWidth: 100, totalRowText: '合计'},
                     {field: 'accountType', title: '代理级别', minWidth: 100,},
                     {field: 'activeStatus', title: '是否加入动能', minWidth: 100},
-                    {field: 'systemProfitId', title: '编号', minWidth: 100},
+                    {field: 'systemProfitId', title: '动能编号', minWidth: 100},
                     {field: 'directCnt', title: '直推数量', minWidth: 100, totalRow: true},
                     {field: 'directProfit', title: '直推收益', minWidth: 100, totalRow: true},
                     {field: 'levelProfit', title: '层级收益', minWidth: 100, totalRow: true},
diff --git a/src/main/resources/templates/febs/views/dapp/member.html b/src/main/resources/templates/febs/views/dapp/member.html
index 6237c3e..f64ee09 100644
--- a/src/main/resources/templates/febs/views/dapp/member.html
+++ b/src/main/resources/templates/febs/views/dapp/member.html
@@ -119,11 +119,7 @@
 <!--    {{# } }}-->
 <!--</script>-->
 <script type="text/html" id="approve-list">
-    {{# if(d.activeStatus == '1') { }}
     <a href="https://bscscan.com/address/{{d.address}}" target="_blank">{{d.address}}</a>
-    {{# } else { }}
-    <span>未加入</span>
-    {{# } }}
 </script>
 <script type="text/html" id="member-option">
     {{#
@@ -257,22 +253,30 @@
                 elem: $view.find('table'),
                 id: 'memberTable',
                 url: ctx + 'member/list',
+                totalRow: true,
                 cols: [[
                     // {type: 'checkbox'},
                     // {type: 'numbers'},
                     {title: '代理级别',
                         templet: function (d) {
                             return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="teamInfo" shiro:hasPermission="teamInfo:view"><span>'+d.accountType+'</span></button>'
-                        },minWidth: 130,align:'center'},
-                    {field: 'address', title: '地址', minWidth: 400},
+                        },minWidth: 130,align:'center', totalRowText: '合计'},
+                    {title: '地址', templet: '#approve-list', minWidth: 400},
                     {field: 'chainType', title: '所属链', minWidth: 130},
-                    {title: '是否加入动能', templet: '#approve-list', minWidth: 350},
+                    {field: 'activeStatus', title: '加入动能',
+                        templet: function (d) {
+                            if (d.activeStatus === 1) {
+                                return '<span style="color:green;">'+d.systemProfitId+'</span>'
+                            } else{
+                                return ''
+                            }
+                        }, minWidth: 80,align:'center'},
+                    {field: 'directProfit', title: '直推收益', minWidth: 100, totalRow: true},
+                    {field: 'levelProfit', title: '层级收益', minWidth: 100, totalRow: true},
+                    {field: 'luckyProfit', title: '动能收益', minWidth: 100, totalRow: true},
                     {field: 'inviteId', title: '邀请码', minWidth: 100},
                     {field: 'refererId', title: '上级邀请码', minWidth: 100},
-                    // {title: '账户状态', templet: '#user-status', minWidth: 100},
-                    // {title: '是否可提现', templet: '#withdraw-able', minWidth: 100},
-                    {field: 'createTime', title: '创建时间', minWidth: 180},
-                    // {title: '操作', toolbar: '#member-option', minWidth: 300}
+                    {field: 'createTime', title: '创建时间', minWidth: 180}
                 ]]
             });
         }
diff --git a/src/main/resources/templates/febs/views/dapp/money-change-flow.html b/src/main/resources/templates/febs/views/dapp/money-change-flow.html
index c8db166..f4484c4 100644
--- a/src/main/resources/templates/febs/views/dapp/money-change-flow.html
+++ b/src/main/resources/templates/febs/views/dapp/money-change-flow.html
@@ -9,7 +9,17 @@
                                 <div class="layui-form-item">
                                     <div class="layui-inline">
                                         <div class="layui-input-inline">
+                                            <input type="text" name="systemProfitId" autocomplete="off" placeholder="输入动能编号" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-inline">
+                                        <div class="layui-input-inline">
                                             <input type="text" name="address" autocomplete="off" placeholder="输入地址" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-inline">
+                                        <div class="layui-input-inline">
+                                            <input type="text" name="fromHash" autocomplete="off" placeholder="输入FromHash" class="layui-input">
                                         </div>
                                     </div>
                                     <div class="layui-inline">
@@ -127,7 +137,24 @@
         table.on('tool(moneyChangeTable)', function (obj) {
             var data = obj.data,
                 layEvent = obj.event;
+            if (layEvent === 'transferManual') {
+                febs.modal.confirm('人工操作', '是否人工转账?', function () {
+                    transferManual("flow/withdrawAgree/" + data.id);
+                });
+            }
+            if (layEvent === 'transferManual') {
+                febs.modal.confirm('人工操作', '是否人工转账?', function () {
+                    transferManual(data.id);
+                });
+            }
         });
+
+        function transferManual(id) {
+            febs.get(ctx + 'flow/transferManual/' + id, null, function () {
+                febs.alert.success('操作成功');
+                $reset.click();
+            });
+        }
 
         table.on('sort(moneyChangeTable)', function (obj) {
             sortObject = obj;
@@ -156,7 +183,8 @@
                 id: 'moneyChangeTable',
                 url: ctx + 'flow/fundFlow',
                 cols: [[
-                    {field: 'address', title: '地址', minWidth: 380},
+                    {field: 'address', title: '地址', minWidth: 400},
+                    {field: 'systemProfitId', title: '动能编号', minWidth: 100},
                     {title: '类型', minWidth: 100,templet: '#flow-type',align:'center'},
                     {field: 'amount', title: '金额',
                         templet: function (d) {
@@ -168,18 +196,27 @@
                                 return d.amount
                             }
                         }, minWidth: 80,align:'center'},
-                    {field: 'fee', title: '手续费', minWidth: 80},
+                    // {field: 'fee', title: '手续费', minWidth: 80},
                     {field: 'createTime', title: '创建时间', minWidth: 150},
                     {title: '状态', templet: '#status-able', minWidth: 80},
-                    {field: 'fromHash', title: 'fromHash', minWidth: 150},
-                    {field: 'toHash', title: 'toHash', minWidth: 150},
+                    {field: 'fromHash', title: 'FromHash', minWidth: 150},
+                    {title: '操作',
+                        templet: function (d) {
+                            if(d.status == 3){
+                                return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="transferManual" shiro:hasPermission="transferManual:update">手动转账</button>'
+                            }else{
+                                return ''
+                            }
+                        },minWidth: 100,align:'center'}
                 ]]
             });
         }
 
         function getQueryParams() {
             return {
+                systemProfitId: $searchForm.find('input[name="systemProfitId"]').val().trim(),
                 address: $searchForm.find('input[name="address"]').val().trim(),
+                fromHash: $searchForm.find('input[name="fromHash"]').val().trim(),
                 type: $searchForm.find("select[name='type']").val(),
                 // accountStatus: $searchForm.find("select[name='accountStatus']").val(),
                 // withdrawAble: $searchForm.find("input[name='withdrawAble']").val(),
diff --git a/src/main/resources/templates/febs/views/dapp/system-profit-flow.html b/src/main/resources/templates/febs/views/dapp/system-profit-flow.html
index c0bc018..20ab378 100644
--- a/src/main/resources/templates/febs/views/dapp/system-profit-flow.html
+++ b/src/main/resources/templates/febs/views/dapp/system-profit-flow.html
@@ -59,6 +59,7 @@
                 cols: [[
                     {field: 'address', title: '地址', minWidth: 300},
                     {field: 'amount', title: '金额', minWidth: 80},
+                    {field: 'fromHash', title: 'hash', minWidth: 150},
                     {title: '状态', templet: '#status-able', minWidth: 80},
                     {title: '类型', templet: '#type-able', minWidth: 80},
                     {field: 'createTime', title: '创建时间', minWidth: 150}
diff --git a/src/main/resources/templates/febs/views/dapp/system-profit.html b/src/main/resources/templates/febs/views/dapp/system-profit.html
index b756efd..3a2c7e2 100644
--- a/src/main/resources/templates/febs/views/dapp/system-profit.html
+++ b/src/main/resources/templates/febs/views/dapp/system-profit.html
@@ -9,6 +9,11 @@
                                 <div class="layui-form-item">
                                     <div class="layui-inline">
                                         <div class="layui-input-inline">
+                                            <input type="text" name="id" autocomplete="off" placeholder="输入动能编号"  class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-inline">
+                                        <div class="layui-input-inline">
                                             <input type="text" name="address" autocomplete="off" placeholder="输入地址"  class="layui-input">
                                         </div>
                                     </div>
@@ -122,7 +127,7 @@
                 id: 'systemProfitTable',
                 url: ctx + 'member/systemProfitList',
                 cols: [[
-                    {field: 'id', title: '序列号', minWidth: 400},
+                    {field: 'id', title: '动能编号', minWidth: 400},
                     {field: 'address', title: '地址', minWidth: 400},
                     {field: 'amount', title: '金额', minWidth: 130},
                     {title: '状态', templet: '#state-able', minWidth: 100},
@@ -137,6 +142,7 @@
 
         function getQueryParams() {
             return {
+                id: $searchForm.find('input[name="id"]').val().trim(),
                 address: $searchForm.find('input[name="address"]').val().trim(),
                 state: $searchForm.find("select[name='state']").val()
             };

--
Gitblit v1.9.1