| | |
| | | private final DappOnHookAwardDao dappOnHookAwardDao; |
| | | private final DappWalletService dappWalletService; |
| | | private final DappOnHookDoneDao dappOnHookDoneDao; |
| | | private final MemberCoinWithdrawDao memberCoinWithdrawDao; |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | |
| | | // BigDecimal totalProfit = igtOnHookPlanOrder.getProfit(); |
| | | BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | // BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | //更新用户表是否正在挂机状态字段为否 |
| | | //更新用户表是否正在挂机状态字段为结算中 |
| | | DappMemberEntity dappMember = dappMemberDao.selectById(memberId); |
| | | dappMember.setIsOnHook(3); |
| | | dappMemberDao.updateById(dappMember); |
| | |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | //获得总收益 |
| | | BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)); |
| | | if(multiply.compareTo(totalProfit) < 0){ |
| | | totalProfit = multiply; |
| | | } |
| | | |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | | //只有上级用户金额大于51U才能得到对应的佣金 |
| | | ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | for(String inviteId : refererIdList){ |
| | | DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | refererIdLisstUp.add(inviteId); |
| | | } |
| | | } |
| | | } |
| | | // ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | // for(String inviteId : refererIdList){ |
| | | // DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | // if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | // DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | // if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | // refererIdLisstUp.add(inviteId); |
| | | // } |
| | | // } |
| | | // } |
| | | //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdLisstUp, totalProfit,igtOnHookPlanOrder.getId()); |
| | | BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit,igtOnHookPlanOrder.getId()); |
| | | //生成流水佣金和盈利分成和流水记录,返回盈利分成和流水佣金总共分成 |
| | | // BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit,igtOnHookPlanOrder.getId()); |
| | | //平台分成 |
| | |
| | | Date date = dappOnHookAwardNow.getAwardTime(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String yyyyMMddHHMM = sdf.format(date); |
| | | List<DappOnHookAward> dappOnHookAwards = dappOnHookAwardDao.selectInfoByByAwardTime(yyyyMMddHHMM); |
| | | // List<DappOnHookAward> dappOnHookAwards = dappOnHookAwardDao.selectInfoByByAwardTime(yyyyMMddHHMM); |
| | | List<DappOnHookAward> dappOnHookAwards = dappOnHookAwardDao.selectByIdLimitTT(Long.parseLong(onHookAwardRedisId)); |
| | | if(CollUtil.isNotEmpty(dappOnHookAwards)){ |
| | | for(DappOnHookAward dappOnHookAward : dappOnHookAwards){ |
| | | ApiAwardInfoVo apiAwardInfoVo = new ApiAwardInfoVo(); |
| | |
| | | DateTime dateTime = DateUtil.offsetMinute(awardTime, 5); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String yyyyMMddHHMM = sdf.format(dateTime); |
| | | DappOnHookAward dappOnHookAwardNext = dappOnHookAwardDao.selectByByAwardTime(yyyyMMddHHMM); |
| | | long onHookAwardNextId = Long.parseLong(onHookAwardRedisId) + 1; |
| | | // DappOnHookAward dappOnHookAwardNext = dappOnHookAwardDao.selectByByAwardTime(yyyyMMddHHMM); |
| | | DappOnHookAward dappOnHookAwardNext = dappOnHookAwardDao.selectById(onHookAwardNextId); |
| | | |
| | | //系统挂机总次数 = 时长 * 60 / 5 |
| | | DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | |
| | | .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //获取收益 |
| | | //获取当前用户每分钟应该获取的收益 |
| | | //预期最大收益 |
| | | BigDecimal multiply = hangingRevenueLevel.multiply(planAmount); |
| | | DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | //挂机总时长(分钟) |
| | |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | //获得总收益 |
| | | BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | if(multiply.compareTo(totalProfit) < 0){ |
| | | totalProfit = multiply; |
| | | } |
| | | |
| | | // BigDecimal totalProfit = planAmount.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | | //只有上级用户金额大于51U才能得到对应的佣金 |
| | | ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | for(String inviteId : refererIdList){ |
| | | DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | refererIdLisstUp.add(inviteId); |
| | | } |
| | | } |
| | | } |
| | | // ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | // for(String inviteId : refererIdList){ |
| | | // DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | // if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | // DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | // if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | // refererIdLisstUp.add(inviteId); |
| | | // } |
| | | // } |
| | | // } |
| | | //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdLisstUp, totalProfit,igtOnHookPlanOrder.getId()); |
| | | BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit,igtOnHookPlanOrder.getId()); |
| | | //平台分成 |
| | | //平台拿走35%盈利分成和流水佣金剩下的全部 |
| | | BigDecimal systemAdd = totalProfit.multiply(new BigDecimal(0.4)).subtract(profitSharingTotal); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void memberCoinInsideMessage(Long orderId) { |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = memberCoinWithdrawDao.selectById(orderId); |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | //转出账户,总额减少,冻结减少 |
| | | BigDecimal amount = memberCoinWithdrawEntity.getAmount().setScale(4,BigDecimal.ROUND_DOWN); |
| | | Long memberIdOut = memberCoinWithdrawEntity.getMemberId(); |
| | | DappWalletCoinEntity dappWalletCoinEntityOut = dappWalletCoinDao.selectByMemberId(memberIdOut); |
| | | dappWalletCoinDao.delTotalAndDelFrozenById(dappWalletCoinEntityOut.getId(),amount); |
| | | |
| | | String content = "内部转账"; |
| | | Integer type = 4; |
| | | //转出账户生成一条账户资金变化记录 |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityOut = new DappAccountMoneyChangeEntity(memberIdOut, |
| | | dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN), |
| | | amount.negate(), |
| | | dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).subtract(amount), |
| | | content, |
| | | type); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityOut); |
| | | |
| | | //转入账户,总额增加,余额增加 |
| | | //转账 |
| | | String addressIn = memberCoinWithdrawEntity.getAddress(); |
| | | DappMemberEntity dappMemberEntityIn = dappMemberDao.selectMemberInfoByInviteId(addressIn); |
| | | DappWalletCoinEntity dappWalletCoinEntityIn = dappWalletCoinDao.selectByMemberId(dappMemberEntityIn.getId()); |
| | | Integer countIn = dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntityIn.getId(), memberCoinWithdrawEntity.getAmount()); |
| | | //生成流水记录 |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityIn = new DappAccountMoneyChangeEntity(dappMemberEntityIn.getId(), |
| | | dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN), |
| | | amount, |
| | | dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).add(amount), |
| | | "转账", |
| | | 4); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityIn); |
| | | } |
| | | |
| | | private String getProfitCase(String identity,BigDecimal balance){ |
| | | //匹配会员等级获取对应的收益率 |
| | | List<DataDictionaryCustom> dataDictionaryCustoms = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.LEVEL_MB.getType()); |