Search in sources :

Example 1 with FundExistenceCheck

use of com.tony.billing.model.FundExistenceCheck in project BillingDubbo by TonyJiangWJ.

the class FundInfoController method checkAllFundsStatus.

@RequestMapping(value = "/fund/check/all/status", method = RequestMethod.POST)
public FundsExistenceCheckResponse checkAllFundsStatus(@ModelAttribute("request") @Validated FundsExistenceCheckRequest request) {
    List<FundExistenceCheck> existsList = fundInfoService.checkFundsExistence(request.getFundCheckList());
    FundsExistenceCheckResponse response = ResponseUtil.success(new FundsExistenceCheckResponse());
    response.setExistsList(existsList);
    return response;
}
Also used : FundsExistenceCheckResponse(com.tony.billing.response.fund.FundsExistenceCheckResponse) FundExistenceCheck(com.tony.billing.model.FundExistenceCheck) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with FundExistenceCheck

use of com.tony.billing.model.FundExistenceCheck in project BillingDubbo by TonyJiangWJ.

the class FundInfoServiceImpl method checkFundsExistence.

@Override
public List<FundExistenceCheck> checkFundsExistence(List<FundExistenceCheck> fundCheckList) {
    Preconditions.checkState(CollectionUtils.isNotEmpty(fundCheckList), "待检测列表不能为空");
    List<FundInfo> userFundsList = mapper.listUserExistsFunds(UserIdContainer.getUserId(), fundCheckList.stream().map(FundExistenceCheck::getFundCode).distinct().collect(Collectors.toList()));
    if (CollectionUtils.isEmpty(userFundsList)) {
        return Collections.emptyList();
    }
    Map<String, List<FundInfo>> resultMap = userFundsList.stream().collect(Collectors.groupingBy(FundInfo::getFundCode));
    List<FundExistenceCheck> resultList = new CopyOnWriteArrayList<>();
    fundCheckList.parallelStream().forEach(fundCheck -> {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        List<FundInfo> fundInfos = resultMap.get(fundCheck.getFundCode());
        if (CollectionUtils.isNotEmpty(fundInfos)) {
            for (FundInfo fundInfo : fundInfos) {
                String confirmDate = fundInfo.getConfirmDate().toInstant().atZone(TimeConstants.CHINA_ZONE).format(formatter);
                if (confirmDate.equals(fundCheck.getConfirmDate()) && fundInfo.getPurchaseAmount().compareTo(fundCheck.getPurchaseAmount()) == 0) {
                    resultList.add(fundCheck);
                }
            }
        }
    });
    return resultList;
}
Also used : FundInfo(com.tony.billing.entity.FundInfo) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) FundExistenceCheck(com.tony.billing.model.FundExistenceCheck) DateTimeFormatter(java.time.format.DateTimeFormatter) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

FundExistenceCheck (com.tony.billing.model.FundExistenceCheck)2 FundInfo (com.tony.billing.entity.FundInfo)1 FundsExistenceCheckResponse (com.tony.billing.response.fund.FundsExistenceCheckResponse)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1