修改收益管理,新增基金募资金额字段

master
xiaoCJ 1 year ago
parent e54e8ca2d3
commit dcdc378c4b

@ -12,6 +12,10 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* @Author xcj
* @Date 2023/12/6
@ -41,11 +45,13 @@ public class ProfitDistributionController {
@AnonymousAccess
@PostMapping("/getType")
@ApiOperation("返回基金募集的类型")
public Integer submit(@RequestParam String flowId) {
@ApiOperation("返回基金募集的类型和总金额")
public ResultEntity<Map<Integer, BigDecimal>> submit(@RequestParam String flowId) {
Fundraising fundraising = fundraisingService.selectByFlowId(flowId);
if (fundraising!=null) {
return fundraising.getType();
Map<Integer, BigDecimal> map = new HashMap<>();
if (fundraising != null) {
map.put(fundraising.getType(), fundraising.getFundraisingAmount());
return new ResultEntity<>(map);
}
return null;
}

@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -66,11 +67,11 @@ public class ProfitManagementController {
@ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案")
@AnonymousAccess
@GetMapping("/getExitTimeRightMarketValueAndFundEarnings")
public ResultEntity getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId,
@ApiParam("退出时间") @RequestParam String exitTime,
@ApiParam("随机生成的价格") @RequestParam BigDecimal price,
@ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue,
@ApiParam("用户输入的基金收益") @RequestParam BigDecimal userFundEarnings) {
public ResultEntity<HttpStatus> getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId,
@ApiParam("退出时间") @RequestParam String exitTime,
@ApiParam("随机生成的价格") @RequestParam BigDecimal price,
@ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue,
@ApiParam("用户输入的基金收益") @RequestParam BigDecimal userFundEarnings) {
return profitManagementService.getExitTimeRightMarketValueAndFundEarnings(flowId, exitTime, price, userMarketValue, userFundEarnings);
}
@ -88,7 +89,7 @@ public class ProfitManagementController {
@ApiOperation("判断市值和基金收益对错,计算错误则返回正确答案")
@AnonymousAccess
@GetMapping("/getRightMarketValueAndFundEarnings")
public ResultEntity getStockInfo(@RequestParam @ApiParam("getLineChart返回的Id") String id,
public ResultEntity<HttpStatus> getStockInfo(@RequestParam @ApiParam("getLineChart返回的Id") String id,
@ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue,
@ApiParam("用户输入的基金收益") @RequestParam BigDecimal userFundEarnings) {
return profitManagementService.getRightMarketValueAndFundEarnings(id, userMarketValue, userFundEarnings);

@ -3,6 +3,7 @@ package com.sztzjy.fund_investment.service;
import com.sztzjy.fund_investment.entity.ExitTime;
import com.sztzjy.fund_investment.entity.ProfitManagement;
import com.sztzjy.fund_investment.util.ResultEntity;
import org.springframework.http.HttpStatus;
import java.math.BigDecimal;
import java.util.List;
@ -16,9 +17,9 @@ public interface ProfitManagementService {
ProfitManagement getStockInfo(String id);
ResultEntity getRightMarketValueAndFundEarnings(String id, BigDecimal userMarketValue, BigDecimal userFundEarnings);
ResultEntity<HttpStatus> getRightMarketValueAndFundEarnings(String id, BigDecimal userMarketValue, BigDecimal userFundEarnings);
ExitTime getExitTime(String flowId);
ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, BigDecimal userMarketValue, BigDecimal userFundEarnings);
ResultEntity<HttpStatus> getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, BigDecimal userMarketValue, BigDecimal userFundEarnings);
}

@ -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;
}
}

Loading…
Cancel
Save