diff --git a/fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/angel/InsurerRpcService.java b/fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/angel/InsurerRpcService.java index c94452d..18e2208 100644 --- a/fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/angel/InsurerRpcService.java +++ b/fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/angel/InsurerRpcService.java @@ -17,8 +17,10 @@ import org.springframework.data.redis.core.BoundValueOperations; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import java.util.Date; +import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -84,25 +86,37 @@ public class InsurerRpcService { if (StringUtils.isValid(cache)) { return JSONObject.parseObject(cache, InsuranceDTO.class); } - Message msg = insuranceEstimateApiService.getCusLatest(customerId); + Message> msg = insuranceEstimateApiService.getCusLatest(customerId); + log.info("查询正在生效的保险信息:{}", msg.getResult()); - InsuranceOrderDTO data = msg.getData(); - if (!msg.isSuccess() || Objects.isNull(data) || Objects.isNull(data.getInsuranceInfo())) { + List data = msg.getData(); + if (!msg.isSuccess() || CollectionUtils.isEmpty(data)) { return null; } - Date tciEndTime = data.getInsuranceInfo().getTciEndTime(); - Date vciEndTime = data.getInsuranceInfo().getVciEndTime(); + Date tciEndTime = null; + Date vciEndTime = null; + Date tciStartTime = null; + Date vciStartTime = null; + for (InsuranceOrderDTO insuranceOrderDTO : data) { + if (1 == insuranceOrderDTO.getInsuranceInfo().getInsuranceType()) { + tciEndTime = insuranceOrderDTO.getInsuranceInfo().getEndTime(); + tciStartTime = insuranceOrderDTO.getInsuranceInfo().getStartTime(); + } else if (2 == insuranceOrderDTO.getInsuranceInfo().getInsuranceType()) { + vciEndTime = insuranceOrderDTO.getInsuranceInfo().getEndTime(); + vciStartTime = insuranceOrderDTO.getInsuranceInfo().getStartTime(); + } + } final Date now = new Date(); boolean before1 = !Objects.isNull(tciEndTime) && now.before(tciEndTime); - boolean before2 = !Objects.isNull(tciEndTime) && now.before(vciEndTime); + boolean before2 = !Objects.isNull(vciEndTime) && now.before(vciEndTime); if (before1 || before2) { InsuranceDTO dto = new InsuranceDTO(); BeanUtils.copyProperties(data, dto); - dto.setEffectDate(data.getInsuranceInfo().getVciStartTime()); - dto.setExpiryDate(data.getInsuranceInfo().getVciEndTime()); - dto.setTciEffectDate(data.getInsuranceInfo().getTciStartTime()); - dto.setTciExpiryDate(data.getInsuranceInfo().getTciEndTime()); + dto.setEffectDate(vciStartTime); + dto.setExpiryDate(vciEndTime); + dto.setTciEffectDate(tciStartTime); + dto.setTciExpiryDate(tciEndTime); setToCache(key, JSONObject.toJSONString(dto), 30); return dto; }