From e1cef2e391ec3dfea2b7671c6e0c214ebcbd5021 Mon Sep 17 00:00:00 2001 From: "fengyu.wang" Date: Mon, 15 Jun 2020 22:31:47 +0800 Subject: [PATCH] TotalGrowthRateIndicatorsHandler --- .../TotalGrowthRateIndicatorsHandler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TotalGrowthRateIndicatorsHandler.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TotalGrowthRateIndicatorsHandler.java index 4fe2f31..490130e 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TotalGrowthRateIndicatorsHandler.java +++ b/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 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(); } }