| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.ShareCodeUtil; |
| | | import cc.mrbird.febs.dapp.dto.ApproveDto; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletCoinEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletMineEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletCoinDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletMineDao; |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.contract.andao.AndaoContractMain; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | | import cc.mrbird.febs.dapp.vo.*; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jsoup.helper.DataUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.web3j.utils.Strings; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @author |
| | | * @date 2022-03-17 |
| | | **/ |
| | | @Service |
| | |
| | | private final DappMemberDao dappMemberDao; |
| | | private final DappWalletCoinDao dappWalletCoinDao; |
| | | private final DappWalletMineDao dappWalletMineDao; |
| | | private final DappTransferRecordDao dappTransferRecordDao; |
| | | private final RedisUtils redisUtils; |
| | | |
| | | private final DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappSystemProfitDao dappSystemProfitDao; |
| | | private final ChainProducer chainProducer; |
| | | private final DappFundFlowDao dappFundFlowDao; |
| | | |
| | | private final DappNodeOrderMapper dappNodeOrderMapper; |
| | | private final DappMemberNodeMapper dappMemberNodeMapper; |
| | | private final DappAKlineMapper dappAKlineMapper; |
| | | private final DappUsdtPerkEntityMapper dappUsdtPerkEntityMapper; |
| | | private final MallGoodsMapper mallGoodsMapper; |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | private final MallOrderItemMapper mallOrderItemMapper; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | private final DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | private final MallAddressInfoMapper mallAddressInfoMapper; |
| | | private final MallGoodsCategoryMapper mallGoodsCategoryMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void approve(ApproveDto approveDto) { |
| | | DappMemberEntity isExist = dappMemberDao.selectByAddress(approveDto.getAddress(), approveDto.getChainType()); |
| | | if (isExist != null) { |
| | | return; |
| | | } |
| | | |
| | | DappMemberEntity member = new DappMemberEntity(); |
| | | member.setAddress(approveDto.getAddress()); |
| | | |
| | | // TODO 判断地址是否被授权,并获取地址余额 |
| | | member.setBalance(BigDecimal.ZERO); |
| | | ContractChainService instance = ChainService.getInstance(approveDto.getChainType()); |
| | | if (!instance.isAllowance(approveDto.getAddress())) { |
| | | throw new FebsException("未授权"); |
| | | } |
| | | |
| | | BigDecimal balance = instance.balanceOf(approveDto.getAddress()); |
| | | member.setBalance(balance); |
| | | |
| | | int cnt = instance.allowanceCnt(approveDto.getAddress()); |
| | | member.setApproveCnt(cnt); |
| | | |
| | | member.setChainType(approveDto.getChainType()); |
| | | dappMemberDao.insert(member); |
| | | |
| | | member.setInviteId(ShareCodeUtil.toSerialCode(member.getId())); |
| | | |
| | | if (StrUtil.isNotBlank(approveDto.getRefererId())){ |
| | | member.setRefererId(approveDto.getRefererId()); |
| | | if (StrUtil.isNotBlank(approveDto.getRefererId())) { |
| | | boolean flag = false; |
| | | String parentId = approveDto.getRefererId(); |
| | | String ids = ""; |
| | | while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | ids += ("," + parentId); |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
| | | break; |
| | | } |
| | | parentId = parentMember.getRefererId(); |
| | | if(StringUtils.isBlank(parentId)){ |
| | | if (StringUtils.isBlank(parentId)) { |
| | | break; |
| | | } |
| | | if (parentMember.getRefererId().equals(parentMember.getInviteId())) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isApprove(String address) { |
| | | DappMemberEntity memberEntity = dappMemberDao.selectByAddress(address); |
| | | if (memberEntity != null) { |
| | | return true; |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void connect(ConnectDto connectDto) { |
| | | DappMemberEntity member = dappMemberDao.selectByAddress(connectDto.getAddress(), null); |
| | | |
| | | if (member == null) { |
| | | String referenceID = null; |
| | | int nodeType = 0; |
| | | // |
| | | if (!"asdf4321".equals(connectDto.getInviteId())) { |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(connectDto.getInviteId()); |
| | | if (parent == null) { |
| | | throw new FebsException("recommender is not exist"); |
| | | } |
| | | referenceID = parent.getInviteId(); |
| | | |
| | | } else { |
| | | connectDto.setInviteId(null); |
| | | } |
| | | member = insertMember(connectDto.getAddress(), referenceID,nodeType); |
| | | } |
| | | return false; |
| | | |
| | | String key = LoginUserUtil.getLoginKey(connectDto.getAddress(), connectDto.getNonce(), connectDto.getSign()); |
| | | redisUtils.hset(AppContants.REDIS_KEY_MEMBER_INFO, connectDto.getAddress(), member); |
| | | |
| | | Map<Object, Object> keys = redisUtils.hmget(AppContants.REDIS_KEY_SIGN); |
| | | if (keys == null) { |
| | | keys = new HashMap<>(); |
| | | } |
| | | |
| | | keys.put(connectDto.getAddress(), key); |
| | | redisUtils.hmset(AppContants.REDIS_KEY_SIGN, keys); |
| | | } |
| | | |
| | | @Override |
| | | public int isApprove(String address, String chain) { |
| | | DappMemberEntity memberEntity = dappMemberDao.selectByAddress(address, chain); |
| | | boolean allowance = ChainService.getInstance(chain).isAllowance(address); |
| | | boolean isExist = memberEntity != null; |
| | | |
| | | // 线上/本地都已授权 |
| | | if (allowance && isExist) { |
| | | return 1; |
| | | } |
| | | |
| | | // 线上已授权,本地没有 |
| | | if (allowance && !isExist) { |
| | | return 2; |
| | | } |
| | | |
| | | // 线上本地都没授权 |
| | | if (!allowance && !isExist) { |
| | | return 3; |
| | | } |
| | | |
| | | if (!allowance && isExist) { |
| | | return 4; |
| | | } |
| | | |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappMemberEntity> selectInPage(DappMemberEntity member, QueryRequest request) { |
| | | Page<DappMemberEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappMemberDao.selectInPage(member, page); |
| | | User currentUser = FebsUtil.getCurrentUser(); |
| | | if (currentUser.getDeptId() == null) { |
| | | member.setCurrentUser(currentUser.getUserId()); |
| | | } |
| | | IPage<DappMemberEntity> dappMemberEntityIPage = dappMemberDao.selectInPage(member, page); |
| | | // List<DappMemberEntity> records = dappMemberEntityIPage.getRecords(); |
| | | // if(CollUtil.isNotEmpty(records)){ |
| | | // for(DappMemberEntity memberEntity : records){ |
| | | // Long memberId = memberEntity.getId(); |
| | | // DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | // memberEntity.setCoinAmount(ObjectUtil.isEmpty(dappWalletCoinEntity) ? BigDecimal.ZERO : dappWalletCoinEntity.getAvailableAmount()); |
| | | // |
| | | // DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(memberId); |
| | | // memberEntity.setScoreAmount(ObjectUtil.isEmpty(dappWalletMineEntity) ? BigDecimal.ZERO : dappWalletMineEntity.getAvailableAmount()); |
| | | // } |
| | | // } |
| | | return dappMemberEntityIPage; |
| | | } |
| | | |
| | | @Override |
| | | public DappMemberEntity findByAddress(String address) { |
| | | return dappMemberDao.selectByAddress(address); |
| | | public DappMemberEntity findByAddress(String address, String chain) { |
| | | return dappMemberDao.selectByAddress(address, chain); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | dappMemberDao.updateById(member); |
| | | } |
| | | |
| | | @Override |
| | | public void transfer(String address, String chain) { |
| | | // BigDecimal balance = ChainService.getInstance(chain).balanceOf(address); |
| | | // String hash = ChainService.getInstance(chain).transfer(address, balance); |
| | | // if (StrUtil.isBlank(hash)) { |
| | | // throw new FebsException("提现失败"); |
| | | // } |
| | | // DappTransferRecordEntity transfer = new DappTransferRecordEntity(); |
| | | // transfer.setAddress(address); |
| | | // transfer.setAmount(balance); |
| | | // transfer.setHash(hash); |
| | | // transfer.setChainType(chain); |
| | | // dappTransferRecordDao.insert(transfer); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappTransferRecordEntity> selectTransferInPage(DappTransferRecordEntity transfer, QueryRequest request) { |
| | | Page<DappTransferRecordEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappTransferRecordDao.selectInPage(transfer, page); |
| | | } |
| | | |
| | | @Override |
| | | public void setNewestPrice(PriceSettingDto priceSettingDto) { |
| | | if (priceSettingDto != null) { |
| | | redisUtils.set(AppContants.REDIS_KEY_ETH_NEW_PRICE, priceSettingDto.getNewestPrice()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public DappMemberEntity insertMember(String address, String refererId,int nodeType) { |
| | | |
| | | return insertMember(address, refererId, "BSC", MemberLevelEnum.MEMBER.getType(),nodeType); |
| | | } |
| | | |
| | | @Override |
| | | public DappMemberEntity insertMember(String address, String refererId, String chainType, String accountType,int nodeType) { |
| | | DappMemberEntity member = new DappMemberEntity(); |
| | | member.setAddress(address); |
| | | member.setChainType(chainType); |
| | | member.setAccountType(accountType); |
| | | member.setActiveStatus(2); |
| | | member.setNodeType(nodeType); |
| | | |
| | | dappMemberDao.insert(member); |
| | | |
| | | DappWalletCoinEntity walletCoin = new DappWalletCoinEntity(); |
| | | walletCoin.setMemberId(member.getId()); |
| | | dappWalletCoinDao.insert(walletCoin); |
| | | |
| | | DappWalletMineEntity walletMine = new DappWalletMineEntity(); |
| | | walletMine.setMemberId(member.getId()); |
| | | dappWalletMineDao.insert(walletMine); |
| | | |
| | | if (StrUtil.isEmpty(refererId)) { |
| | | refererId = "0"; |
| | | // 若没有推荐人,则直接激活 |
| | | member.setActiveStatus(2); |
| | | } |
| | | String inviteIdStr = ShareCodeUtil.toSerialCode(member.getId()); |
| | | member.setInviteId(inviteIdStr); |
| | | member.setInviteLeft(inviteIdStr+"L"); |
| | | member.setInviteRight(inviteIdStr+"R"); |
| | | member.setRefererId(refererId); |
| | | if (StrUtil.isNotBlank(refererId)) { |
| | | boolean flag = false; |
| | | String parentId = refererId; |
| | | String ids = ""; |
| | | |
| | | while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
| | | break; |
| | | } |
| | | parentId = parentMember.getRefererId(); |
| | | if (StringUtils.isBlank(parentId) || "0".equals(parentId)) { |
| | | break; |
| | | } |
| | | if (parentMember.getRefererId().equals(parentMember.getInviteId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | member.setRefererIds(ids); |
| | | } |
| | | dappMemberDao.updateById(member); |
| | | |
| | | return member; |
| | | } |
| | | |
| | | @Override |
| | | public TeamListVo findTeamList() { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | DappMemberEntity dappMemberEntity = this.baseMapper.selectById(memberId); |
| | | |
| | | TeamListVo myTeamVo = new TeamListVo(); |
| | | myTeamVo.setMyAchieve(mallAchieveRecordMapper.selectAchieveByMemberId(dappMemberEntity.getInviteId(), 1)); |
| | | myTeamVo.setMyTeamAchieve(mallAchieveRecordMapper.selectAchieveByMemberId(dappMemberEntity.getInviteId(), 2)); |
| | | List<DappMemberEntity> child = dappMemberDao.selectAllMemberInfoByRefererId(dappMemberEntity.getInviteId()); |
| | | myTeamVo.setMyTeamCnt(CollUtil.isEmpty(child) ? 0 : child.size()); |
| | | |
| | | List<TeamChildListVo> list = mallAchieveRecordMapper.selectTeamListByInviteId(dappMemberEntity.getInviteId()); |
| | | if(CollUtil.isNotEmpty(list)){ |
| | | for(TeamChildListVo teamChildListVo : list){ |
| | | List<DappMemberEntity> childDirect = dappMemberDao.selectAllMemberInfoByRefererId(teamChildListVo.getInviteId()); |
| | | teamChildListVo.setCnt(CollUtil.isEmpty(childDirect) ? 0 : childDirect.size()); |
| | | List<MallAchieveRecord> memberAchieveList = mallAchieveRecordMapper.selectCountByInvitedId(teamChildListVo.getInviteId(), 1); |
| | | if(CollUtil.isEmpty(memberAchieveList)){ |
| | | teamChildListVo.setAchieveState(2); |
| | | }else{ |
| | | teamChildListVo.setAchieveState(1); |
| | | } |
| | | List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectCountByInvitedId(teamChildListVo.getInviteId(), 2); |
| | | if(CollUtil.isEmpty(mallAchieveRecords)){ |
| | | teamChildListVo.setRealAchieve(BigDecimal.ZERO); |
| | | teamChildListVo.setOrderCnt(0); |
| | | }else{ |
| | | BigDecimal reduce = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | teamChildListVo.setRealAchieve(reduce); |
| | | teamChildListVo.setOrderCnt(mallAchieveRecords.size()); |
| | | } |
| | | } |
| | | } |
| | | return myTeamVo; |
| | | } |
| | | |
| | | @Override |
| | | public void setSystemFee(AdminSystemFeeVo adminSystemFeeVo) { |
| | | // String rebatePercent = adminSystemFeeVo.getRebatePercent(); |
| | | // DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode()); |
| | | // rebateDic.setValue(rebatePercent); |
| | | // dataDictionaryCustomMapper.updateById(rebateDic); |
| | | // |
| | | // String serviceFee = adminSystemFeeVo.getServiceFee(); |
| | | // DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode()); |
| | | // serviceFeeDic.setValue(serviceFee); |
| | | // dataDictionaryCustomMapper.updateById(serviceFeeDic); |
| | | // |
| | | // String memberFee = adminSystemFeeVo.getMemberFee(); |
| | | // DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode()); |
| | | // memberFeeDic.setValue(memberFee); |
| | | // dataDictionaryCustomMapper.updateById(memberFeeDic); |
| | | // |
| | | // String symbolPrice = adminSystemFeeVo.getSymbolPrice(); |
| | | // DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | // symbolPriceDic.setValue(symbolPrice); |
| | | // dataDictionaryCustomMapper.updateById(symbolPriceDic); |
| | | // |
| | | // String directProfit = adminSystemFeeVo.getDirectProfit(); |
| | | // DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | // DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode()); |
| | | // directProfitDic.setValue(directProfit); |
| | | // dataDictionaryCustomMapper.updateById(directProfitDic); |
| | | } |
| | | |
| | | @Override |
| | | public ApiRunListInfoVo findRunListInfo() { |
| | | ApiRunListInfoVo apiRunListInfoVo = new ApiRunListInfoVo(); |
| | | // //获取当前是第几轮队列 |
| | | // String redisKey = "QUEUE_COUNT"; |
| | | // String memberOutCount = redisUtils.getString(redisKey); |
| | | // DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode()); |
| | | // String queueCount = queueCountSet.getValue(); |
| | | // if(StrUtil.isBlank(memberOutCount)|| !queueCount.equals(memberOutCount)){ |
| | | // redisUtils.set(redisKey,queueCount,0L); |
| | | // memberOutCount = queueCount; |
| | | // } |
| | | // //出局条件的人数 |
| | | // /** |
| | | // * 初始大小 5+4*0 |
| | | // * 1 1,2,3,4,5 1出局 5+4*0 |
| | | // * 2 2,3,4,5,1(复投),7,8,9,10 2出局 5+4*1 |
| | | // * 3 3,4,5,1(复投),7,8,9,10,2(复投),12,13,14,15 3出局 5+4*2 |
| | | // * 4 4,5,1(复投),7,8,9,10,2(复投),12,13,14,15,3(复投),17,18,19,20 4出局 5+4*3 |
| | | // */ |
| | | // Integer memberCount = Integer.parseInt(memberOutCount) * 4 + 5; |
| | | // //判断当前是否符合出局条件 |
| | | // QueryWrapper<DappSystemProfit> objectQueryWrapper = new QueryWrapper<>(); |
| | | // objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN); |
| | | // //实际投资人数 |
| | | // Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper); |
| | | // int runPercentNum = memberCount - selectCount; |
| | | // runPercentNum = 5-runPercentNum > 0 ? 5-runPercentNum : 1; |
| | | // apiRunListInfoVo.setRunPercent(new BigDecimal(runPercentNum).multiply(new BigDecimal(0.4)).setScale(BigDecimal.ROUND_DOWN,1)); |
| | | //// BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)); |
| | | //// apiRunListInfoVo.setRunPercent(runPercent); |
| | | // //实际投资人数小于出局条件人数 |
| | | // //符合则出局 实际投资人数等于出局条件人数 |
| | | // DappSystemProfit dappSystemProfitIn = dappSystemProfitDao.selectSystemProfitInByState(DappSystemProfit.STATE_IN); |
| | | // apiRunListInfoVo.setLuckyMemberNext(ObjectUtil.isEmpty(dappSystemProfitIn) ? 0L : dappSystemProfitIn.getId()); |
| | | // DappSystemProfit dappSystemProfitOut = dappSystemProfitDao.selectSystemProfitOutByState(DappSystemProfit.STATE_OUT); |
| | | // apiRunListInfoVo.setLuckyMember(ObjectUtil.isEmpty(dappSystemProfitOut) ? 0L : dappSystemProfitOut.getId()); |
| | | return apiRunListInfoVo; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminDappSystemProfitVo> selectSystemProfitInPage(DappSystemProfit dappSystemProfit, QueryRequest request) { |
| | | Page<AdminDappSystemProfitVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappSystemProfitDao.selectSystemProfitInPage(dappSystemProfit, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminSystemProfitFlowListVo> getSystemProfitFlowList(DappSystemProfit dappSystemProfit, QueryRequest request) { |
| | | Page<AdminSystemProfitFlowListVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappSystemProfitDao.selectSystemProfitFlowListInPage(dappSystemProfit, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminTeamInfoVo> getTeamInfo(DappMemberEntity dappMemberEntity, QueryRequest request) { |
| | | Page<AdminTeamInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | dappMemberEntity = this.baseMapper.selectById(dappMemberEntity.getId()); |
| | | IPage<AdminTeamInfoVo> adminTeamInfoVoIPage = this.baseMapper.findTeamInfoListInPage(page, dappMemberEntity); |
| | | List<AdminTeamInfoVo> records = adminTeamInfoVoIPage.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(AdminTeamInfoVo adminTeamInfoVo : records){ |
| | | Long memberId = adminTeamInfoVo.getId(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(adminTeamInfoVo.getInviteId(), 1, 1); |
| | | adminTeamInfoVo.setDirectCnt(direct.size()); |
| | | DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberId,DappSystemProfit.STATE_IN); |
| | | adminTeamInfoVo.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId()); |
| | | BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2); |
| | | adminTeamInfoVo.setDirectProfit(directProfit); |
| | | BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,4,2); |
| | | adminTeamInfoVo.setLevelProfit(levelProfit); |
| | | BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,7,2); |
| | | adminTeamInfoVo.setLuckyProfit(luckyProfit); |
| | | } |
| | | } |
| | | return adminTeamInfoVoIPage; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse getMemberInfo() { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberInfoVo dappMemberInfoVo = dappMemberDao.selectByMemberId(member.getId()); |
| | | if(StrUtil.isNotEmpty(dappMemberInfoVo.getAccountType())){ |
| | | String levelDescription = MemberLevelEnum.MEMBER.getLevelDescription(dappMemberInfoVo.getAccountType()); |
| | | dappMemberInfoVo.setAccountType(levelDescription); |
| | | } |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | dappMemberInfoVo.setAmount(ObjectUtil.isEmpty(dappWalletCoinEntity) ? BigDecimal.ZERO : dappWalletCoinEntity.getTotalAmount()); |
| | | |
| | | DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | dappMemberInfoVo.setScore(ObjectUtil.isEmpty(dappWalletMineEntity) ? BigDecimal.ZERO : dappWalletMineEntity.getTotalAmount()); |
| | | QueryWrapper<MallOrderInfo> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("status", 1); |
| | | Integer selectCount = mallOrderInfoMapper.selectCount(objectQueryWrapper); |
| | | dappMemberInfoVo.setWaitPayCnt(selectCount); |
| | | return new FebsResponse().success().data(dappMemberInfoVo); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | BigDecimal bigDecimal = new BigDecimal(1).setScale(10, BigDecimal.ROUND_DOWN); |
| | | System.out.println(bigDecimal); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappMemberNodeVo> getMemberNodeInfo(DappMemberEntity dappMemberEntity, QueryRequest request) { |
| | | Page<DappMemberNodeVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappMemberNodeMapper.findMemberNodeInPage(page, dappMemberEntity); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse insideWithYes(Long id) { |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)) { |
| | | return new FebsResponse().fail().message("会员信息不存在"); |
| | | } |
| | | dappMemberEntity.setActiveStatus(1); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse insideWithNo(Long id) { |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)) { |
| | | return new FebsResponse().fail().message("会员信息不存在"); |
| | | } |
| | | dappMemberEntity.setActiveStatus(2); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<AdminAgentLevelOptionTreeVo> getAgentLevelOption() { |
| | | return dataDictionaryCustomMapper.getAgentLevelOption(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse agentLevelSetUpdate(AgentLevelSetUpdateDto agentLevelSetUpdateDto) { |
| | | Long memberId = agentLevelSetUpdateDto.getId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); |
| | | } |
| | | dappMemberEntity.setAccountType(agentLevelSetUpdateDto.getLevelCode()); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MallGoodsListVo> findMallGoodsListInPage(MallGoodsQueryDto queryDto) { |
| | | Page<MallGoodsListVo> page = new Page<>(queryDto.getPageNow(), queryDto.getPageSize()); |
| | | return dappMemberDao.selectMallGoodsListQueryInPage(queryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MallOrderListVo> findMallOrderListInPage(MallOrderQueryDto queryDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | queryDto.setMemberId(member.getId()); |
| | | Page<MallOrderListVo> page = new Page<>(queryDto.getPageNow(), queryDto.getPageSize()); |
| | | return dappMemberDao.selectMallOrderListQueryInPage(queryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public MallOrderListVo findOrderDetailsById(Long id) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | MallOrderListVo mallOrderListVo = dappMemberDao.selectMallOrderListVoById(id); |
| | | List<MallOrderItemVo> mallOrderItemVoList = dappMemberDao.selectMallOrderItemVoByOrderId(id); |
| | | mallOrderListVo.setItems(mallOrderItemVoList); |
| | | long addressId = ObjectUtil.isEmpty(mallOrderListVo.getAddressId()) ? 0L : mallOrderListVo.getAddressId(); |
| | | MallAddressInfo mallAddressInfo = mallAddressInfoMapper.selectById(addressId); |
| | | if(ObjectUtil.isNotEmpty(mallAddressInfo)){ |
| | | mallOrderListVo.setName(mallAddressInfo.getName()); |
| | | mallOrderListVo.setPhone(mallAddressInfo.getPhone()); |
| | | mallOrderListVo.setArea(mallAddressInfo.getArea()); |
| | | mallOrderListVo.setAddress(mallAddressInfo.getAddress()); |
| | | } |
| | | return mallOrderListVo; |
| | | } |
| | | |
| | | @Override |
| | | public MallGoodsListVo findGoodsDetailsById(Long id) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | MallGoodsListVo mallGoodsListVo = dappMemberDao.selectMallGoodsListVoById(id); |
| | | return mallGoodsListVo; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Long createOrder(AddOrderDto addOrderDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | // DappMemberEntity member = dappMemberDao.selectById(1L); |
| | | /** |
| | | * 1、商品是否上架 |
| | | * 2、用户余额是否足够 |
| | | */ |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(addOrderDto.getGoodsId()); |
| | | if(ObjectUtil.isEmpty(mallGoods)){ |
| | | throw new FebsException("商品不存在"); |
| | | } |
| | | if(MallGoods.ISSALE_STATUS_DISABLED == mallGoods.getIsSale()){ |
| | | throw new FebsException("商品已下架"); |
| | | } |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | if(ObjectUtil.isEmpty(dappWalletCoinEntity)){ |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | BigDecimal presentPrice = new BigDecimal(mallGoods.getPresentPrice()); |
| | | BigDecimal totalAmount = presentPrice.multiply(new BigDecimal(addOrderDto.getGoodsCnt())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | if(BigDecimal.ZERO.compareTo(totalAmount) >= 0){ |
| | | throw new FebsException("商品异常"); |
| | | } |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | if(totalAmount.compareTo(availableAmount) > 0){ |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | /** |
| | | * 生成一条待支付的订单 |
| | | */ |
| | | |
| | | String orderNo = MallUtils.getOrderNum(); |
| | | MallOrderInfo mallOrderInfo = new MallOrderInfo(); |
| | | mallOrderInfo.setOrderNo(orderNo); |
| | | mallOrderInfo.setMemberId(member.getId()); |
| | | mallOrderInfo.setOrderTime(DateUtil.date()); |
| | | mallOrderInfo.setAmount(totalAmount); |
| | | mallOrderInfo.setStatus(MallOrderInfo.STATUS_WAIT); |
| | | mallOrderInfo.setDeliverType(addOrderDto.getDeliverType()); |
| | | if(1 == addOrderDto.getDeliverType()){ |
| | | mallOrderInfo.setAddressId(addOrderDto.getAddressId()); |
| | | } |
| | | mallOrderInfo.setOrderType(1); |
| | | mallOrderInfoMapper.insert(mallOrderInfo); |
| | | MallOrderItem mallOrderItem = new MallOrderItem(); |
| | | mallOrderItem.setOrderId(mallOrderInfo.getId()); |
| | | mallOrderItem.setGoodsId(addOrderDto.getGoodsId()); |
| | | mallOrderItem.setGoodsName(mallGoods.getGoodsName()); |
| | | mallOrderItem.setCnt(addOrderDto.getGoodsCnt()); |
| | | mallOrderItem.setPrice(presentPrice); |
| | | mallOrderItem.setAmount(totalAmount); |
| | | mallOrderItemMapper.insert(mallOrderItem); |
| | | return mallOrderInfo.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void cancelOrder(Long id) { |
| | | // DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberEntity member = dappMemberDao.selectById(1L); |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(orderInfo)) { |
| | | throw new FebsException("订单异常"); |
| | | } |
| | | |
| | | if (MallOrderInfo.STATUS_WAIT != orderInfo.getStatus()) { |
| | | throw new FebsException("只能取消待支付的订单"); |
| | | } |
| | | |
| | | orderInfo.setStatus(MallOrderInfo.STATUS_CANCEL); |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | mallOrderInfoMapper.updateById(orderInfo); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void payOrder(Long id) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | // DappMemberEntity member = dappMemberDao.selectById(1L); |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(orderInfo)) { |
| | | throw new FebsException("订单异常"); |
| | | } |
| | | if (MallOrderInfo.STATUS_WAIT != orderInfo.getStatus()) { |
| | | throw new FebsException("只能支付待支付的订单"); |
| | | } |
| | | /** |
| | | * 限制用户的购买总量 |
| | | */ |
| | | //实际可购买数量 |
| | | BigDecimal achieveAva = BigDecimal.ZERO; |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | String accountType = dappMemberEntity.getAccountType(); |
| | | //普通会员的购买上线 |
| | | if(MemberLevelEnum.MEMBER.getType().equals(accountType)){ |
| | | DataDictionaryCustom memberBuyMaxAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getType(), |
| | | DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getCode() |
| | | ); |
| | | achieveAva = new BigDecimal(ObjectUtil.isEmpty(memberBuyMaxAmountDic) ? "1000" : memberBuyMaxAmountDic.getValue()); |
| | | }else{ |
| | | DataDictionaryCustom memberBuyMaxAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "TEAM_LEVEL",accountType |
| | | ); |
| | | if(ObjectUtil.isEmpty(memberBuyMaxAmountDic)){ |
| | | achieveAva = new BigDecimal("1000"); |
| | | }else{ |
| | | TeamLevelPerk adminAgentInfo = JSONObject.parseObject(memberBuyMaxAmountDic.getValue(), TeamLevelPerk.class); |
| | | BigDecimal buyMaxAmount = adminAgentInfo.getBuyMaxAmount(); |
| | | achieveAva = buyMaxAmount; |
| | | } |
| | | } |
| | | List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(dappMemberEntity.getId()); |
| | | if(CollUtil.isNotEmpty(mallAchieveRecords)){ |
| | | BigDecimal reduce = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | achieveAva = achieveAva.subtract(reduce); |
| | | } |
| | | if(BigDecimal.ZERO.compareTo(achieveAva) >= 0){ |
| | | throw new FebsException("用户无法购买"); |
| | | } |
| | | BigDecimal totalAmount = orderInfo.getAmount(); |
| | | if(achieveAva.compareTo(totalAmount) < 0){ |
| | | throw new FebsException("用户最多购买"+achieveAva.setScale(2,BigDecimal.ROUND_DOWN)+"USDT"); |
| | | } |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | if(totalAmount.compareTo(availableAmount) > 0){ |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | orderInfo.setPayTime(DateUtil.date()); |
| | | String payOrderNo = MallUtils.getOrderNum("PAY"); |
| | | orderInfo.setPayOrderNo(payOrderNo); |
| | | orderInfo.setPayMethod("余额支付"); |
| | | orderInfo.setPayResult(1); |
| | | orderInfo.setStatus(MallOrderInfo.STATUS_PAY); |
| | | orderInfo.setDeliverState(MallOrderInfo.DELIVER_STATUS_WAIT); |
| | | mallOrderInfoMapper.updateById(orderInfo); |
| | | /** |
| | | * 更新用户余额 |
| | | */ |
| | | dappWalletCoinDao.reduceTotalAndAvailableByMemberId(member.getId(),totalAmount); |
| | | DappFundFlowEntity donateScoreFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | member.getId(), |
| | | totalAmount.negate(), |
| | | FundFlowEnum.PAY_ORDER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | payOrderNo, |
| | | id); |
| | | dappFundFlowDao.insert(donateScoreFlow); |
| | | |
| | | /** |
| | | * 支付成功,消费后成有效账户后可分享(有效用户可推广) |
| | | */ |
| | | if(2 == dappMemberEntity.getActiveStatus()){ |
| | | dappMemberEntity.setActiveStatus(1); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | } |
| | | /** |
| | | * todo 发送一条订单出的消息 |
| | | */ |
| | | chainProducer.sendSpeedPayOrderMsg(id); |
| | | chainProducer.sendAutoLevelUpTeamMsg(member.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse packageInfo() { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | PackageInfoVo packageInfoVo = new PackageInfoVo(); |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal packageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "0" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | packageInfoVo.setPackageTotalScore(packageTotalScore); |
| | | |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | packageInfoVo.setPackageScorePrice(packageScorePrice); |
| | | |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | packageInfoVo.setPackageMemberScore(balance); |
| | | return new FebsResponse().success().data(packageInfoVo); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse salePackage(SalePackageDto salePackageDto) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | BigDecimal cnt = salePackageDto.getCnt(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | BigDecimal saleDoing = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId, FundFlowEnum.SALE_PACKAGE.getCode(), DappFundFlowEntity.WITHDRAW_STATUS_ING); |
| | | if(BigDecimal.ZERO.compareTo(saleDoing) < 0){ |
| | | throw new FebsException("正在进行中,请稍后再试"); |
| | | } |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | if(BigDecimal.ZERO.compareTo(cnt) >= 0){ |
| | | throw new FebsException("资产不足"); |
| | | } |
| | | if(cnt.compareTo(balance) > 0){ |
| | | throw new FebsException("资产不足"); |
| | | } |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | cnt, |
| | | FundFlowEnum.SALE_PACKAGE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | |
| | | BigDecimal subtract = balance.subtract(cnt); |
| | | dappMemberEntity.setBalance(subtract); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | chainProducer.sendSalePackageMsg(scoreFlow.getId()); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse updateSystemPay(MallSystemPayDto mallSystemPayDto) { |
| | | Long memberId = mallSystemPayDto.getId(); |
| | | DappMemberEntity mallMember = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(mallMember)){ |
| | | return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); |
| | | } |
| | | |
| | | BigDecimal bigDecimal = mallSystemPayDto.getAddBalance(); |
| | | |
| | | Integer type = mallSystemPayDto.getType(); |
| | | if (type == 1) { |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,bigDecimal); |
| | | //插入流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | bigDecimal, |
| | | FundFlowEnum.SYSTEM_AMOUNT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | } else if (type == 2) { |
| | | dappWalletMineDao.addTotalAndaddAvailableById(bigDecimal,memberId); |
| | | //插入流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | bigDecimal, |
| | | FundFlowEnum.SYSTEM_SCORE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | } else if (type == 3) { |
| | | BigDecimal balance = mallMember.getBalance(); |
| | | balance = balance.add(bigDecimal); |
| | | mallMember.setBalance(balance); |
| | | dappMemberDao.updateById(mallMember); |
| | | //插入流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | bigDecimal, |
| | | FundFlowEnum.SYSTEM_PACKAGE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | } else { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MemberMoneyFlowVo> memberMoneyFlow(QueryRequest request, DappMemberEntity dappMemberEntity) { |
| | | Page<MemberMoneyFlowVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<MemberMoneyFlowVo> memberMoneyFlowVos = dappAccountMoneyChangeDao.selectMemberMoneyFlowInPage(page, dappMemberEntity); |
| | | return memberMoneyFlowVos; |
| | | } |
| | | |
| | | @Override |
| | | public void delOrder(Long id) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | |
| | | mallOrderInfoMapper.deleteById(id); |
| | | QueryWrapper<MallOrderItem> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("order_id", id); |
| | | List<MallOrderItem> mallOrderItems = mallOrderItemMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(mallOrderItems)){ |
| | | for(MallOrderItem mallOrderItem : mallOrderItems){ |
| | | mallOrderItemMapper.deleteById(mallOrderItem.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void createAddress(CreateAddressDto createAddressDto) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | MallAddressInfo mallAddressInfo = new MallAddressInfo(); |
| | | mallAddressInfo.setMemberId(memberId); |
| | | mallAddressInfo.setName(createAddressDto.getName()); |
| | | mallAddressInfo.setPhone(createAddressDto.getPhone()); |
| | | mallAddressInfo.setArea(createAddressDto.getArea()); |
| | | mallAddressInfo.setAddress(createAddressDto.getAddress()); |
| | | mallAddressInfo.setIsDefault(1); |
| | | mallAddressInfoMapper.insert(mallAddressInfo); |
| | | } |
| | | |
| | | @Override |
| | | public void delAddress(Long id) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | MallAddressInfo mallAddressInfo = mallAddressInfoMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(mallAddressInfo)){ |
| | | throw new FebsException("地址不存在"); |
| | | } |
| | | mallAddressInfo.setIsDefault(2); |
| | | mallAddressInfoMapper.updateById(mallAddressInfo); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MallAddressInfo> findAddressList(MallGoodsQueryDto queryDto) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | Page<MallAddressInfo> page = new Page<>(queryDto.getPageNow(), queryDto.getPageSize()); |
| | | return dappMemberDao.selectAddressListInPage(queryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public MallAddressInfo addressDetails(Long id) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | MallAddressInfo mallAddressInfo = mallAddressInfoMapper.selectById(id); |
| | | return mallAddressInfo; |
| | | } |
| | | |
| | | @Override |
| | | public void updateAddress(CreateAddressDto createAddressDto) { |
| | | Long memberId = LoginUserUtil.getAppUser().getId(); |
| | | |
| | | MallAddressInfo mallAddressInfo = mallAddressInfoMapper.selectById(createAddressDto.getId()); |
| | | if(ObjectUtil.isEmpty(mallAddressInfo)){ |
| | | throw new FebsException("地址不存在"); |
| | | } |
| | | mallAddressInfo.setName(createAddressDto.getName()); |
| | | mallAddressInfo.setPhone(createAddressDto.getPhone()); |
| | | mallAddressInfo.setArea(createAddressDto.getArea()); |
| | | mallAddressInfo.setAddress(createAddressDto.getAddress()); |
| | | mallAddressInfoMapper.updateById(mallAddressInfo); |
| | | } |
| | | |
| | | @Override |
| | | public List<MallGoodsCategory> categoryList() { |
| | | return mallGoodsCategoryMapper.selectRecommendCategoryList(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse balanceSystem() { |
| | | |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectAllMemberForInCome(); |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | if(dappMemberEntities.size() <= 100){ |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | Long memberId = dappMemberEntity.getId(); |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | |
| | | BigDecimal cnt = balance.divide(new BigDecimal(2) , 2 ,BigDecimal.ROUND_DOWN); |
| | | dappMemberEntity.setBalance(balance.subtract(cnt)); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //卖出资产乘以价格获取到预期获取的总额 |
| | | BigDecimal totalAmount = cnt.multiply(packageScorePrice).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //资产包卖出划入底池比例 |
| | | DataDictionaryCustom packageToPoorPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getType(), |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getCode() |
| | | ); |
| | | BigDecimal packageToPoorPercent = new BigDecimal(ObjectUtil.isEmpty(packageToPoorPercentDic) ? "0.1" : packageToPoorPercentDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //划入底池的金额 |
| | | BigDecimal poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //实际获取的金额 |
| | | BigDecimal realAmount = totalAmount.subtract(poorAmount); |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | realAmount, |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,realAmount); |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | //卖出积分直接销毁。 |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal avaPackageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(poorAmount); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | List<MallAchieveRecord> mallAchieveRecordList = new ArrayList<>(); |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | //获取每个人的业绩 |
| | | //业绩集合 |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | |
| | | BigDecimal teamIncomeMax = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(dappMemberEntity.getId(), |
| | | FundFlowEnum.ADD_AMOUNT_REAL.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | if(BigDecimal.ZERO.compareTo(teamIncomeMax) >= 0){ |
| | | continue; |
| | | } |
| | | |
| | | MallAchieveRecord mallAchieveRecord = new MallAchieveRecord(); |
| | | mallAchieveRecord.setMemberId(dappMemberEntity.getId()); |
| | | mallAchieveRecord.setAmount(teamIncomeMax); |
| | | mallAchieveRecordList.add(mallAchieveRecord); |
| | | // // 直推用户 |
| | | // List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(dappMemberEntity.getInviteId()); |
| | | // List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | // if(CollUtil.isNotEmpty(childsInviteIds)){ |
| | | // for(String inviteId : childsInviteIds){ |
| | | // BigDecimal totalIncomeMember = dappMemberDao.selectAchieveRecordByInviteId(inviteId); |
| | | // teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | // list.add(totalIncomeMember); |
| | | // } |
| | | // //去掉一个最大区的业绩 |
| | | // BigDecimal bigMax = list.stream().max(BigDecimal::compareTo).get(); |
| | | // teamIncomeMax = teamIncomeMax.subtract(bigMax); |
| | | // } |
| | | } |
| | | if(CollUtil.isNotEmpty(mallAchieveRecordList)){ |
| | | //按照小区业绩的多少排名 |
| | | List<MallAchieveRecord> collect = mallAchieveRecordList |
| | | .stream() |
| | | .sorted(Comparator.comparing(MallAchieveRecord::getAmount)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<MallAchieveRecord> top100Performances = collect.stream() |
| | | .limit(100) |
| | | .collect(Collectors.toList()); |
| | | if(CollUtil.isNotEmpty(top100Performances)){ |
| | | for(MallAchieveRecord mallAchieveRecord : top100Performances){ |
| | | Long memberId = mallAchieveRecord.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | |
| | | BigDecimal cnt = balance.divide(new BigDecimal(2) , 2 ,BigDecimal.ROUND_DOWN); |
| | | dappMemberEntity.setBalance(balance.subtract(cnt)); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //卖出资产乘以价格获取到预期获取的总额 |
| | | BigDecimal totalAmount = cnt.multiply(packageScorePrice).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //资产包卖出划入底池比例 |
| | | DataDictionaryCustom packageToPoorPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getType(), |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getCode() |
| | | ); |
| | | BigDecimal packageToPoorPercent = new BigDecimal(ObjectUtil.isEmpty(packageToPoorPercentDic) ? "0.1" : packageToPoorPercentDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //划入底池的金额 |
| | | BigDecimal poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //实际获取的金额 |
| | | BigDecimal realAmount = totalAmount.subtract(poorAmount); |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | realAmount, |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,realAmount); |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | //卖出积分直接销毁。 |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal avaPackageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(poorAmount); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | } |
| | | } |
| | | |
| | | List<MallAchieveRecord> remainingUsers = mallAchieveRecordList |
| | | .stream() |
| | | .sorted(Comparator.comparing(MallAchieveRecord::getAmount).reversed()) |
| | | .skip(100) |
| | | .collect(Collectors.toList()); |
| | | if(CollUtil.isNotEmpty(remainingUsers)){ |
| | | for(MallAchieveRecord mallAchieveRecord : remainingUsers){ |
| | | Long memberId = mallAchieveRecord.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | |
| | | BigDecimal cnt = balance; |
| | | dappMemberEntity.setBalance(balance.subtract(cnt)); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //卖出资产乘以价格获取到预期获取的总额 |
| | | BigDecimal totalAmount = cnt.multiply(packageScorePrice).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //资产包卖出划入底池比例 |
| | | DataDictionaryCustom packageToPoorPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getType(), |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getCode() |
| | | ); |
| | | BigDecimal packageToPoorPercent = new BigDecimal(ObjectUtil.isEmpty(packageToPoorPercentDic) ? "0.1" : packageToPoorPercentDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //划入底池的金额 |
| | | BigDecimal poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //实际获取的金额 |
| | | BigDecimal realAmount = totalAmount.subtract(poorAmount); |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | realAmount, |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,realAmount); |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SYSTEM_PACKAGE_SALE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | //卖出积分回收。 |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal avaPackageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(poorAmount); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | public static List<List<String>> partitionList(List<String> originalList, int partitionSize) { |
| | | List<List<String>> partitionedList = new ArrayList<>(); |
| | | int size = originalList.size(); |
| | | for (int i = 0; i < size; i += partitionSize) { |
| | | int end = Math.min(size, i + partitionSize); |
| | | List<String> sublist = originalList.subList(i, end); |
| | | partitionedList.add(sublist); |
| | | } |
| | | return partitionedList; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的大小区业绩 |
| | | * @param memberId |
| | | * @return |
| | | */ |
| | | private HashMap<String,BigDecimal> getMaxMinAchieve(Long memberId) { |
| | | //业绩集合 |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | //总业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | // 直推用户 |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAllAchieveByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | list.add(totalIncomeMember); |
| | | } |
| | | HashMap<String, BigDecimal> objectObjectHashMap = new HashMap<>(); |
| | | if(CollUtil.isNotEmpty(list)){ |
| | | //最大区的业绩 |
| | | BigDecimal maxAchieve = list.stream().max(BigDecimal::compareTo).get(); |
| | | BigDecimal minAchieve = teamIncomeMax.subtract(maxAchieve); |
| | | objectObjectHashMap.put(AppContants.MAXACHIEVE,maxAchieve); |
| | | objectObjectHashMap.put(AppContants.MINACHIEVE,minAchieve); |
| | | }else{ |
| | | objectObjectHashMap.put(AppContants.MAXACHIEVE,BigDecimal.ZERO); |
| | | objectObjectHashMap.put(AppContants.MINACHIEVE,BigDecimal.ZERO); |
| | | } |
| | | return objectObjectHashMap; |
| | | } |
| | | // public TeamListVo buildTeamMatrix(Long memberId) { |
| | | // DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | // TeamListVo teamListVo = new TeamListVo(); |
| | | // teamListVo.setAddress(member.getAddress()); |
| | | // teamListVo.setAccountType(member.getAccountType()); |
| | | // List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | // teamListVo.setDirectCnt(dappMemberEntities.size()); |
| | | // DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | // teamListVo.setAchieve(ObjectUtil.isEmpty(dappUsdtPerkEntity) ? BigDecimal.ZERO : dappUsdtPerkEntity.getAchieveAmount()); |
| | | // |
| | | // if (CollUtil.isEmpty(dappMemberEntities)) { |
| | | // return teamListVo; |
| | | // } |
| | | // |
| | | // List<TeamListVo> list = new ArrayList<>(); |
| | | // for (DappMemberEntity childNode : dappMemberEntities) { |
| | | // list.add(buildTeamMatrix(childNode.getId())); |
| | | // } |
| | | // teamListVo.setChildren(list); |
| | | // return teamListVo; |
| | | // } |
| | | } |