| | |
| | | import org.web3j.utils.Strings; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | int nodeType = 0; |
| | | // |
| | | if (!"asdf4321".equals(connectDto.getInviteId())) { |
| | | DappMemberEntity parent = dappMemberDao.selectByAddress(connectDto.getInviteId(), null); |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(connectDto.getInviteId()); |
| | | if (parent == null) { |
| | | throw new FebsException("recommender is not exist"); |
| | | } |
| | |
| | | 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(); |
| | | //直推收益 |
| | | BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2); |
| | | memberEntity.setDirectProfit(directProfit); |
| | | //购买节点数量 |
| | | List<DappMemberNodeVo> dappMemberNodeVos = dappMemberNodeMapper.selectListByMemberId(memberId); |
| | | memberEntity.setMemberNodeCnt(CollUtil.isEmpty(dappMemberNodeVos) ? 0 : dappMemberNodeVos.size()); |
| | | |
| | | BigDecimal memberNodeSumPrice = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(dappMemberNodeVos)){ |
| | | for(DappMemberNodeVo dappMemberNodeVo : dappMemberNodeVos){ |
| | | BigDecimal nodePrice = dappMemberNodeVo.getNodePrice(); |
| | | memberNodeSumPrice = memberNodeSumPrice.add(nodePrice); |
| | | } |
| | | } |
| | | memberEntity.setMemberNodeSumPrice(memberNodeSumPrice.setScale(8,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | } |
| | | // 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; |
| | | } |
| | | |
| | |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)) { |
| | | return new FebsResponse().fail().message("会员信息不存在"); |
| | | } |
| | | dappMemberEntity.setNodeType(1); |
| | | // dappMemberEntity.setAccountType(MemberLevelEnum.NODE_5.getType()); |
| | | dappMemberEntity.setActiveStatus(1); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)) { |
| | | return new FebsResponse().fail().message("会员信息不存在"); |
| | | } |
| | | dappMemberEntity.setNodeType(2); |
| | | dappMemberEntity.setAccountType(MemberLevelEnum.MEMBER.getType()); |
| | | dappMemberEntity.setActiveStatus(2); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | @Transactional |
| | | public Long createOrder(AddOrderDto addOrderDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | // DappMemberEntity member = dappMemberDao.selectById(1L); |
| | | /** |
| | | * 1、商品是否上架 |
| | | * 2、用户余额是否足够 |
| | |
| | | @Override |
| | | @Transactional |
| | | public void cancelOrder(Long id) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | // DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberEntity member = dappMemberDao.selectById(1L); |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(orderInfo)) { |
| | | throw new FebsException("订单异常"); |
| | |
| | | @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("订单异常"); |
| | |
| | | String payOrderNo = MallUtils.getOrderNum("PAY"); |
| | | orderInfo.setPayOrderNo(payOrderNo); |
| | | orderInfo.setPayMethod("余额支付"); |
| | | orderInfo.setPayResult("成功"); |
| | | orderInfo.setPayResult(1); |
| | | orderInfo.setStatus(MallOrderInfo.STATUS_PAY); |
| | | mallOrderInfoMapper.updateById(orderInfo); |
| | | /** |
| | |
| | | BigDecimal.ZERO, |
| | | payOrderNo, |
| | | id); |
| | | dappFundFlowDao.insert(donateScoreFlow); |
| | | |
| | | /** |
| | | * 支付成功,消费后成有效账户后可分享(有效用户可推广) |
| | |
| | | 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(); |
| | | } |
| | | |
| | | public static List<List<String>> partitionList(List<String> originalList, int partitionSize) { |
| | | List<List<String>> partitionedList = new ArrayList<>(); |
| | | int size = originalList.size(); |