TotalGrowthRateIndicatorsHandler

pull/2/head
fengyu.wang 5 years ago
parent c0355bc45e
commit e1cef2e391
  1. 19
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TotalGrowthRateIndicatorsHandler.java

@ -1,9 +1,12 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.IndicatorsUtils;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.indicators.dto.LastAndFirstAssetsDto;
import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
@ -11,6 +14,8 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
import static cn.hutool.core.util.NumberUtil.add;
/**
* @author fengyu
*/
@ -20,6 +25,8 @@ public class TotalGrowthRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "TotalGrowthRate";
private final AssetsReporterService assetsReporterService;
private final AssessUserService assessUserService;
private final AssessUserMapper assessUserMapper;
@Override
public Float handleIndicator(String assessUserId) {
@ -27,14 +34,16 @@ public class TotalGrowthRateIndicatorsHandler implements IndicatorsHandler {
//获取最初、最后交易的信息
LastAndFirstAssetsDto lastAndFirstAssetsDto = IndicatorsUtils.getLastAndFirstAssetsDto(reporterList);
AssetsReporter lastAssets =lastAndFirstAssetsDto.getLastAssets();
AssetsReporter firstAssets =lastAndFirstAssetsDto.getFirstAssets();
AssetsReporter lastAssets = lastAndFirstAssetsDto.getLastAssets();
AssetsReporter firstAssets = lastAndFirstAssetsDto.getFirstAssets();
//充值的总金额
//todo 不知道如何获取
BigDecimal rechargeAmount=null;
List<UserTimeMoneyDto> userTimeMoneyList = assessUserService.selectUserTimeMoneyDtosForNotEnd();
String sysUserId = userTimeMoneyList.stream().filter(dto -> dto.getAssessUserId().equals(assessUserId)).findFirst().map(UserTimeMoneyDto::getQUserId).get();
UserTimeMoneyDto timeMoneyDto = assessUserMapper.selectCurrentUserTimeMoneyDto(assessUserId, sysUserId);
BigDecimal rechargeAmount = add(timeMoneyDto.getAliPayInit(), timeMoneyDto.getWxPayInit(), timeMoneyDto.getBankCardInit());
return lastAssets.getAssets().subtract(firstAssets.getAssets()).divide(rechargeAmount,4,BigDecimal.ROUND_HALF_UP)
return lastAssets.getAssets().subtract(firstAssets.getAssets()).divide(rechargeAmount, 4, BigDecimal.ROUND_HALF_UP)
.multiply(BigDecimal.valueOf(100)).floatValue();
}
}

Loading…
Cancel
Save