| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | BigDecimal V3 = BigDecimal.ZERO; |
| | | if (flag) { |
| | | V2 = V1.divide(new BigDecimal("2"), 0, RoundingMode.DOWN); |
| | | V3 = new BigDecimal(RandomUtil.randomInt(V2.intValue(),V1.intValue())).setScale(0,RoundingMode.DOWN); |
| | | if(V1.intValue() <= V2.intValue()){ |
| | | V3 = new BigDecimal(RandomUtil.randomInt(V1.intValue(),V2.intValue()+1)).setScale(0,RoundingMode.DOWN); |
| | | }else{ |
| | | V3 = new BigDecimal(RandomUtil.randomInt(V2.intValue(),V1.intValue())).setScale(0,RoundingMode.DOWN); |
| | | } |
| | | }else{ |
| | | List<MallMoneyFlow> mallMoneyFlows = mallMoneyFlowMapper.selectList( |
| | | new LambdaQueryWrapper<MallMoneyFlow>() |
| | |
| | | BigDecimal amountNow = runVipGrow.getAmountNow(); |
| | | RunVip runVipNext = runVips.stream().filter(vipItem -> vipItem.getOrderNumber() == runVip.getOrderNumber() + 1).findFirst().orElse(null); |
| | | if(runVipNext != null){ |
| | | |
| | | BigDecimal presentPrice = runVip.getPresentPrice(); |
| | | amountNow = amountNow.subtract(presentPrice); |
| | | |
| | | BigDecimal presentPriceNext = runVipNext.getPresentPrice(); |
| | | BigDecimal subtract = presentPriceNext.subtract(presentPrice); |
| | | |
| | |
| | | |
| | | BigDecimal growthAmountTotal = divide.multiply(new BigDecimal(growthNum)); |
| | | BigDecimal growthAmount = growthAmountTotal.divide(new BigDecimal(C1), 0, RoundingMode.DOWN); |
| | | V3 = V3.add(growthAmount); |
| | | if(growthAmount.intValue() > 0){ |
| | | V3 = V3.add(growthAmount); |
| | | } |
| | | } |
| | | } |
| | | //更新钱包数据 |
| | |
| | | .collect(Collectors.toMap(MallMember::getId, member -> member)); |
| | | // 缓存直推成员 |
| | | Map<String, Set<MallMember>> directMembersCache = mallMembers.stream() |
| | | .filter(member -> StrUtil.isNotBlank(member.getReferrerId())) |
| | | .collect(Collectors.groupingBy(MallMember::getReferrerId, Collectors.toSet())); |
| | | |
| | | |
| | |
| | | continue; |
| | | } |
| | | for (MallMember item : directMembers) { |
| | | CompletableFuture.runAsync(() -> { |
| | | BigDecimal realScore = calculateDirectScore(memberRunVip, item, operationDate, runVipMap); |
| | | if(BigDecimal.ZERO.compareTo(realScore) >= 0){ |
| | | return; |
| | | } |
| | | walletService.addScore(realScore, memberId); |
| | | String orderNo = MallUtils.getOrderNum("ZLS"); |
| | | mallMoneyFlowService.runVipMoneyFlowAdd( |
| | | memberId, |
| | | item.getId(), |
| | | orderNo, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getValue(), |
| | | realScore, |
| | | StrUtil.format(RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getDescription(), realScore), |
| | | YesOrNoEnum.YES.getValue() |
| | | ); |
| | | },febsConfigure.asyncThreadPoolTaskExecutor()); |
| | | BigDecimal realScore = calculateDirectScore(memberRunVip, item, operationDate, runVipMap); |
| | | if(BigDecimal.ZERO.compareTo(realScore) >= 0){ |
| | | return; |
| | | } |
| | | walletService.addScore(realScore, memberId); |
| | | String orderNo = MallUtils.getOrderNum("ZLS"); |
| | | mallMoneyFlowService.runVipMoneyFlowAdd( |
| | | memberId, |
| | | item.getId(), |
| | | orderNo, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getValue(), |
| | | realScore, |
| | | StrUtil.format(RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getDescription(), realScore), |
| | | YesOrNoEnum.YES.getValue() |
| | | ); |
| | | // CompletableFuture.runAsync(() -> { |
| | | // BigDecimal realScore = calculateDirectScore(memberRunVip, item, operationDate, runVipMap); |
| | | // if(BigDecimal.ZERO.compareTo(realScore) >= 0){ |
| | | // return; |
| | | // } |
| | | // walletService.addScore(realScore, memberId); |
| | | // String orderNo = MallUtils.getOrderNum("ZLS"); |
| | | // mallMoneyFlowService.runVipMoneyFlowAdd( |
| | | // memberId, |
| | | // item.getId(), |
| | | // orderNo, |
| | | // FlowTypeEnum.SCORE.getValue(), |
| | | // RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getValue(), |
| | | // realScore, |
| | | // StrUtil.format(RunVipMoneyFlowTypeEnum.DIRECT_SCORE.getDescription(), realScore), |
| | | // YesOrNoEnum.YES.getValue() |
| | | // ); |
| | | // },febsConfigure.asyncThreadPoolTaskExecutor()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |