Commit f628a3cb authored by 刘长帅's avatar 刘长帅

Merge branch 'master-regeneration-24-02-21' into dev-test

parents 0aff1a16 86a5e77c
......@@ -134,7 +134,9 @@ public interface AdminConstant {
PREMIUM("Premium",1, "私人定制")
, FOLLOW_UP("FollowUp",2, "跟投账户")
, ASSET_TYPE("AssetType",3, "资管")
, SMART_TYPE("SmartType",4, "智能跟投");
, SMART_TYPE("SmartType",4, "智能跟投")
, SURVEY_TYPE("SurveyType",5, "项目调研")
, HIGH_TYPE("HighType",6, "高端定制");
private final String code;
......
......@@ -40,4 +40,6 @@ public class RedisKeyMessageConstant {
public static final String REDIS_SEND_CM_KEY="CM:redisId:code:key";
public static final String SendCustomerReportForms="ZG:CR:KEY:SCMF";
public static final String SendPersonalCustomerReportForms="ZG:CR:KEY:PERSONAL";
public static final String RedisUpdateGraphKey="BLG:graph:type:KEY";
}
package com.zfxftech.telmarket.common.pojo.dao;
import lombok.Data;
@Data
public class UpdateWriteOffChangeLog {
/**
* 产品类型 Premium--私人定制 AssetType--资管 SmartType--智能跟投
*/
private String type;
/**
*示范盘id
*/
private String marketId;
}
package com.zfxftech.telmarket.common.pojo.dao.survey;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Description TODO
* @Author Dell
* @Date 2021/11/27 15:20
*
*/
@Data
@TableName(value = "survey_market_profit_log")
public class SurveyMarketProfitLog {
/**
* 唯一标记
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 示范盘Id
*/
private Long marketId;
/**
* 本金
*/
private BigDecimal principal;
/**
* 总收益
*/
private BigDecimal profit;
/**
* 较上一日增量收益
*/
private BigDecimal incrementProfit;
/**
* 收益率
*/
private BigDecimal profitRate;
/**
* 日期
*/
private Date date;
/**
* 删除标记
*/
@TableLogic
@TableField(value = "is_deleted")
private String isDeleted;
/**
* 创建时间
*/
private Date createdTime;
}
package com.zfxftech.telmarket.mapper.business.survey;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyMarketProfitLog;
import org.springframework.stereotype.Repository;
@Repository
public interface SurveyMarketProfitLogMapper extends BaseMapper<SurveyMarketProfitLog> {
}
package com.zfxftech.telmarket.service.business.high;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zfxftech.telmarket.common.pojo.dao.high.HighMarketProfitLog;
import java.util.List;
/**
* @Description TODO
* @Author Dell
* @Date 2021/11/19 9:44
*/
public interface HighMarketProfitLogService extends IService<HighMarketProfitLog> {
}
......@@ -8,4 +8,5 @@ import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyAccountProductRelatio
public interface SurveyAccountProductRelationService extends IService<SurveyAccountProductRelation> {
SurveyAccountProductRelation queryAccountProductRelationByMarketInfo(Long maketId, String code);
}
package com.zfxftech.telmarket.service.business.survey;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyMarketProfitLog;
import java.util.List;
/**
* @Description TODO
* @Author Dell
* @Date 2021/11/19 9:44
*/
public interface SurveyMarketProfitLogService extends IService<SurveyMarketProfitLog> {
}
package com.zfxftech.telmarket.service.impl.business.high;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zfxftech.telmarket.common.pojo.dao.high.HighMarketProfitLog;
import com.zfxftech.telmarket.mapper.business.high.HighMarketProfitLogMapper;
import com.zfxftech.telmarket.service.business.high.HighMarketProfitLogService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
/**
* @Description TODO
* @Author Dell
* @Date 2021/11/19 9:47
*/
@Service
@Log4j2
public class HighMarketProfitLogServiceImpl extends ServiceImpl<HighMarketProfitLogMapper, HighMarketProfitLog> implements HighMarketProfitLogService {
}
package com.zfxftech.telmarket.service.impl.business.survey;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyAccountProductRelation;
import com.zfxftech.telmarket.mapper.business.survey.SurveyAccountProductRelationMapper;
import com.zfxftech.telmarket.service.business.survey.SurveyAccountProductRelationService;
import org.springframework.stereotype.Service;
import static com.zfxftech.telmarket.common.constant.AdminConstant.MarketTypeEnum.REAL;
import static com.zfxftech.telmarket.common.constant.AdminConstant.MarketTypeEnum.SIMULATED;
@Service
public class SurveyAccountProductRelationServiceImpl extends ServiceImpl<SurveyAccountProductRelationMapper, SurveyAccountProductRelation> implements SurveyAccountProductRelationService {
@Override
public SurveyAccountProductRelation queryAccountProductRelationByMarketInfo(Long marketId, String type) {
QueryWrapper<SurveyAccountProductRelation> queryWrapper = new QueryWrapper();
if (REAL.getCode().equals(type)) {
queryWrapper.eq("real_market_id", marketId);
}
if (SIMULATED.getCode().equals(type)) {
queryWrapper.eq("simulated_market_id", marketId);
}
return getOne(queryWrapper);
}
}
package com.zfxftech.telmarket.service.impl.business.survey;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyMarketProfitLog;
import com.zfxftech.telmarket.mapper.business.survey.SurveyMarketProfitLogMapper;
import com.zfxftech.telmarket.service.business.survey.SurveyMarketProfitLogService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
/**
* @Description TODO
* @Author Dell
* @Date 2021/11/19 9:47
*/
@Service
@Log4j2
public class SurveyMarketProfitLogServiceImpl extends ServiceImpl<SurveyMarketProfitLogMapper, SurveyMarketProfitLog> implements SurveyMarketProfitLogService {
}
package com.zfxftech.telmarket.task.writeOffChangeLog;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zfxftech.telmarket.common.constant.AdminConstant;
import com.zfxftech.telmarket.common.constant.RedisKeyMessageConstant;
import com.zfxftech.telmarket.common.pojo.dao.AccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.MarketProfitLog;
import com.zfxftech.telmarket.common.pojo.dao.StockPosition;
import com.zfxftech.telmarket.common.pojo.dao.UpdateWriteOffChangeLog;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetMarketProfitLog;
import com.zfxftech.telmarket.common.pojo.dao.asset.AssetStockPosition;
import com.zfxftech.telmarket.common.pojo.dao.high.HighAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.high.HighMarketProfitLog;
import com.zfxftech.telmarket.common.pojo.dao.high.HighStockPosition;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartMarketProfitLog;
import com.zfxftech.telmarket.common.pojo.dao.smart.SmartStockPosition;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyAccountProductRelation;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyMarketProfitLog;
import com.zfxftech.telmarket.common.pojo.dao.survey.SurveyStockPosition;
import com.zfxftech.telmarket.common.pojo.vo.MarketDetailsVO;
import com.zfxftech.telmarket.common.pojo.vo.asset.AssetMarketDetailsVO;
import com.zfxftech.telmarket.common.pojo.vo.high.HighMarketDetailsVO;
import com.zfxftech.telmarket.common.pojo.vo.smart.SmartMarketDetailsVO;
import com.zfxftech.telmarket.common.pojo.vo.survey.SurveyMarketDetailsVO;
import com.zfxftech.telmarket.common.util.BigDecimalUtil;
import com.zfxftech.telmarket.common.util.DateUtil;
import com.zfxftech.telmarket.common.util.ObjectUtil;
import com.zfxftech.telmarket.common.util.OptionalUtil;
import com.zfxftech.telmarket.service.business.AccountProductRelationService;
import com.zfxftech.telmarket.service.business.MarketProfitLogService;
import com.zfxftech.telmarket.service.business.StockPositionService;
import com.zfxftech.telmarket.service.business.asset.AssetAccountProductRelationService;
import com.zfxftech.telmarket.service.business.asset.AssetMarketProfitLogService;
import com.zfxftech.telmarket.service.business.asset.AssetStockPositionService;
import com.zfxftech.telmarket.service.business.high.HighAccountProductRelationService;
import com.zfxftech.telmarket.service.business.high.HighMarketProfitLogService;
import com.zfxftech.telmarket.service.business.high.HighStockPositionService;
import com.zfxftech.telmarket.service.business.smart.SmartAccountProductRelationService;
import com.zfxftech.telmarket.service.business.smart.SmartMarketProfitLogService;
import com.zfxftech.telmarket.service.business.smart.SmartStockPositionService;
import com.zfxftech.telmarket.service.business.survey.SurveyAccountProductRelationService;
import com.zfxftech.telmarket.service.business.survey.SurveyMarketProfitLogService;
import com.zfxftech.telmarket.service.business.survey.SurveyStockPositionService;
import com.zfxftech.telmarket.service.redis.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static com.zfxftech.telmarket.common.constant.AdminConstant.MarketTypeEnum.SIMULATED;
/**
* 私人订制核销变化记录 晚间核销资金
*/
@Slf4j
@Component
public class ProemiumWriteOffChangeLogTask {
@Autowired
@Qualifier("redisServiceNoWrapper")
private RedisService redisService;
@Autowired
private AssetAccountProductRelationService assetAccountProductRelationService;
@Autowired
private AssetStockPositionService assetStockPositionService;
@Autowired
private AssetMarketProfitLogService assetMarketProfitLogService;
@Autowired
private SmartAccountProductRelationService smartAccountProductRelationService;
@Autowired
private SmartStockPositionService smartStockPositionService;
@Autowired
private SmartMarketProfitLogService smartMarketProfitLogService;
@Autowired
private AccountProductRelationService accountProductRelationService;
@Autowired
private StockPositionService stockPositionService;
@Autowired
private MarketProfitLogService marketProfitLogService;
@Autowired
private SurveyAccountProductRelationService surveyAccountProductRelationService;
@Autowired
private SurveyStockPositionService surveyStockPositionService;
@Autowired
private SurveyMarketProfitLogService surveyMarketProfitLogService;
@Autowired
private HighAccountProductRelationService highAccountProductRelationService;
@Autowired
private HighStockPositionService highStockPositionService;
@Autowired
private HighMarketProfitLogService highMarketProfitLogService;
/**
* djx
* 回撤记录添加记录
*/
@Scheduled(initialDelay = 1000, fixedRate = 1000)
public void retryHandlerTempMsgInfo() {
int count = 1;
while (count <= 50) {
try {
Object voice = redisService.rightPopMessage(RedisKeyMessageConstant.RedisUpdateGraphKey);
if (voice != null) {
if (count == 1 || count % 10 == 0) {
log.info("重新生成折线图记录队列处理>>>");
}
UpdateWriteOffChangeLog robotTelephoneLog = JSONUtil.toBean(JSONUtil.toJsonStr(voice), UpdateWriteOffChangeLog.class);
//根据时间、marketid 、 类型 如果有重复数据则替换
if (robotTelephoneLog.getType().equals(AdminConstant.MemberProductTypeEnum.SMART_TYPE.getCode())) {
this.smartAccountProductRelationTask(Long.valueOf(robotTelephoneLog.getMarketId()));
}
if (robotTelephoneLog.getType().equals(AdminConstant.MemberProductTypeEnum.ASSET_TYPE.getCode())) {
this.assetAccountProductRelationTask(Long.valueOf(robotTelephoneLog.getMarketId()));
}
if (robotTelephoneLog.getType().equals(AdminConstant.MemberProductTypeEnum.PREMIUM.getCode())) {
this.accountProductRelationTask(Long.valueOf(robotTelephoneLog.getMarketId()));
}
if (robotTelephoneLog.getType().equals(AdminConstant.MemberProductTypeEnum.SURVEY_TYPE.getCode())) {
this.surveyAccountProductRelationTask(Long.valueOf(robotTelephoneLog.getMarketId()));
}
if (robotTelephoneLog.getType().equals(AdminConstant.MemberProductTypeEnum.HIGH_TYPE.getCode())) {
this.highAccountProductRelationTask(Long.valueOf(robotTelephoneLog.getMarketId()));
}
} else {
break;
}
} catch (Exception e) {
log.error("重新生成折线图日志出错:{}", e);
} finally {
count++;
}
}
}
public void assetAccountProductRelationTask(Long maketId) {
AssetAccountProductRelation accountProductRelation = assetAccountProductRelationService.queryAccountProductRelationByMarketInfo(maketId, SIMULATED.getCode());
AssetAccountProductRelation productRelation = new AssetAccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询持仓信息
BigDecimal funding = accountProductRelation.getSimulatedFunding();
//获取所有买入过的股票
List<AssetStockPosition> stockPositions = assetStockPositionService.queryStockPositions(maketId);
//汇总数据
AssetMarketDetailsVO marketDetailsVO = assetStockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
productRelation.setId(accountProductRelation.getId());
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalProfitRate())) {
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
}
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalPrice())) {
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
}
assetAccountProductRelationService.updateById(productRelation);
QueryWrapper<AssetMarketProfitLog> queryWrapper = new QueryWrapper();
queryWrapper.le("date", new Date());
queryWrapper.ge("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd 00:00:00"));
queryWrapper.eq("market_id", maketId);
List<AssetMarketProfitLog> list = assetMarketProfitLogService.list(queryWrapper);
if (ObjectUtils.isEmpty(list)) {
return;
}
AssetMarketProfitLog assetmarketProfitLog = new AssetMarketProfitLog();
assetmarketProfitLog.setId(list.get(0).getId());
assetmarketProfitLog.setMarketId(accountProductRelation.getSimulatedMarketId());
assetmarketProfitLog.setPrincipal(accountProductRelation.getInitialFunding());
if (BigDecimalUtil.le(accountProductRelation.getSimulatedTotalProfit(), new BigDecimal("0"))) {
assetmarketProfitLog.setProfit(new BigDecimal("0"));
} else {
assetmarketProfitLog.setProfit(BigDecimalUtil.mul(accountProductRelation.getSimulatedTotalProfit(), accountProductRelation.getSimulatedTotalPrice()));
}
assetmarketProfitLog.setProfitRate(ObjectUtils.isEmpty(accountProductRelation.getSimulatedTotalProfit()) ? new BigDecimal("0") : accountProductRelation.getSimulatedTotalProfit());
assetMarketProfitLogService.updateById(assetmarketProfitLog);
} catch (Exception e) {
log.error("资管更新数据错误:{}", e);
}
}
public void smartAccountProductRelationTask(Long maketId) {
SmartAccountProductRelation accountProductRelation = smartAccountProductRelationService.queryAccountProductRelationByMarketInfo(maketId, SIMULATED.getCode());
SmartAccountProductRelation productRelation = new SmartAccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询持仓信息
BigDecimal funding = accountProductRelation.getSimulatedFunding();
//获取所有买入过的股票
List<SmartStockPosition> stockPositions = smartStockPositionService.queryStockPositions(maketId);
//汇总数据
SmartMarketDetailsVO marketDetailsVO = smartStockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
productRelation.setId(accountProductRelation.getId());
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalProfitRate())) {
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
}
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalPrice())) {
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
}
smartAccountProductRelationService.updateById(productRelation);
QueryWrapper<SmartMarketProfitLog> queryWrapper = new QueryWrapper();
queryWrapper.le("date", new Date());
queryWrapper.ge("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd 00:00:00"));
queryWrapper.eq("market_id", maketId);
List<SmartMarketProfitLog> list = smartMarketProfitLogService.list(queryWrapper);
if (ObjectUtils.isEmpty(list)) {
return;
}
SmartMarketProfitLog smartmarketProfitLog = new SmartMarketProfitLog();
smartmarketProfitLog.setId(list.get(0).getId());
smartmarketProfitLog.setMarketId(accountProductRelation.getSimulatedMarketId());
smartmarketProfitLog.setPrincipal(accountProductRelation.getInitialFunding());
if (BigDecimalUtil.le(accountProductRelation.getSimulatedTotalProfit(), new BigDecimal("0"))) {
smartmarketProfitLog.setProfit(new BigDecimal("0"));
} else {
smartmarketProfitLog.setProfit(BigDecimalUtil.mul(accountProductRelation.getSimulatedTotalProfit(), accountProductRelation.getSimulatedTotalPrice()));
}
smartmarketProfitLog.setProfitRate(ObjectUtils.isEmpty(accountProductRelation.getSimulatedTotalProfit()) ? new BigDecimal("0") : accountProductRelation.getSimulatedTotalProfit());
smartMarketProfitLogService.updateById(smartmarketProfitLog);
} catch (Exception e) {
log.error("智能跟投更新数据错误:{}", e);
}
}
public void accountProductRelationTask(Long maketId) {
AccountProductRelation accountProductRelation = accountProductRelationService.queryAccountProductRelationByMarketInfo(maketId, SIMULATED.getCode());
AccountProductRelation productRelation = new AccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询持仓信息
BigDecimal funding = accountProductRelation.getSimulatedFunding();
//获取所有买入过的股票
List<StockPosition> stockPositions = stockPositionService.queryStockPositions(maketId);
//汇总数据
MarketDetailsVO marketDetailsVO = stockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
productRelation.setId(accountProductRelation.getId());
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalProfitRate())) {
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
}
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalPrice())) {
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
}
accountProductRelationService.updateById(productRelation);
QueryWrapper<MarketProfitLog> queryWrapper = new QueryWrapper();
queryWrapper.le("date", new Date());
queryWrapper.ge("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd 00:00:00"));
queryWrapper.eq("market_id", maketId);
List<MarketProfitLog> list = marketProfitLogService.list(queryWrapper);
if (ObjectUtils.isEmpty(list)) {
return;
}
MarketProfitLog smartmarketProfitLog = new MarketProfitLog();
smartmarketProfitLog.setId(list.get(0).getId());
smartmarketProfitLog.setMarketId(accountProductRelation.getSimulatedMarketId());
smartmarketProfitLog.setPrincipal(accountProductRelation.getInitialFunding());
if (BigDecimalUtil.le(accountProductRelation.getSimulatedTotalProfit(), new BigDecimal("0"))) {
smartmarketProfitLog.setProfit(new BigDecimal("0"));
} else {
smartmarketProfitLog.setProfit(BigDecimalUtil.mul(accountProductRelation.getSimulatedTotalProfit(), accountProductRelation.getSimulatedTotalPrice()));
}
smartmarketProfitLog.setProfitRate(ObjectUtils.isEmpty(accountProductRelation.getSimulatedTotalProfit()) ? new BigDecimal("0") : accountProductRelation.getSimulatedTotalProfit());
marketProfitLogService.updateById(smartmarketProfitLog);
} catch (Exception e) {
log.error("私人订制更新数据错误:{}", e);
}
}
public void surveyAccountProductRelationTask(Long maketId) {
SurveyAccountProductRelation accountProductRelation = surveyAccountProductRelationService.queryAccountProductRelationByMarketInfo(maketId, SIMULATED.getCode());
SurveyAccountProductRelation productRelation = new SurveyAccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询持仓信息
BigDecimal funding = accountProductRelation.getSimulatedFunding();
//获取所有买入过的股票
List<SurveyStockPosition> stockPositions = surveyStockPositionService.queryStockPositions(maketId);
//汇总数据
SurveyMarketDetailsVO marketDetailsVO = surveyStockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
productRelation.setId(accountProductRelation.getId());
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalProfitRate())) {
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
}
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalPrice())) {
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
}
surveyAccountProductRelationService.updateById(productRelation);
QueryWrapper<SurveyMarketProfitLog> queryWrapper = new QueryWrapper();
queryWrapper.le("date", new Date());
queryWrapper.ge("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd 00:00:00"));
queryWrapper.eq("market_id", maketId);
List<SurveyMarketProfitLog> list = surveyMarketProfitLogService.list(queryWrapper);
if (ObjectUtils.isEmpty(list)) {
return;
}
SurveyMarketProfitLog surveymarketProfitLog = new SurveyMarketProfitLog();
surveymarketProfitLog.setId(list.get(0).getId());
surveymarketProfitLog.setMarketId(accountProductRelation.getSimulatedMarketId());
surveymarketProfitLog.setPrincipal(accountProductRelation.getInitialFunding());
if (BigDecimalUtil.le(accountProductRelation.getSimulatedTotalProfit(), new BigDecimal("0"))) {
surveymarketProfitLog.setProfit(new BigDecimal("0"));
} else {
surveymarketProfitLog.setProfit(BigDecimalUtil.mul(accountProductRelation.getSimulatedTotalProfit(), accountProductRelation.getSimulatedTotalPrice()));
}
surveymarketProfitLog.setProfitRate(ObjectUtils.isEmpty(accountProductRelation.getSimulatedTotalProfit()) ? new BigDecimal("0") : accountProductRelation.getSimulatedTotalProfit());
surveyMarketProfitLogService.updateById(surveymarketProfitLog);
} catch (Exception e) {
log.error("项目调研更新数据错误:{}", e);
}
}
public void highAccountProductRelationTask(Long maketId) {
HighAccountProductRelation accountProductRelation = highAccountProductRelationService.queryAccountProductRelationByMarketInfo(maketId, SIMULATED.getCode());
HighAccountProductRelation productRelation = new HighAccountProductRelation();
try {
OptionalUtil.checkNull(accountProductRelation, "当前用户产品关系不存在");
//查询持仓信息
BigDecimal funding = accountProductRelation.getSimulatedFunding();
//获取所有买入过的股票
List<HighStockPosition> stockPositions = highStockPositionService.queryStockPositions(maketId);
//汇总数据
HighMarketDetailsVO marketDetailsVO = highStockPositionService.createMarketDetailsVOTask(stockPositions, funding, accountProductRelation);
productRelation.setId(accountProductRelation.getId());
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalProfitRate())) {
productRelation.setSimulatedTotalProfit(new BigDecimal(marketDetailsVO.getTotalProfitRate()));
}
if (!ObjectUtils.isEmpty(marketDetailsVO.getTotalPrice())) {
//示范盘总资产
productRelation.setSimulatedTotalPrice(new BigDecimal(marketDetailsVO.getTotalPrice()));
}
highAccountProductRelationService.updateById(productRelation);
QueryWrapper<HighMarketProfitLog> queryWrapper = new QueryWrapper();
queryWrapper.le("date", new Date());
queryWrapper.ge("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd 00:00:00"));
queryWrapper.eq("market_id", maketId);
List<HighMarketProfitLog> list = highMarketProfitLogService.list(queryWrapper);
if (ObjectUtils.isEmpty(list)) {
return;
}
HighMarketProfitLog smartmarketProfitLog = new HighMarketProfitLog();
smartmarketProfitLog.setId(list.get(0).getId());
smartmarketProfitLog.setMarketId(accountProductRelation.getSimulatedMarketId());
smartmarketProfitLog.setPrincipal(accountProductRelation.getInitialFunding());
if (BigDecimalUtil.le(accountProductRelation.getSimulatedTotalProfit(), new BigDecimal("0"))) {
smartmarketProfitLog.setProfit(new BigDecimal("0"));
} else {
smartmarketProfitLog.setProfit(BigDecimalUtil.mul(accountProductRelation.getSimulatedTotalProfit(), accountProductRelation.getSimulatedTotalPrice()));
}
smartmarketProfitLog.setProfitRate(ObjectUtils.isEmpty(accountProductRelation.getSimulatedTotalProfit()) ? new BigDecimal("0") : accountProductRelation.getSimulatedTotalProfit());
highMarketProfitLogService.updateById(smartmarketProfitLog);
} catch (Exception e) {
log.error("高端订制更新数据错误:{}", e);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment