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