Search in sources :

Example 1 with DailyFundChangedResponse

use of com.tony.billing.response.fund.DailyFundChangedResponse in project BillingDubbo by TonyJiangWJ.

the class FundHistoryValueServiceImpl method getFundChangedInfosByAssessmentDate.

@Override
public DailyFundChangedResponse getFundChangedInfosByAssessmentDate(String assessmentDate) {
    DailyFundChangedResponse response = ResponseUtil.success(new DailyFundChangedResponse());
    Long userId = UserIdContainer.getUserId();
    List<FundInfo> userFunds = fundInfoService.listGroupedFundsByUserId(userId);
    FundInfo fundInfo = new FundInfo();
    fundInfo.setUserId(userId);
    fundInfo.setInStore(EnumYesOrNo.YES.val());
    List<FundInfo> userFundDetailList = fundInfoService.list(fundInfo);
    if (CollectionUtils.isNotEmpty(userFunds)) {
        List<FundHistoryValue> latestHistoryValues = mapper.getLatestFundHistoryValueByFundCodes(userFunds.stream().map(FundInfo::getFundCode).collect(Collectors.toList()), assessmentDate);
        Map<String, FundHistoryValue> latestHistoryValueMap = new HashMap<>(latestHistoryValues.size());
        if (CollectionUtils.isNotEmpty(latestHistoryValues)) {
            latestHistoryValues.forEach(fundHistoryValue -> latestHistoryValueMap.put(fundHistoryValue.getFundCode(), fundHistoryValue));
        }
        response.setSummaryFundInfos(getFundChangedInfos(userFunds, latestHistoryValueMap, assessmentDate));
        response.setFundDetailInfos(getFundChangedInfos(userFundDetailList, latestHistoryValueMap, assessmentDate));
        response.setAssessmentDate(assessmentDate);
        response.calculateIncreaseInfo();
    }
    return response;
}
Also used : FundHistoryValue(com.tony.billing.entity.FundHistoryValue) HashMap(java.util.HashMap) FundInfo(com.tony.billing.entity.FundInfo) DailyFundChangedResponse(com.tony.billing.response.fund.DailyFundChangedResponse)

Aggregations

FundHistoryValue (com.tony.billing.entity.FundHistoryValue)1 FundInfo (com.tony.billing.entity.FundInfo)1 DailyFundChangedResponse (com.tony.billing.response.fund.DailyFundChangedResponse)1 HashMap (java.util.HashMap)1