|
|
|
@ -74,12 +74,12 @@ public class ProfitManagementServiceImpl implements ProfitManagementService {
|
|
|
|
|
|
|
|
|
|
profitManagementMapper.updateByPrimaryKey(profitManagement);
|
|
|
|
|
if (!(userMarketValue.compareTo(marketValue) == 0)) {
|
|
|
|
|
return new ResultEntity(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue);
|
|
|
|
|
} else {
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitManagementMarketValueScore", 2, profitManagement.getFlowId());
|
|
|
|
|
}
|
|
|
|
|
if (!(userFundEarnings.compareTo(fundEarnings) == 0)) {
|
|
|
|
|
return new ResultEntity(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings);
|
|
|
|
|
} else {
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitManagementFundScore", 2, profitManagement.getFlowId());
|
|
|
|
|
}
|
|
|
|
@ -93,25 +93,7 @@ public class ProfitManagementServiceImpl implements ProfitManagementService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ExitTime getExitTime(String flowId) {
|
|
|
|
|
ExitTime dataExitTime = exitTimeMapper.selectByPrimaryKey(flowId);
|
|
|
|
|
if (dataExitTime != null) {
|
|
|
|
|
return dataExitTime;
|
|
|
|
|
} else {
|
|
|
|
|
ExitTime exitTime = new ExitTime();
|
|
|
|
|
List<ProfitManagement> profitManagementList = getLineChart(flowId);
|
|
|
|
|
if (profitManagementList.isEmpty()){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
ProfitManagement profitManagement = profitManagementList.get(0);
|
|
|
|
|
exitTime.setFlowId(flowId);
|
|
|
|
|
exitTime.setProjectName(profitManagement.getProjectName());
|
|
|
|
|
exitTime.setInvestmentAmount(profitManagement.getInvestmentAmount());
|
|
|
|
|
exitTime.setShareRatio(profitManagement.getShareRatio());
|
|
|
|
|
exitTime.setTotalEquity(profitManagement.getTotalEquity());
|
|
|
|
|
exitTime.setShareCount(profitManagement.getShareCount());
|
|
|
|
|
exitTimeMapper.insert(exitTime);
|
|
|
|
|
return exitTime;
|
|
|
|
|
}
|
|
|
|
|
return exitTimeMapper.selectByPrimaryKey(flowId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -122,37 +104,46 @@ public class ProfitManagementServiceImpl implements ProfitManagementService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price,
|
|
|
|
|
BigDecimal userMarketValue, BigDecimal userFundEarnings) {
|
|
|
|
|
ExitTime exitTimeEntity = exitTimeMapper.selectByPrimaryKey(flowId);
|
|
|
|
|
ExitTime exitTimeEntity =new ExitTime();
|
|
|
|
|
List<ProfitManagement> profitManagementList = getLineChart(flowId);
|
|
|
|
|
if (profitManagementList.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
ProfitManagement profitManagement = profitManagementList.get(0);
|
|
|
|
|
exitTimeEntity.setFlowId(flowId);
|
|
|
|
|
exitTimeEntity.setProjectName(profitManagement.getProjectName());
|
|
|
|
|
exitTimeEntity.setInvestmentAmount(profitManagement.getInvestmentAmount());
|
|
|
|
|
exitTimeEntity.setShareRatio(profitManagement.getShareRatio());
|
|
|
|
|
exitTimeEntity.setTotalEquity(profitManagement.getTotalEquity());
|
|
|
|
|
exitTimeEntity.setShareCount(profitManagement.getShareCount());
|
|
|
|
|
exitTimeEntity.setExitTiming(exitTime);
|
|
|
|
|
exitTimeEntity.setExitStockPrice(price);
|
|
|
|
|
exitTimeEntity.setUserMarketValue(userMarketValue);
|
|
|
|
|
exitTimeEntity.setUserFundEarnings(userFundEarnings);
|
|
|
|
|
//公司市值=股票价格*总股本
|
|
|
|
|
BigDecimal marketValue = exitTimeEntity.getExitStockPrice().multiply(exitTimeEntity.getTotalEquity()).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
BigDecimal marketValue = price.multiply(exitTimeEntity.getTotalEquity()).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
exitTimeEntity.setExitMarketValue(marketValue);
|
|
|
|
|
exitTimeEntity.setUserMarketValue(userMarketValue);
|
|
|
|
|
//基金收益=持股数量*股票价格-投资金额
|
|
|
|
|
BigDecimal fundEarnings = exitTimeEntity.getShareCount().multiply(exitTimeEntity.getExitStockPrice()).subtract(exitTimeEntity.getInvestmentAmount()).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
exitTimeEntity.setUserFundEarnings(userFundEarnings);
|
|
|
|
|
BigDecimal fundEarnings = exitTimeEntity.getShareCount().multiply(price).subtract(exitTimeEntity.getInvestmentAmount()).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
exitTimeEntity.setExitFundEarnings(fundEarnings);
|
|
|
|
|
// 退出时收益率 = 基金收益 / 投资金额
|
|
|
|
|
BigDecimal exitYield = exitTimeEntity.getExitFundEarnings().divide(exitTimeEntity.getInvestmentAmount(), 2, RoundingMode.HALF_UP);
|
|
|
|
|
BigDecimal exitYield = profitManagement.getFundEarnings().divide(exitTimeEntity.getInvestmentAmount(), 2, RoundingMode.HALF_UP);
|
|
|
|
|
exitTimeEntity.setExitYield(exitYield);
|
|
|
|
|
exitTimeMapper.updateByPrimaryKey(exitTimeEntity);
|
|
|
|
|
exitTimeMapper.insert(exitTimeEntity);
|
|
|
|
|
//标记页面完成时间
|
|
|
|
|
PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId);
|
|
|
|
|
performanceScore.setProfitManagementTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
if (!(userMarketValue.compareTo(marketValue) == 0)) {
|
|
|
|
|
return new ResultEntity(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue);
|
|
|
|
|
} else {
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitManagementFundExitScore", 3, flowId);
|
|
|
|
|
}
|
|
|
|
|
if (!(userFundEarnings.compareTo(fundEarnings) == 0)) {
|
|
|
|
|
return new ResultEntity(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings);
|
|
|
|
|
} else {
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitManagementMarketValueExitScore", 3, flowId);
|
|
|
|
|
}
|
|
|
|
|
//标记页面完成时间
|
|
|
|
|
PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId);
|
|
|
|
|
performanceScore.setProfitManagementTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|