| | |
| | | import cc.mrbird.febs.dapp.vo.ApiPlanInfoVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | public FebsResponse endPlan(Long orderId) { |
| | | DappMemberEntity dappMemberEntity = LoginUserUtil.getAppUser(); |
| | | Long memberId = dappMemberEntity.getId(); |
| | | //判断系统是否已经结算过了 |
| | | QueryWrapper<DappOnHookDone> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("order_id",orderId); |
| | | List<DappOnHookDone> dappOnHookDones = dappOnHookDoneDao.selectList(objectQueryWrapper); |
| | |
| | | igtOnHookPlanOrder.setState(2); |
| | | igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | |
| | | BigDecimal totalProfit = igtOnHookPlanOrder.getProfit(); |
| | | // BigDecimal totalProfit = igtOnHookPlanOrder.getProfit(); |
| | | BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | // BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | //更新用户表是否正在挂机状态字段为否 |
| | | DappMemberEntity dappMember = dappMemberDao.selectById(memberId); |
| | | |
| | | dappMember.setIsOnHook(3); |
| | | dappMemberDao.updateById(dappMember); |
| | | |
| | | //获取当前用户每分钟应该获取的收益 |
| | | String identity = dappMember.getIdentity(); |
| | | //当前用户的挂机收益率 |
| | | BigDecimal hangingRevenue = getHangingRevenue(identity); |
| | | BigDecimal multiply = hangingRevenue.multiply(planAmount); |
| | | DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | //挂机总时长(分钟) |
| | | BigDecimal maxHours = new BigDecimal(maxHoursDic.getValue()).multiply(new BigDecimal(60)); |
| | | //得到每分钟的收益 |
| | | BigDecimal minuteProfit = multiply.divide(maxHours, 4, BigDecimal.ROUND_DOWN); |
| | | //获取挂机开始时间到现在的总时长(分钟数) |
| | | Date startTime = igtOnHookPlanOrder.getStartTime(); |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | //获得总收益 |
| | | BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)); |
| | | |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | |
| | | //平台分成,返回剩余盈利 |
| | | BigDecimal systemTotal = dappWalletService.updatePTFC(memberId,igtOnHookPlanOrder.getProfit(),igtOnHookPlanOrder.getId()); |
| | | totalProfit = totalProfit.subtract(profitSharingTotal).subtract(systemTotal); |
| | | BigDecimal totalMoney = avaAmount.add(totalProfit); |
| | | // BigDecimal totalMoney = avaAmount.add(totalProfit); |
| | | BigDecimal totalMoney = planAmount.add(totalProfit); |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntity.getId(),totalMoney); |
| | | |
| | |
| | | dappOnHookDoneDao.insert(dappOnHookDone); |
| | | |
| | | return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001")); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | DateTime startTime = DateUtil.offsetMinute(DateUtil.date(), 10); |
| | | |
| | | System.out.println(startTime); |
| | | System.out.println(DateUtil.date()); |
| | | |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | System.out.println(between); |
| | | } |
| | | |
| | | |
| | | private BigDecimal getHangingRevenue(String identity){ |
| | | DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), identity); |
| | | String dataDictionaryCustomValue = dataDictionaryCustom.getValue(); |
| | | cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dataDictionaryCustomValue); |
| | | String runningCommission = jsonObject.get("hangingRevenue").toString(); |
| | | return new BigDecimal(runningCommission).multiply(new BigDecimal(0.01)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | BigDecimal hangingRevenueLevel = new BigDecimal(identityDicValueParse.get("hangingRevenue").toString()) |
| | | .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //获取收益 |
| | | BigDecimal totalProfit = planAmount.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //获取当前用户每分钟应该获取的收益 |
| | | BigDecimal multiply = hangingRevenueLevel.multiply(planAmount); |
| | | DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | //挂机总时长(分钟) |
| | | BigDecimal maxHours = new BigDecimal(maxHoursDic.getValue()).multiply(new BigDecimal(60)); |
| | | //得到每分钟的收益 |
| | | BigDecimal minuteProfit = multiply.divide(maxHours, 4, BigDecimal.ROUND_DOWN); |
| | | //获取挂机开始时间到现在的总时长(分钟数) |
| | | Date startTime = igtOnHookPlanOrder.getStartTime(); |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | //获得总收益 |
| | | BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // BigDecimal totalProfit = planAmount.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | DateTime nowTime = DateUtil.parseTimeToday(DateUtil.format(DateUtil.date(),"HH:mm:ss")); |
| | | System.out.println(nowTime); |
| | | int maxTimes = 10; |
| | | for(int i =1;i<maxTimes;){ |
| | | maxTimes --; |
| | | System.out.println(maxTimes); |
| | | } |
| | | } |
| | | // public static void main(String[] args) { |
| | | // |
| | | // DateTime nowTime = DateUtil.parseTimeToday(DateUtil.format(DateUtil.date(),"HH:mm:ss")); |
| | | // System.out.println(nowTime); |
| | | // int maxTimes = 10; |
| | | // for(int i =1;i<maxTimes;){ |
| | | // maxTimes --; |
| | | // System.out.println(maxTimes); |
| | | // } |
| | | // } |
| | | } |