| | |
| | | * 0x55d398326f99059fF775485246999027B3197955 |
| | | * 测试链 0x337610d27c682E347C9cD60BD4b3b107C9d34dDd |
| | | */ |
| | | BSC_USDT("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | BSC_USDT("BSC", "0xE09705E2D5283ee4b74182Ed5906D30E3b0D5fa8", |
| | | "a922d1900a99e883c5ca684ea479a81f2c7de6b8efde7e81b3877ff056221460", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x6c6835e60e7dBaD7a60112a6371271e8eb79ee68", |
| | | "0x55d398326f99059fF775485246999027B3197955", |
| | | ""), |
| | | |
| | | /** |
| | |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x46ac4921e58773ca22826df1640672b91b1db2b3", |
| | | ""), |
| | | BSC_GFA("BSC", "0x977a9ddfb965a9a3416fa72ca7f91c4949c18f25", |
| | | "0xefe98e00cd227b6322e892c82fcbd8eadf119c3188b7e574bc624f65405d61bf", |
| | | BSC_GFA("BSC", "0xE09705E2D5283ee4b74182Ed5906D30E3b0D5fa8", |
| | | "a922d1900a99e883c5ca684ea479a81f2c7de6b8efde7e81b3877ff056221460", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0xaC97ff8173c41b83111b411A3Fa62D7C6ff385be", |
| | | ""), |
| | |
| | | } |
| | | |
| | | public String getGas() { |
| | | String gas; |
| | | if (url.contains("infura.io")) { |
| | | String resp = HttpUtil.get("https://etherscan.io/autoUpdateGasTracker.ashx?sid=75f30b765180f29e2b7584b8501c9124"); |
| | | JSONObject data = JSONObject.parseObject(resp); |
| | | gas = data.getString("avgPrice"); |
| | | } else { |
| | | String resp = HttpUtil.get("https://gbsc.blockscan.com/gasapi.ashx?apikey=key&method=gasoracle"); |
| | | JSONObject data = JSONObject.parseObject(resp); |
| | | gas = data.getString("FastGasPrice"); |
| | | } |
| | | String gas = "1"; |
| | | // String gas; |
| | | // if (url.contains("infura.io")) { |
| | | // String resp = HttpUtil.get("https://etherscan.io/autoUpdateGasTracker.ashx?sid=75f30b765180f29e2b7584b8501c9124"); |
| | | // JSONObject data = JSONObject.parseObject(resp); |
| | | // gas = data.getString("avgPrice"); |
| | | // } else { |
| | | // String resp = HttpUtil.get("https://gbsc.blockscan.com/gasapi.ashx?apikey=key&method=gasoracle"); |
| | | // JSONObject data = JSONObject.parseObject(resp); |
| | | // gas = data.getString("FastGasPrice"); |
| | | // } |
| | | return StrUtil.isBlank(gas) ? "35" : gas; |
| | | } |
| | | |
| | |
| | | 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.dapp.entity.DappAccountMoneyChangeEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappAchieve; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.service.AsyncCjService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | public class MemberMoneyFlowController extends BaseController { |
| | | |
| | | private final DappWalletService dappWalletService; |
| | | private final DappFundFlowDao dappFundFlowDao; |
| | | private final AsyncCjService asyncCjService; |
| | | |
| | | @GetMapping("/dappAchieveItem") |
| | | public FebsResponse dappAchieveItem(QueryRequest request, DappAchieve dappAchieve, Integer parentId) { |
| | |
| | | return new FebsResponse().success().data(getDataTable(dappWalletService.fundFlowInPage(dappFundFlowEntity, request))); |
| | | } |
| | | |
| | | @GetMapping("confirmOrder") |
| | | @ControllerEndpoint(operation = "批量转账", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmOrder(DappFundFlowEntity dappFundFlowIn){ |
| | | String orderIds = dappFundFlowIn.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId); |
| | | if(1 != dappFundFlowEntity.getStatus()){ |
| | | continue; |
| | | } |
| | | asyncCjService.confirmOrder(dappFundFlowEntity); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("confirmCancel") |
| | | @ControllerEndpoint(operation = "取消", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmCancel(DappFundFlowEntity dappFundFlowIn){ |
| | | String orderIds = dappFundFlowIn.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId); |
| | | if(1 != dappFundFlowEntity.getStatus()){ |
| | | continue; |
| | | } |
| | | asyncCjService.confirmCancel(dappFundFlowEntity); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @PostMapping(value = "/withdrawAgree/{id}") |
| | | public FebsResponse withdrawAgree(@PathVariable("id") Long id) { |
| | | dappWalletService.withdrawAgreeOrNot(id, 1); |
| | |
| | | private BigDecimal targetAmount; |
| | | |
| | | private String content; |
| | | |
| | | @TableField(exist = false) |
| | | private String orderIds; |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsConstant; |
| | | import cc.mrbird.febs.dapp.entity.DappAchieve; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | |
| | |
| | | |
| | | @Async(FebsConstant.ASYNC_POOL) |
| | | void tradeProfitDistribute(); |
| | | |
| | | @Async(FebsConstant.ASYNC_POOL) |
| | | void confirmOrder(DappFundFlowEntity dappFundFlowEntity); |
| | | |
| | | @Async(FebsConstant.ASYNC_POOL) |
| | | void confirmCancel(DappFundFlowEntity dappFundFlowEntity); |
| | | } |
| | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.AsyncCjService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | teamHdPerk(teamPercent,divideEveryUsdt,divideEveryCoin); |
| | | } |
| | | |
| | | @Override |
| | | public void confirmOrder(DappFundFlowEntity dappFundFlow) { |
| | | Long id = dappFundFlow.getId(); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | Integer status = dappFundFlowEntity.getStatus(); |
| | | if(1 != status){ |
| | | return; |
| | | } |
| | | Integer type = dappFundFlowEntity.getType(); |
| | | BigDecimal amount = dappFundFlowEntity.getAmount().negate(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >=0){ |
| | | amount = amount.negate(); |
| | | } |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(FlowTypeEnum.USDT_OUT.getValue() == type){ |
| | | //USDT转账 |
| | | String transfer = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(dappMemberEntity.getAddress(), amount); |
| | | int retryTime = 0;//重试次数 |
| | | while (StrUtil.isEmpty(transfer)) { |
| | | // 休眠2s |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(retryTime < 3){ |
| | | transfer = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(dappMemberEntity.getAddress(), amount); |
| | | } |
| | | retryTime ++ ; |
| | | } |
| | | if(StrUtil.isNotEmpty(transfer)){ |
| | | dappFundFlowEntity.setFromHash(transfer); |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | }else{ |
| | | dappFundFlowEntity.setStatus(1); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | } |
| | | }else if(FlowTypeEnum.DAI_BI_OUT.getValue() == type){ |
| | | //代币转账 |
| | | String transfer = ChainService.getInstance(ChainEnum.BSC_GFA.name()).transfer(dappMemberEntity.getAddress(), amount); |
| | | if(StrUtil.isNotEmpty(transfer)){ |
| | | dappFundFlowEntity.setFromHash(transfer); |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | }else{ |
| | | dappFundFlowEntity.setStatus(1); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | } |
| | | }else{ |
| | | return; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void confirmCancel(DappFundFlowEntity dappFundFlow) { |
| | | Long id = dappFundFlow.getId(); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | Integer status = dappFundFlowEntity.getStatus(); |
| | | if(1 != status){ |
| | | return; |
| | | } |
| | | Integer type = dappFundFlowEntity.getType(); |
| | | BigDecimal amount = dappFundFlowEntity.getAmount().negate(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >=0){ |
| | | amount = amount.negate(); |
| | | } |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_DISAGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | if(FlowTypeEnum.USDT_OUT.getValue() == type){ |
| | | dappMemberEntity.setUsdtBalance(dappMemberEntity.getUsdtBalance().add(amount)); |
| | | dappMemberDao.updateUsdtBalanceWithVersion(dappMemberEntity); |
| | | }else if(FlowTypeEnum.DAI_BI_OUT.getValue() == type){ |
| | | dappMemberEntity.setBalance(dappMemberEntity.getBalance().add(amount)); |
| | | dappMemberDao.updateBalanceWithVersion(dappMemberEntity); |
| | | }else{ |
| | | return; |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String transfer = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer("0xCEBfd36e03BD80c7015Cbad17eFfBc33d2923FF3", new BigDecimal("0.1")); |
| | | // BigInteger bigInteger = org.web3j.utils.Convert.toWei("35", org.web3j.utils.Convert.Unit.GWEI).toBigInteger(); |
| | | // System.out.println(bigInteger); |
| | | } |
| | | |
| | | public void teamHdPerk(int teamPercent,BigDecimal divideEveryUsdt,BigDecimal divideEveryCoin){ |
| | | //3%用于团队业绩计算 |
| | | BigDecimal teamPercentMultiply = new BigDecimal(teamPercent); |
| | |
| | | // DataDicEnum.GFA_COIN.getValue(), |
| | | // 1); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String format = StrUtil.format(FlowTypeEnum.HUA_DIAN_GEREN.getDescrition(), 100); |
| | | System.out.println(format); |
| | | } |
| | | |
| | | /** |
| | |
| | | <a lay-event="disagree" shiro:hasPermission="withdraw:disagree">审核驳回</a> |
| | | {{# } }} |
| | | </script> |
| | | |
| | | <script type="text/html" id="tableToolBarOrderDB"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="confirmOrderDB">提现确认</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="confirmCancelDB">提现取消</button> |
| | | </div> |
| | | </script> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () { |
| | | var $ = layui.jquery, |
| | |
| | | form.render(); |
| | | |
| | | initTable(); |
| | | |
| | | table.on('toolbar(withdrawDbTable)', function(obj){ |
| | | var event = obj.event; |
| | | var id = obj.config.id; |
| | | var checkStatus = table.checkStatus(id); |
| | | if(event === 'confirmOrderDB'){ |
| | | var data = checkStatus.data; |
| | | let ids = ""; |
| | | let totalAmount = 0; |
| | | for(let i = 0;i < data.length;i++){ |
| | | if(data[i].status != 1){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | }else{ |
| | | ids = ids + data[i].id+","; |
| | | totalAmount = totalAmount + data[i].amount; |
| | | } |
| | | } |
| | | if(ids == null || ids == ""){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | } |
| | | |
| | | febs.modal.confirm('代币提现', '总额为:'+totalAmount, function () { |
| | | confirmOrderDB(ids); |
| | | }); |
| | | } |
| | | if(event === 'confirmCancelDB'){ |
| | | var data = checkStatus.data; |
| | | let ids = ""; |
| | | let totalAmount = 0; |
| | | for(let i = 0;i < data.length;i++){ |
| | | if(data[i].status != 1){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | }else{ |
| | | ids = ids + data[i].id+","; |
| | | totalAmount = totalAmount + data[i].amount; |
| | | } |
| | | } |
| | | if(ids == null || ids == ""){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | } |
| | | |
| | | febs.modal.confirm('提现取消', '总额为:'+totalAmount, function () { |
| | | confirmCancelDB(ids); |
| | | }); |
| | | } |
| | | }); |
| | | function confirmOrderDB(ids) { |
| | | febs.get(ctx + 'flow/confirmOrder?&orderIds='+ids, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | |
| | | }); |
| | | } |
| | | function confirmCancelDB(ids) { |
| | | febs.get(ctx + 'flow/confirmCancel?&orderIds='+ids, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | |
| | | }); |
| | | } |
| | | |
| | | table.on('tool(withdrawDbTable)', function (obj) { |
| | | var data = obj.data, |
| | |
| | | elem: $view.find('table'), |
| | | id: 'withdrawDbTable', |
| | | url: ctx + 'flow/fundFlow?type=8', |
| | | toolbar: '#tableToolBarOrderDB', |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'}, |
| | | {field: 'address', title: '地址', minWidth: 130}, |
| | | {field: 'createTime', title: '创建时间', minWidth: 180}, |
| | | {field: 'amount', title: '金额(USDT)', minWidth: 130}, |
| | | {title: '提现状态', templet: '#withdraw-status'}, |
| | | {field: 'fee', title: '手续费', minWidth: 130}, |
| | | {title: '操作', toolbar: '#withdraw-option', minWidth: 200} |
| | | // {field: 'fee', title: '手续费', minWidth: 130}, |
| | | // {title: '操作', toolbar: '#withdraw-option', minWidth: 200} |
| | | ]] |
| | | }); |
| | | } |
| | |
| | | <a lay-event="disagree" shiro:hasPermission="withdraw:disagree">审核驳回</a> |
| | | {{# } }} |
| | | </script> |
| | | |
| | | <script type="text/html" id="tableToolBarOrder"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="confirmOrder">提现确认</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="confirmCancel">提现取消</button> |
| | | </div> |
| | | </script> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () { |
| | | var $ = layui.jquery, |
| | |
| | | form.render(); |
| | | |
| | | initTable(); |
| | | |
| | | table.on('toolbar(withdrawTable)', function(obj){ |
| | | var event = obj.event; |
| | | var id = obj.config.id; |
| | | var checkStatus = table.checkStatus(id); |
| | | if(event === 'confirmOrder'){ |
| | | var data = checkStatus.data; |
| | | let ids = ""; |
| | | let totalAmount = 0; |
| | | for(let i = 0;i < data.length;i++){ |
| | | if(data[i].status != 1){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | }else{ |
| | | ids = ids + data[i].id+","; |
| | | totalAmount = totalAmount + data[i].amount; |
| | | } |
| | | } |
| | | if(ids == null || ids == ""){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | } |
| | | |
| | | febs.modal.confirm('USDT提现', '总额为:'+totalAmount, function () { |
| | | confirmOrder(ids); |
| | | }); |
| | | } |
| | | if(event === 'confirmCancel'){ |
| | | var data = checkStatus.data; |
| | | let ids = ""; |
| | | let totalAmount = 0; |
| | | for(let i = 0;i < data.length;i++){ |
| | | if(data[i].status != 1){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | }else{ |
| | | ids = ids + data[i].id+","; |
| | | totalAmount = totalAmount + data[i].amount; |
| | | } |
| | | } |
| | | if(ids == null || ids == ""){ |
| | | febs.alert.warn('请选择审核中的记录'); |
| | | return; |
| | | } |
| | | |
| | | febs.modal.confirm('提现取消', '总额为:'+totalAmount, function () { |
| | | confirmCancel(ids); |
| | | }); |
| | | } |
| | | }); |
| | | function confirmOrder(ids) { |
| | | febs.get(ctx + 'flow/confirmOrder?&orderIds='+ids, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | |
| | | }); |
| | | } |
| | | function confirmCancel(ids) { |
| | | febs.get(ctx + 'flow/confirmCancel?&orderIds='+ids, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | |
| | | }); |
| | | } |
| | | |
| | | table.on('tool(withdrawTable)', function (obj) { |
| | | var data = obj.data, |
| | |
| | | elem: $view.find('table'), |
| | | id: 'withdrawTable', |
| | | url: ctx + 'flow/fundFlow?type=7', |
| | | toolbar: '#tableToolBarOrder', |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'}, |
| | | {field: 'address', title: '地址', minWidth: 130}, |
| | | {field: 'createTime', title: '创建时间', minWidth: 180}, |
| | | {field: 'amount', title: '金额(USDT)', minWidth: 130}, |
| | | {title: '提现状态', templet: '#withdraw-status'}, |
| | | {field: 'fee', title: '手续费', minWidth: 130}, |
| | | {title: '操作', toolbar: '#withdraw-option', minWidth: 200} |
| | | // {field: 'fee', title: '手续费', minWidth: 130}, |
| | | // {title: '操作', toolbar: '#withdraw-option', minWidth: 200} |
| | | ]] |
| | | }); |
| | | } |