| | |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 4-保险池 5-提现 6-手续费充值 7-手续费扣除 8-结算 |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 4-保险池 5-提现 6-手续费充值 7-手续费扣除 8-结算 9-冻结 10-冻结释放 |
| | | */ |
| | | private Integer type; |
| | | |
| | |
| | | Map<String, BigDecimal> selectAmountTotalByType(@Param("memberId") Long memberId); |
| | | |
| | | BigDecimal selectProfitAmountByMemberId(@Param("memberId") Long memberId); |
| | | |
| | | DappFundFlowEntity selectNewestFundFlow(@Param("memberId") Long memberId, @Param("type") Integer type); |
| | | } |
| | |
| | | |
| | | List<DappMemberEntity> selectMemberByAccountType(@Param("accountType") String accountType); |
| | | |
| | | List<DappMemberEntity> selectChildMemberDirectOrNot(@Param("inviteId") String inviteId, @Param("type") Integer type); |
| | | List<DappMemberEntity> selectChildMemberDirectOrNot(@Param("inviteId") String inviteId, @Param("type") Integer type, @Param("status") Integer status); |
| | | |
| | | BigDecimal selectChildHoldAmount(@Param("inviteId") String inviteId); |
| | | |
| | | List<DappMemberEntity> selectMakerAddress(); |
| | | |
| | | int updateMemberActive(); |
| | | |
| | | DappMemberEntity selectNewestDirectMember(@Param("inviteId") String inviteId); |
| | | } |
| | |
| | | |
| | | void updateWalletMineWithLock(BigDecimal amount, Long memberId, int type); |
| | | |
| | | void addFrozenAmountWithLock(BigDecimal amount, Long memberId); |
| | | |
| | | void releaseFrozenAmountWithLock(Long memberId); |
| | | |
| | | DappWalletCoinEntity findByMemberId(Long memberId); |
| | | |
| | | } |
| | |
| | | throw new FebsException("recommender is not exist"); |
| | | } |
| | | |
| | | List<DappMemberEntity> child = dappMemberDao.selectChildMemberDirectOrNot(connectDto.getInviteId(), 1); |
| | | List<DappMemberEntity> child = dappMemberDao.selectChildMemberDirectOrNot(connectDto.getInviteId(), 1, null); |
| | | if (child.size() == 6) { |
| | | throw new FebsException("Invite Code is Invalid"); |
| | | } |
| | |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextUtil; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.SystemDto; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | |
| | | |
| | | // 如果是复投的,则需奖励 |
| | | if (isReIn == 1) { |
| | | member.setOutCnt(member.getOutCnt() + 1); |
| | | dappMemberDao.updateById(member); |
| | | List<DappMemberEntity> directCnt = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1); |
| | | |
| | | dappWalletService.updateWalletCoinWithLock(new BigDecimal(190), member.getId(), 1); |
| | | boolean hasNewDirect = false; |
| | | if (directCnt.size() < 3) { |
| | | DappMemberEntity newestDirect = dappMemberDao.selectNewestDirectMember(member.getInviteId()); |
| | | DappFundFlowEntity fundFlow = dappFundFlowDao.selectNewestFundFlow(memberId, 9); |
| | | |
| | | DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, new BigDecimal("190"), 2, 2, null, null); |
| | | dappFundFlowDao.insert(matrixProfitFlow); |
| | | if (newestDirect != null && fundFlow != null) { |
| | | if (newestDirect.getCreateTime().after(fundFlow.getCreateTime())) { |
| | | hasNewDirect = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复投后,推一个拿一轮,推两个拿两轮,推三个后终身有效。 |
| | | * 按规则每轮未能提取的奖金分配: |
| | | * 50%直接进入TFC底池 |
| | | * 20%给到推荐人 |
| | | * 30%留下待提。 |
| | | */ |
| | | if (directCnt.size() < 3 && member.getOutCnt() != 0 && member.getOutCnt() - 1 == directCnt.size() && !hasNewDirect) { |
| | | BigDecimal amount = new BigDecimal("190"); |
| | | |
| | | BigDecimal sourcePool = amount.multiply(new BigDecimal("0.5")); |
| | | BigDecimal directAmount = amount.multiply(new BigDecimal("0.2")); |
| | | |
| | | BigDecimal remain = amount.subtract(sourcePool).subtract(directAmount); |
| | | |
| | | // ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer("", sourcePool); |
| | | |
| | | if (parent != null) { |
| | | dappWalletService.updateWalletCoinWithLock(directAmount, parent.getId(), 1); |
| | | |
| | | DappFundFlowEntity direct = new DappFundFlowEntity(parent.getId(), directAmount, 3, 2, null, null); |
| | | dappFundFlowDao.insert(direct); |
| | | } |
| | | |
| | | dappWalletService.addFrozenAmountWithLock(remain, memberId); |
| | | } else { |
| | | dappWalletService.releaseFrozenAmountWithLock(memberId); |
| | | |
| | | member.setOutCnt(member.getOutCnt() + 1); |
| | | dappMemberDao.updateById(member); |
| | | |
| | | dappWalletService.updateWalletCoinWithLock(new BigDecimal(190), member.getId(), 1); |
| | | |
| | | DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, new BigDecimal("190"), 2, 2, null, null); |
| | | dappFundFlowDao.insert(matrixProfitFlow); |
| | | } |
| | | |
| | | DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(memberId, new BigDecimal("100").negate(), 1, 2, null, null); |
| | | dappFundFlowDao.insert(rePutInFlow); |
| | |
| | | |
| | | DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId()); |
| | | WalletInfoVo walletInfo = new WalletInfoVo(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, null); |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addFrozenAmountWithLock(BigDecimal amount, Long memberId) { |
| | | boolean isSuccess = false; |
| | | while(!isSuccess) { |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(memberId); |
| | | |
| | | walletCoin.setTotalAmount(walletCoin.getTotalAmount().add(amount)); |
| | | walletCoin.setFrozenAmount(walletCoin.getFrozenAmount().add(amount)); |
| | | |
| | | int i = dappWalletCoinDao.updateWithLock(walletCoin); |
| | | if (i > 0) { |
| | | isSuccess = true; |
| | | |
| | | DappFundFlowEntity frozenAmount = new DappFundFlowEntity(memberId, amount, 9, 2, null, null); |
| | | dappFundFlowDao.insert(frozenAmount); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void releaseFrozenAmountWithLock(Long memberId) { |
| | | boolean isSuccess = false; |
| | | while(!isSuccess) { |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(memberId); |
| | | |
| | | if (walletCoin.getFrozenAmount().compareTo(BigDecimal.ZERO) <= 0) { |
| | | return; |
| | | } |
| | | BigDecimal frozen = walletCoin.getFrozenAmount(); |
| | | |
| | | walletCoin.setAvailableAmount(walletCoin.getAvailableAmount().add(frozen)); |
| | | walletCoin.setFrozenAmount(walletCoin.getFrozenAmount().subtract(frozen)); |
| | | |
| | | int i = dappWalletCoinDao.updateWithLock(walletCoin); |
| | | if (i > 0) { |
| | | isSuccess = true; |
| | | |
| | | DappFundFlowEntity releaseFrozen = new DappFundFlowEntity(memberId, frozen, 10, 2, null, null); |
| | | dappFundFlowDao.insert(releaseFrozen); |
| | | |
| | | DappFundFlowEntity releaseFrozenNegate = new DappFundFlowEntity(memberId, frozen.negate(), 9, 2, null, null); |
| | | dappFundFlowDao.insert(releaseFrozenNegate); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public DappWalletCoinEntity findByMemberId(Long memberId) { |
| | | return dappWalletCoinDao.selectByMemberId(memberId); |
| | | } |
| | | } |
| | |
| | | online-transfer: false |
| | | chain-listener: false |
| | | reset-job: false |
| | | debug: false |
| | | debug: true |
| | |
| | | select ifnull(sum(amount), 0) from dapp_fund_flow |
| | | where member_id=#{memberId} and type in (2,3) |
| | | </select> |
| | | |
| | | <select id="selectNewestFundFlow" resultType="cc.mrbird.febs.dapp.entity.DappFundFlowEntity"> |
| | | select * from dapp_fund_flow |
| | | where member_id=#{memberId} and type = #{type} |
| | | order by id desc |
| | | limit 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | <if test="type==2"> |
| | | and find_in_set(#{inviteId}, fee_profit_ids) |
| | | </if> |
| | | <if test="status != null"> |
| | | and active_status=#{status} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | |
| | | set active_status = 2 |
| | | where active_status = 1 |
| | | </update> |
| | | |
| | | <select id="selectNewestDirectMember" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity"> |
| | | select * from dapp_member |
| | | where referer_id=#{inviteId} and active_status=1 |
| | | order by id desc |
| | | limit 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | update dapp_wallet_coin |
| | | set total_amount=#{record.totalAmount}, |
| | | available_amount=#{record.availableAmount}, |
| | | frozen_amount=#{record.frozenAmount}, |
| | | version=version+1 |
| | | where id=#{record.id} and version=#{record.version} |
| | | </update> |
| | |
| | | dappSystemService.resetMatrix(); |
| | | // dappAchieveMemberTreeDao.emptyTable(); |
| | | } |
| | | |
| | | @Test |
| | | public void limitResetProfitTest() { |
| | | dappSystemService.putIntoProfit(60L, 1); |
| | | } |
| | | } |