Commit 1245c464ed738773d898614389bd462c3cd67ecd
1 parent
30f8f45d
对接保险新的sdk
Showing
1 changed file
with
24 additions
and
10 deletions
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/angel/InsurerRpcService.java
@@ -17,8 +17,10 @@ import org.springframework.data.redis.core.BoundValueOperations; | @@ -17,8 +17,10 @@ import org.springframework.data.redis.core.BoundValueOperations; | ||
17 | import org.springframework.data.redis.core.StringRedisTemplate; | 17 | import org.springframework.data.redis.core.StringRedisTemplate; |
18 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
19 | import org.springframework.util.Assert; | 19 | import org.springframework.util.Assert; |
20 | +import org.springframework.util.CollectionUtils; | ||
20 | 21 | ||
21 | import java.util.Date; | 22 | import java.util.Date; |
23 | +import java.util.List; | ||
22 | import java.util.Objects; | 24 | import java.util.Objects; |
23 | import java.util.concurrent.TimeUnit; | 25 | import java.util.concurrent.TimeUnit; |
24 | 26 | ||
@@ -84,25 +86,37 @@ public class InsurerRpcService { | @@ -84,25 +86,37 @@ public class InsurerRpcService { | ||
84 | if (StringUtils.isValid(cache)) { | 86 | if (StringUtils.isValid(cache)) { |
85 | return JSONObject.parseObject(cache, InsuranceDTO.class); | 87 | return JSONObject.parseObject(cache, InsuranceDTO.class); |
86 | } | 88 | } |
87 | - Message<InsuranceOrderDTO> msg = insuranceEstimateApiService.getCusLatest(customerId); | 89 | + Message<List<InsuranceOrderDTO>> msg = insuranceEstimateApiService.getCusLatest(customerId); |
90 | + | ||
88 | log.info("查询正在生效的保险信息:{}", msg.getResult()); | 91 | log.info("查询正在生效的保险信息:{}", msg.getResult()); |
89 | - InsuranceOrderDTO data = msg.getData(); | ||
90 | - if (!msg.isSuccess() || Objects.isNull(data) || Objects.isNull(data.getInsuranceInfo())) { | 92 | + List<InsuranceOrderDTO> data = msg.getData(); |
93 | + if (!msg.isSuccess() || CollectionUtils.isEmpty(data)) { | ||
91 | return null; | 94 | return null; |
92 | } | 95 | } |
93 | - Date tciEndTime = data.getInsuranceInfo().getTciEndTime(); | ||
94 | - Date vciEndTime = data.getInsuranceInfo().getVciEndTime(); | 96 | + Date tciEndTime = null; |
97 | + Date vciEndTime = null; | ||
98 | + Date tciStartTime = null; | ||
99 | + Date vciStartTime = null; | ||
100 | + for (InsuranceOrderDTO insuranceOrderDTO : data) { | ||
101 | + if (1 == insuranceOrderDTO.getInsuranceInfo().getInsuranceType()) { | ||
102 | + tciEndTime = insuranceOrderDTO.getInsuranceInfo().getEndTime(); | ||
103 | + tciStartTime = insuranceOrderDTO.getInsuranceInfo().getStartTime(); | ||
104 | + } else if (2 == insuranceOrderDTO.getInsuranceInfo().getInsuranceType()) { | ||
105 | + vciEndTime = insuranceOrderDTO.getInsuranceInfo().getEndTime(); | ||
106 | + vciStartTime = insuranceOrderDTO.getInsuranceInfo().getStartTime(); | ||
107 | + } | ||
108 | + } | ||
95 | final Date now = new Date(); | 109 | final Date now = new Date(); |
96 | boolean before1 = !Objects.isNull(tciEndTime) && now.before(tciEndTime); | 110 | boolean before1 = !Objects.isNull(tciEndTime) && now.before(tciEndTime); |
97 | - boolean before2 = !Objects.isNull(tciEndTime) && now.before(vciEndTime); | 111 | + boolean before2 = !Objects.isNull(vciEndTime) && now.before(vciEndTime); |
98 | 112 | ||
99 | if (before1 || before2) { | 113 | if (before1 || before2) { |
100 | InsuranceDTO dto = new InsuranceDTO(); | 114 | InsuranceDTO dto = new InsuranceDTO(); |
101 | BeanUtils.copyProperties(data, dto); | 115 | BeanUtils.copyProperties(data, dto); |
102 | - dto.setEffectDate(data.getInsuranceInfo().getVciStartTime()); | ||
103 | - dto.setExpiryDate(data.getInsuranceInfo().getVciEndTime()); | ||
104 | - dto.setTciEffectDate(data.getInsuranceInfo().getTciStartTime()); | ||
105 | - dto.setTciExpiryDate(data.getInsuranceInfo().getTciEndTime()); | 116 | + dto.setEffectDate(vciStartTime); |
117 | + dto.setExpiryDate(vciEndTime); | ||
118 | + dto.setTciEffectDate(tciStartTime); | ||
119 | + dto.setTciExpiryDate(tciEndTime); | ||
106 | setToCache(key, JSONObject.toJSONString(dto), 30); | 120 | setToCache(key, JSONObject.toJSONString(dto), 30); |
107 | return dto; | 121 | return dto; |
108 | } | 122 | } |