From bfb1a0cc7642f59c5bc881fc83bd2ee4858564fe Mon Sep 17 00:00:00 2001 From: "fengyu.wang" Date: Tue, 27 Oct 2020 21:51:38 +0800 Subject: [PATCH] commit --- .../service/impl/AssessUserServiceImpl.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index 19db4ff..5758e91 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -1,5 +1,7 @@ package com.blockchain.server.yyyf.service.impl; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.server.train.dto.ExamPaperDto; import com.blockchain.server.train.dto.TrainCaseTargetDto; @@ -13,11 +15,13 @@ import com.blockchain.server.yyyf.entity.YyyfMoney; import com.blockchain.server.yyyf.enums.YyyfEnums; import com.blockchain.server.yyyf.exceprion.YyyfException; import com.blockchain.server.yyyf.indicators.IndicatorsManager; +import com.blockchain.server.yyyf.indicators.dto.AssetsReporter; import com.blockchain.server.yyyf.mapper.AssessUserMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.TrainCaseManageMapper; import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper; import com.blockchain.server.yyyf.service.AssessUserService; +import com.blockchain.server.yyyf.service.AssetsReporterService; import com.blockchain.server.yyyf.utils.HttpClientUtil; import com.blockchain.server.yyyf.utils.IdGenerator; import lombok.SneakyThrows; @@ -63,6 +67,8 @@ public class AssessUserServiceImpl implements AssessUserService { @Autowired private IndicatorsManager indicatorsManager; + @Autowired + private AssetsReporterService assetsReporterService; @Value("${yyyf.url}") @@ -148,6 +154,19 @@ public class AssessUserServiceImpl implements AssessUserService { if (assessUser.getEndTime() != null) { throw new YyyfException(YyyfEnums.PROHIBIT_DUPLICATE_SUBMISSION); } + //计算当前时间收益 + BigDecimal assets = indicatorsManager.calculateCurrentTotalAssets(assessUser.getQUserId(), assessUserId); + Date now = new Date(); + assetsReporterService.saveList(Collections.singletonList(AssetsReporter.builder() + .id(IdGenerator.uuid()) + .assessUserId(assessUserId) + .assets(assets) + //不满一天按一天计算 + .days(DateUtil.between(assessUser.getStartTime(), now, DateUnit.DAY) + 1) + .coinName("RMB") + .createTime(now) + .build())); + Double totalScore = 0d; //获取指标信息 Example example = new Example(AssessUserTarget.class); @@ -172,7 +191,6 @@ public class AssessUserServiceImpl implements AssessUserService { } Date startTime = assessUser.getStartTime(); - Date now = new Date(); assessUser.setTotalScore(totalScore); assessUser.setEndTime(now); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -343,4 +361,4 @@ public class AssessUserServiceImpl implements AssessUserService { } -} \ No newline at end of file +}