| | |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MoneyFlowEnum; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappStorageMapper; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | private DappStorageMapper dappStorageMapper; |
| | | @Resource |
| | | private DappMemberDao dappMemberDao; |
| | | @Resource |
| | | private ChainProducer chainProducer; |
| | | @Resource |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | |
| | | /** |
| | | * 每天释放1%的静态释放 |
| | |
| | | for(DappStorage storage : dappStorages){ |
| | | Long memberId = storage.getMemberId(); |
| | | BigDecimal releaseAmount = storage.getReleaseAmount(); |
| | | |
| | | /** |
| | | * DAO成员动态: |
| | | * * 1.直推1个拿2代,直推10个拿20代,直推15个拿30代,最高30代 |
| | | */ |
| | | chainProducer.sendMemberDynamicPerkMsg(storage.getId()); |
| | | |
| | | dappSystemService.updateBalanceInsertFlow( |
| | | releaseAmount, |
| | | memberId, |
| | |
| | | * (其中50%给予当天大单排名激励前4名,40%、30%、20、10%; |
| | | * 另外50% 给予当天直推总业绩排名激励前10名,第1名40%,2-4名30%,5-10名30%) |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | @Scheduled(cron = "0 0/1 0 * * ?") |
| | | public void profitDailyJobOne() { |
| | | |
| | | Date date = new Date(); |
| | | DappStorage dappStorageLast = dappStorageMapper.selectOneByCreateTimeDesc(0, 1); |
| | | DateTime dateTime1 = DateUtil.offsetHour(dappStorageLast.getCreateTime(), 24); |
| | | int compare = DateUtil.compare(dateTime1, date); |
| | | if(compare > 0){ |
| | | return; |
| | | } |
| | | |
| | | DataDictionaryCustom symbolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCHANG_SYMBOL.getType(), |
| | | DataDictionaryEnum.BUCHANG_SYMBOL.getCode() |
| | | ); |
| | | if(2 == Integer.parseInt(symbolDic.getValue())){ |
| | | return; |
| | | } |
| | | symbolDic.setValue("2"); |
| | | dataDictionaryCustomMapper.updateById(symbolDic); |
| | | |
| | | DataDictionaryCustom buChangChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode() |
| | |
| | | BigDecimal everyAmount = daDanTotal.divide(new BigDecimal(count)); |
| | | |
| | | if(everyAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | DappStorage dappStorageOne = dappStorageMapper.selectAmountByDesc(new Date(),0,1); |
| | | if(ObjectUtil.isNotEmpty(dappStorageOne)){ |
| | | List<DappStorage> dappStorageOne = dappStorageMapper.selectSumByAmountDescFiveToFive(DateUtil.offsetHour(new Date(),-24),0,1); |
| | | if(CollUtil.isNotEmpty(dappStorageOne)){ |
| | | BigDecimal multiply = everyAmount.multiply(new BigDecimal(oneCount)); |
| | | dappSystemService.updateBalanceInsertFlow( |
| | | multiply, |
| | | dappStorageOne.getMemberId(), |
| | | dappStorageOne.get(0).getMemberId(), |
| | | MoneyFlowEnum.DA_DAN_JI_LI_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.DA_DAN_JI_LI_PERK.getDescrition(),daDanTotal,multiply)); |
| | | |
| | | realAmount = realAmount.add(multiply); |
| | | } |
| | | DappStorage dappStorageTwo = dappStorageMapper.selectAmountByDesc(new Date(),1,1); |
| | | if(ObjectUtil.isNotEmpty(dappStorageTwo)){ |
| | | List<DappStorage> dappStorageTwo = dappStorageMapper.selectSumByAmountDescFiveToFive(DateUtil.offsetHour(new Date(),-24),1,1); |
| | | if(CollUtil.isNotEmpty(dappStorageTwo)){ |
| | | BigDecimal multiply = everyAmount.multiply(new BigDecimal(twoCount)); |
| | | dappSystemService.updateBalanceInsertFlow( |
| | | multiply, |
| | | dappStorageTwo.getMemberId(), |
| | | dappStorageTwo.get(0).getMemberId(), |
| | | MoneyFlowEnum.DA_DAN_JI_LI_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.DA_DAN_JI_LI_PERK.getDescrition(),daDanTotal,multiply)); |
| | | |
| | | realAmount = realAmount.add(multiply); |
| | | } |
| | | DappStorage dappStorageThree = dappStorageMapper.selectAmountByDesc(new Date(),2,1); |
| | | if(ObjectUtil.isNotEmpty(dappStorageThree)){ |
| | | List<DappStorage> dappStorageThree = dappStorageMapper.selectSumByAmountDescFiveToFive(DateUtil.offsetHour(new Date(),-24),2,1); |
| | | if(CollUtil.isNotEmpty(dappStorageThree)){ |
| | | BigDecimal multiply = everyAmount.multiply(new BigDecimal(threeCount)); |
| | | dappSystemService.updateBalanceInsertFlow( |
| | | multiply, |
| | | dappStorageThree.getMemberId(), |
| | | dappStorageThree.get(0).getMemberId(), |
| | | MoneyFlowEnum.DA_DAN_JI_LI_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.DA_DAN_JI_LI_PERK.getDescrition(),daDanTotal,multiply)); |
| | | |
| | | realAmount = realAmount.add(multiply); |
| | | } |
| | | DappStorage dappStorageFour = dappStorageMapper.selectAmountByDesc(new Date(),3,1); |
| | | if(ObjectUtil.isNotEmpty(dappStorageFour)){ |
| | | List<DappStorage> dappStorageFour = dappStorageMapper.selectSumByAmountDescFiveToFive(DateUtil.offsetHour(new Date(),-24),3,1); |
| | | if(CollUtil.isNotEmpty(dappStorageFour)){ |
| | | BigDecimal multiply = everyAmount.multiply(new BigDecimal(fourCount)); |
| | | dappSystemService.updateBalanceInsertFlow( |
| | | multiply, |
| | | dappStorageFour.getMemberId(), |
| | | dappStorageFour.get(0).getMemberId(), |
| | | MoneyFlowEnum.DA_DAN_JI_LI_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.DA_DAN_JI_LI_PERK.getDescrition(),daDanTotal,multiply)); |
| | | |
| | |
| | | * 另外50% 给予当天直推总业绩排名激励前10名,第1名40%,2-4名30%,5-10名30% |
| | | */ |
| | | BigDecimal directTotal = jiLiTotal.multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_DOWN); |
| | | // /** |
| | | // * 存放直推业绩<上级的memberId,直推总业绩> |
| | | // */ |
| | | // HashMap<Long, BigDecimal> map = new HashMap<>(); |
| | | // |
| | | // List<DappStorage> dappStorages = dappStorageMapper.selectListByDate(new Date()); |
| | | // if(CollUtil.isNotEmpty(dappStorages)){ |
| | | // for(DappStorage dappStorage : dappStorages){ |
| | | // DappMemberEntity member = dappMemberDao.selectById(dappStorage.getMemberId()); |
| | | // if(StrUtil.isEmpty(member.getRefererId())){ |
| | | // continue; |
| | | // } |
| | | // DappMemberEntity memberRef = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | | // if(ObjectUtil.isEmpty(memberRef)){ |
| | | // continue; |
| | | // } |
| | | // Long id = memberRef.getId(); |
| | | // if(map.containsKey(id)){ |
| | | // BigDecimal bigDecimal = map.get(id); |
| | | // BigDecimal add = bigDecimal.add(dappStorage.getAmount()); |
| | | // map.put(id,add); |
| | | // }else{ |
| | | // map.put(id,dappStorage.getAmount()); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 存放直推业绩<上级的memberId,直推总业绩> |
| | | * 存放直推人数<上级的memberId,直推人数> |
| | | */ |
| | | HashMap<Long, BigDecimal> map = new HashMap<>(); |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | for(DappStorage dappStorage : dappStorages){ |
| | | DappMemberEntity member = dappMemberDao.selectById(dappStorage.getMemberId()); |
| | | DateTime startTime = DateUtil.offsetHour(new Date(), -24); |
| | | // DateTime startTime = DateUtil.parseDateTime(startTimeStr); |
| | | // List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectListByDateFiveToFiver(startTime); |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectListByDateFiveToFiver(startTime); |
| | | Set<Long> collect = dappStorages.stream().map(DappStorage::getMemberId).collect(Collectors.toSet()); |
| | | |
| | | // List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(collect)){ |
| | | for(Long memberId : collect){ |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | if(StrUtil.isEmpty(member.getRefererId())){ |
| | | continue; |
| | | } |
| | | if(2 == member.getActiveStatus()){ |
| | | continue; |
| | | } |
| | | DappMemberEntity memberRef = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | |
| | | Long id = memberRef.getId(); |
| | | if(map.containsKey(id)){ |
| | | BigDecimal bigDecimal = map.get(id); |
| | | BigDecimal add = bigDecimal.add(dappStorage.getAmount()); |
| | | BigDecimal add = bigDecimal.add(new BigDecimal("1")); |
| | | map.put(id,add); |
| | | }else{ |
| | | map.put(id,dappStorage.getAmount()); |
| | | map.put(id,new BigDecimal("1")); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | Date date = new Date(); |
| | | System.out.println(date); |
| | | DateTime dateTime1 = DateUtil.offsetHour(date, 24); |
| | | System.out.println(dateTime1); |
| | | |
| | | int compare = DateUtil.compare(date, dateTime1); |
| | | System.out.println(compare); |
| | | |
| | | |
| | | |
| | | DateTime dateTime = DateUtil.offsetHour(new Date(), -24); |
| | | System.out.println(dateTime); |
| | | DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(new Date())); |
| | | DateTime perkTime = DateUtil.parseTime("17:00:00"); |
| | | |
| | | String startTimeStr = null; |
| | | if(DateUtil.compare(nowTime,perkTime) >= 0){ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), 0)) + " 17:00:00"; |
| | | }else{ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1)) + " 17:00:00"; |
| | | } |
| | | |
| | | DateTime startTime = DateUtil.parseDateTime(startTimeStr); |
| | | |
| | | |
| | | |
| | | // 创建一个HashMap示例 |