perf(mall): 优化节点助力功能
- 修改 AsyncService 接口,调整 releaseNodeCoin 方法参数格式
- 实现 AsyncServiceImpl 中的 releaseNodeCoin 方法,更名变量为"助力的碳币"
- 在 MemberProfitServiceImpl 中:
- 增加时间参数,计算指定时间段内的直推业绩
- 过滤掉业绩为零或负数的情况
- 更新会员的总监时间
- 修正 getDirectAchieve 方法,支持时间范围查询
| | |
| | | void releaseScore(BigDecimal amount,Long memberId); |
| | | |
| | | @Async(FebsConstant.ASYNC_POOL) |
| | | void releaseNodeCoin(BigDecimal amount,BigDecimal percent,BigDecimal balanceToCoin,Long memberId); |
| | | void releaseNodeCoin(BigDecimal amount, BigDecimal percent, BigDecimal balanceToCoin, Long memberId); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void releaseNodeCoin(BigDecimal amount, BigDecimal percent, BigDecimal balanceToCoin,Long memberId) { |
| | | //实际节点返利的金额 |
| | | public void releaseNodeCoin(BigDecimal amount, BigDecimal percent, BigDecimal balanceToCoin, Long memberId) { |
| | | //实际节点助力的碳币 |
| | | BigDecimal multiply = amount.multiply(percent); |
| | | if(BigDecimal.ZERO.compareTo(multiply) >=0){ |
| | | return; |
| | |
| | | RunVipDataDictionaryEnum.RUN_VIP_BALANCE_TO_COIN.getType(), |
| | | RunVipDataDictionaryEnum.RUN_VIP_BALANCE_TO_COIN.getCode()).getValue() |
| | | ).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | DateTime endTime = DateUtil.date(); |
| | | for (MallMember item : mallMembers) { |
| | | //获取总业绩 |
| | | BigDecimal achieve = getDirectAchieve(item.getInviteId()); |
| | | BigDecimal achieve = getDirectAchieve(item.getInviteId(),item.getDirectorTime(),endTime); |
| | | if(BigDecimal.ZERO.compareTo(achieve) >= 0){ |
| | | continue; |
| | | } |
| | | BigDecimal nodePercent = getNodePercent(runNodeSets, achieve); |
| | | if(BigDecimal.ZERO.compareTo(nodePercent) >= 0){ |
| | | continue; |
| | | } |
| | | asyncService.releaseNodeCoin(achieve,nodePercent,balanceToCoin,item.getId()); |
| | | item.setDirectorTime(endTime); |
| | | mallMemberMapper.updateById(item); |
| | | } |
| | | } |
| | | |
| | | private BigDecimal getDirectAchieve(String inviteId) { |
| | | private BigDecimal getDirectAchieve(String inviteId,Date startTime,Date endTime) { |
| | | |
| | | try { |
| | | // 获取直推成员和团队成员的ID集合 |
| | |
| | | new LambdaQueryWrapper<MallCharge>() |
| | | .in(MallCharge::getMemberId, memberIds) |
| | | .eq(MallCharge::getState, YesOrNoEnum.YES.getValue()) |
| | | .ge(MallCharge::getCreatedTime, startTime) |
| | | .lt(MallCharge::getCreatedTime, endTime) |
| | | ); |
| | | |
| | | if (CollUtil.isEmpty(mallCharges)) { |