Commit d8d786514d88304fd46292cf650445e05f43cdd3
Merge remote-tracking branch 'origin/master' into 2.0
# Conflicts: # fw-valhalla-server/src/main/resources/application.yml
Showing
7 changed files
with
51 additions
and
499 deletions
fw-valhalla-common/src/main/java/cn/fw/valhalla/common/utils/HttpClientUtil.java deleted
1 | -package cn.fw.valhalla.common.utils; | |
2 | - | |
3 | -import cn.fw.common.exception.BusinessException; | |
4 | -import org.apache.http.*; | |
5 | -import org.apache.http.client.ClientProtocolException; | |
6 | -import org.apache.http.client.entity.UrlEncodedFormEntity; | |
7 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
8 | -import org.apache.http.client.methods.HttpGet; | |
9 | -import org.apache.http.client.methods.HttpPost; | |
10 | -import org.apache.http.client.methods.HttpPut; | |
11 | -import org.apache.http.client.utils.URIBuilder; | |
12 | -import org.apache.http.entity.ByteArrayEntity; | |
13 | -import org.apache.http.entity.ContentType; | |
14 | -import org.apache.http.entity.StringEntity; | |
15 | -import org.apache.http.impl.client.CloseableHttpClient; | |
16 | -import org.apache.http.impl.client.HttpClients; | |
17 | -import org.apache.http.message.BasicNameValuePair; | |
18 | -import org.apache.http.util.CharArrayBuffer; | |
19 | -import org.apache.http.util.EntityUtils; | |
20 | - | |
21 | -import java.io.IOException; | |
22 | -import java.io.InputStreamReader; | |
23 | -import java.io.UnsupportedEncodingException; | |
24 | -import java.net.URI; | |
25 | -import java.util.ArrayList; | |
26 | -import java.util.List; | |
27 | -import java.util.Map; | |
28 | - | |
29 | -/** | |
30 | - * @author kurisu | |
31 | - */ | |
32 | -public class HttpClientUtil { | |
33 | - | |
34 | - public static String doGet(String url, Map<String, String> param) { | |
35 | - | |
36 | - // 创建Httpclient对象 | |
37 | - CloseableHttpClient httpclient = HttpClients.createDefault(); | |
38 | - | |
39 | - String resultString = ""; | |
40 | - CloseableHttpResponse response = null; | |
41 | - try { | |
42 | - // 创建uri | |
43 | - URIBuilder builder = new URIBuilder(url); | |
44 | - if (param != null) { | |
45 | - for (String key : param.keySet()) { | |
46 | - builder.addParameter(key, param.get(key)); | |
47 | - } | |
48 | - } | |
49 | - URI uri = builder.build(); | |
50 | - | |
51 | - // 创建http GET请求 | |
52 | - HttpGet httpGet = new HttpGet(uri); | |
53 | - | |
54 | - // 执行请求 | |
55 | - response = httpclient.execute(httpGet); | |
56 | - // 判断返回状态是否为200 | |
57 | - if (response.getStatusLine().getStatusCode() == 200) { | |
58 | - resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); | |
59 | - } | |
60 | - } catch (Exception e) { | |
61 | - e.printStackTrace(); | |
62 | - } finally { | |
63 | - closeResource(httpclient, response); | |
64 | - } | |
65 | - return resultString; | |
66 | - } | |
67 | - | |
68 | - public static String doGet(String url) { | |
69 | - return doGet(url, null); | |
70 | - } | |
71 | - | |
72 | - public static String doGet(String url, Map<String, String> param, Map<String, String> headerParam) { | |
73 | - | |
74 | - // 创建Httpclient对象 | |
75 | - CloseableHttpClient httpclient = HttpClients.createDefault(); | |
76 | - | |
77 | - String resultString = ""; | |
78 | - CloseableHttpResponse response = null; | |
79 | - try { | |
80 | - // 创建uri | |
81 | - URIBuilder builder = new URIBuilder(url); | |
82 | - if (param != null) { | |
83 | - for (String key : param.keySet()) { | |
84 | - builder.addParameter(key, param.get(key)); | |
85 | - } | |
86 | - } | |
87 | - URI uri = builder.build(); | |
88 | - | |
89 | - // 创建http GET请求 | |
90 | - HttpGet httpGet = new HttpGet(uri); | |
91 | - if (headerParam != null) { | |
92 | - Header[] headers = getHeaders(headerParam); | |
93 | - httpGet.setHeaders(headers); | |
94 | - } | |
95 | - // 执行请求 | |
96 | - response = httpclient.execute(httpGet); | |
97 | - // 判断返回状态是否为200 | |
98 | - if (response.getStatusLine().getStatusCode() == 200) { | |
99 | - resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); | |
100 | - } | |
101 | - } catch (Exception e) { | |
102 | - e.printStackTrace(); | |
103 | - } finally { | |
104 | - closeResource(httpclient, response); | |
105 | - } | |
106 | - return resultString; | |
107 | - } | |
108 | - | |
109 | - public static String doPost(String url, Map<String, Object> param) { | |
110 | - // 创建Httpclient对象 | |
111 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
112 | - CloseableHttpResponse response = null; | |
113 | - String resultString = ""; | |
114 | - try { | |
115 | - // 创建Http Post请求 | |
116 | - HttpPost httpPost = new HttpPost(url); | |
117 | - // 创建参数列表 | |
118 | - createParam(param, httpPost); | |
119 | - // 执行http请求 | |
120 | - response = httpClient.execute(httpPost); | |
121 | - resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); | |
122 | - } catch (Exception e) { | |
123 | - e.printStackTrace(); | |
124 | - } finally { | |
125 | - try { | |
126 | - if (response != null) { | |
127 | - response.close(); | |
128 | - } | |
129 | - } catch (IOException e) { | |
130 | - e.printStackTrace(); | |
131 | - } | |
132 | - } | |
133 | - | |
134 | - return resultString; | |
135 | - } | |
136 | - | |
137 | - public static String doPost(String url, Map<String, Object> param, Map<String, String> headerParam) { | |
138 | - // 创建Httpclient对象 | |
139 | - CloseableHttpResponse response = null; | |
140 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
141 | - String resultString = ""; | |
142 | - try { | |
143 | - // 创建Http Post请求 | |
144 | - HttpPost httpPost = new HttpPost(url); | |
145 | - // 创建参数列表 | |
146 | - createParam(param, httpPost); | |
147 | - if (headerParam != null) { | |
148 | - Header[] headers = getHeaders(headerParam); | |
149 | - httpPost.setHeaders(headers); | |
150 | - } | |
151 | - // 执行http请求 | |
152 | - response = httpClient.execute(httpPost); | |
153 | - resultString = EntityUtils.toString(response.getEntity(), "utf-8"); | |
154 | - } catch (Exception e) { | |
155 | - e.printStackTrace(); | |
156 | - } finally { | |
157 | - try { | |
158 | - if (response != null) { | |
159 | - response.close(); | |
160 | - } | |
161 | - } catch (IOException e) { | |
162 | - e.printStackTrace(); | |
163 | - } | |
164 | - } | |
165 | - | |
166 | - return resultString; | |
167 | - } | |
168 | - | |
169 | - public static String doPost(String url) { | |
170 | - return doPost(url, null); | |
171 | - } | |
172 | - | |
173 | - public static String doPostJson(String url, String json) { | |
174 | - // 创建Httpclient对象 | |
175 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
176 | - CloseableHttpResponse response = null; | |
177 | - String resultString = ""; | |
178 | - try { | |
179 | - // 创建Http Post请求 | |
180 | - HttpPost httpPost = new HttpPost(url); | |
181 | - // 创建请求内容 | |
182 | - StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); | |
183 | - httpPost.setEntity(entity); | |
184 | - // 执行http请求 | |
185 | - response = httpClient.execute(httpPost); | |
186 | - resultString = EntityUtils.toString(response.getEntity(), "utf-8"); | |
187 | - } catch (Exception e) { | |
188 | - throw new BusinessException("接口异常"); | |
189 | - } finally { | |
190 | - try { | |
191 | - if (response != null) { | |
192 | - response.close(); | |
193 | - } | |
194 | - } catch (IOException e) { | |
195 | - e.printStackTrace(); | |
196 | - } | |
197 | - } | |
198 | - | |
199 | - return resultString; | |
200 | - } | |
201 | - | |
202 | - public static String doPostJson(String url, String json, Map<String, String> headerParam) { | |
203 | - // 设置代理 用于抓包 | |
204 | - /*HttpHost proxy = new HttpHost("127.0.0.1", 8888, "http"); | |
205 | - RequestConfig defaultRequestConfig = RequestConfig.custom() | |
206 | - .setProxy(proxy) | |
207 | - .build(); | |
208 | - CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();*/ | |
209 | - // 创建Httpclient对象 | |
210 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
211 | - CloseableHttpResponse response = null; | |
212 | - String resultString = ""; | |
213 | - try { | |
214 | - // 创建Http Post请求 | |
215 | - HttpPost httpPost = new HttpPost(url); | |
216 | - // 创建请求内容 | |
217 | - StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); | |
218 | - httpPost.setEntity(entity); | |
219 | - if (headerParam != null) { | |
220 | - Header[] headers = getHeaders(headerParam); | |
221 | - httpPost.setHeaders(headers); | |
222 | - } | |
223 | - // 执行http请求 | |
224 | - response = httpClient.execute(httpPost); | |
225 | - resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); | |
226 | - } catch (Exception e) { | |
227 | - e.printStackTrace(); | |
228 | - } finally { | |
229 | - try { | |
230 | - if (response != null) { | |
231 | - response.close(); | |
232 | - } | |
233 | - } catch (IOException e) { | |
234 | - e.printStackTrace(); | |
235 | - } | |
236 | - } | |
237 | - | |
238 | - return resultString; | |
239 | - } | |
240 | - | |
241 | - public static String doPutJson(String url, String json, Map<String, String> headerParam) { | |
242 | - // 创建Httpclient对象 | |
243 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
244 | -// CookieStore cookieStore = new BasicCookieStore(); | |
245 | -// cookieStore.addCookie(new BasicClientCookie("", "")); | |
246 | -// CloseableHttpClient httpClient1 = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); | |
247 | - CloseableHttpResponse response = null; | |
248 | - String resultString = ""; | |
249 | - try { | |
250 | - // 创建Http Post请求 | |
251 | - HttpPut httpPut = new HttpPut(url); | |
252 | - // 创建请求内容 | |
253 | - StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); | |
254 | - httpPut.setEntity(entity); | |
255 | - if (headerParam != null) { | |
256 | - Header[] headers = getHeaders(headerParam); | |
257 | - httpPut.setHeaders(headers); | |
258 | - } | |
259 | - // 执行http请求 | |
260 | - response = httpClient.execute(httpPut); | |
261 | - resultString = EntityUtils.toString(response.getEntity(), "utf-8"); | |
262 | - } catch (Exception e) { | |
263 | - e.printStackTrace(); | |
264 | - } finally { | |
265 | - try { | |
266 | - if (response != null) { | |
267 | - response.close(); | |
268 | - } | |
269 | - } catch (IOException e) { | |
270 | - e.printStackTrace(); | |
271 | - } | |
272 | - } | |
273 | - | |
274 | - return resultString; | |
275 | - } | |
276 | - | |
277 | - | |
278 | -//============================================================================================================================ | |
279 | - | |
280 | - | |
281 | - private static Header[] getHeaders(Map<String, String> headerParam) { | |
282 | - Header[] headers = new Header[headerParam.size()]; | |
283 | - int i = 0; | |
284 | - for (String key : headerParam.keySet()) { | |
285 | - headers[i++] = new Header() { | |
286 | - @Override | |
287 | - public String getName() { | |
288 | - return key; | |
289 | - } | |
290 | - | |
291 | - @Override | |
292 | - public String getValue() { | |
293 | - return headerParam.get(key); | |
294 | - } | |
295 | - | |
296 | - @Override | |
297 | - public HeaderElement[] getElements() throws ParseException { | |
298 | - return new HeaderElement[0]; | |
299 | - } | |
300 | - }; | |
301 | - } | |
302 | - return headers; | |
303 | - } | |
304 | - | |
305 | - private static void closeResource(CloseableHttpClient httpclient, CloseableHttpResponse response) { | |
306 | - try { | |
307 | - if (response != null) { | |
308 | - response.close(); | |
309 | - } | |
310 | - httpclient.close(); | |
311 | - } catch (IOException e) { | |
312 | - e.printStackTrace(); | |
313 | - } | |
314 | - } | |
315 | - | |
316 | - private static void createParam(Map<String, Object> param, HttpPost httpPost) throws UnsupportedEncodingException { | |
317 | - if (param != null) { | |
318 | - List<NameValuePair> paramList = new ArrayList<>(); | |
319 | - for (String key : param.keySet()) { | |
320 | - paramList.add(new BasicNameValuePair(key, param.get(key).toString())); | |
321 | - } | |
322 | - // 模拟表单 | |
323 | - UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList, "UTF-8"); | |
324 | - httpPost.setEntity(entity); | |
325 | - } | |
326 | - } | |
327 | - | |
328 | - /** | |
329 | - * Post 请求 参数为 Json字符串 | |
330 | - * | |
331 | - * @param url | |
332 | - * @param jsonString | |
333 | - * @return | |
334 | - */ | |
335 | - public static String postJson(String url, String jsonString) { | |
336 | - String result = null; | |
337 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
338 | - HttpPost post = new HttpPost(url); | |
339 | - CloseableHttpResponse response = null; | |
340 | - try { | |
341 | - post.setEntity(new ByteArrayEntity(jsonString.getBytes("UTF-8"))); | |
342 | - response = httpClient.execute(post); | |
343 | - if (response != null && response.getStatusLine().getStatusCode() == 200) { | |
344 | - HttpEntity entity = response.getEntity(); | |
345 | - result = entityToString(entity); | |
346 | - } | |
347 | - return result; | |
348 | - } catch (UnsupportedEncodingException e) { | |
349 | - e.printStackTrace(); | |
350 | - } catch (ClientProtocolException e) { | |
351 | - e.printStackTrace(); | |
352 | - } catch (IOException e) { | |
353 | - e.printStackTrace(); | |
354 | - } finally { | |
355 | - try { | |
356 | - httpClient.close(); | |
357 | - if (response != null) { | |
358 | - response.close(); | |
359 | - } | |
360 | - } catch (IOException e) { | |
361 | - e.printStackTrace(); | |
362 | - } | |
363 | - } | |
364 | - return null; | |
365 | - } | |
366 | - | |
367 | - private static String entityToString(HttpEntity entity) throws IOException { | |
368 | - String result = null; | |
369 | - if (entity != null) { | |
370 | - long lenth = entity.getContentLength(); | |
371 | - if (lenth != -1 && lenth < 2048) { | |
372 | - result = EntityUtils.toString(entity, "UTF-8"); | |
373 | - } else { | |
374 | - InputStreamReader reader1 = new InputStreamReader(entity.getContent(), "UTF-8"); | |
375 | - CharArrayBuffer buffer = new CharArrayBuffer(2048); | |
376 | - char[] tmp = new char[1024]; | |
377 | - int l; | |
378 | - while ((l = reader1.read(tmp)) != -1) { | |
379 | - buffer.append(tmp, 0, l); | |
380 | - } | |
381 | - result = buffer.toString(); | |
382 | - } | |
383 | - } | |
384 | - return result; | |
385 | - } | |
386 | - | |
387 | -} | |
388 | 0 | \ No newline at end of file |
fw-valhalla-common/src/main/java/cn/fw/valhalla/common/utils/MobileUtil.java deleted
1 | -package cn.fw.valhalla.common.utils; | |
2 | - | |
3 | -import com.fasterxml.jackson.databind.ObjectMapper; | |
4 | -import lombok.Data; | |
5 | -import lombok.extern.slf4j.Slf4j; | |
6 | - | |
7 | -import java.io.IOException; | |
8 | -import java.util.HashMap; | |
9 | -import java.util.Map; | |
10 | - | |
11 | -/** | |
12 | - * 电话号码工具 | |
13 | - * <p> | |
14 | - * | |
15 | - * @author kurisu | |
16 | - */ | |
17 | -@Slf4j | |
18 | -public class MobileUtil { | |
19 | - private final static String JUHE_API = "http://apis.juhe.cn/mobile/get"; | |
20 | - private final static String APP_KEY = "3ae2492bf1b1a382943924e1a1a25e4d"; | |
21 | - private final static ObjectMapper objectMapper = new ObjectMapper(); | |
22 | - | |
23 | - public static String attribution(String mobile) { | |
24 | - if (StringUtils.isEmpty(mobile)) { | |
25 | - return ""; | |
26 | - } | |
27 | - final Map<String, String> param = new HashMap<>(); | |
28 | - param.put("phone", mobile); | |
29 | - param.put("key", APP_KEY); | |
30 | - final String resultString = HttpClientUtil.doGet(JUHE_API, param); | |
31 | - try { | |
32 | - final JuHeResult juHeResult = objectMapper.readValue(resultString, JuHeResult.class); | |
33 | - final int errorCode = Integer.valueOf(juHeResult.getError_code()); | |
34 | - final String reason = juHeResult.getReason(); | |
35 | - if (errorCode != 0) { | |
36 | - log.error("调用聚合API获取手机号码:{} 归属地异常:{}", mobile, errorCode + ":" + reason); | |
37 | - return ""; | |
38 | - } | |
39 | - final String province = juHeResult.getResult().getProvince(); | |
40 | - final String city = juHeResult.getResult().getCity(); | |
41 | - return province.concat(" ").concat(city); | |
42 | - } catch (IOException e) { | |
43 | - e.printStackTrace(); | |
44 | - } | |
45 | - return "未知"; | |
46 | - } | |
47 | - | |
48 | - @Data | |
49 | - public static class JuHeResult { | |
50 | - /** | |
51 | - * 错误码 | |
52 | - */ | |
53 | - private String error_code; | |
54 | - /** | |
55 | - * 结果 | |
56 | - */ | |
57 | - private String resultcode; | |
58 | - /** | |
59 | - * 错误原因 | |
60 | - */ | |
61 | - private String reason; | |
62 | - /** | |
63 | - * 结果 | |
64 | - */ | |
65 | - private Result result; | |
66 | - | |
67 | - | |
68 | - } | |
69 | - | |
70 | - @Data | |
71 | - public static class Result { | |
72 | - /** | |
73 | - * 省 | |
74 | - */ | |
75 | - private String province; | |
76 | - /** | |
77 | - * 市 | |
78 | - */ | |
79 | - private String city; | |
80 | - /** | |
81 | - * 区划编码 | |
82 | - */ | |
83 | - private String areacode; | |
84 | - /** | |
85 | - * 邮编 | |
86 | - */ | |
87 | - private String zip; | |
88 | - /** | |
89 | - * 公司 | |
90 | - */ | |
91 | - private String company; | |
92 | - /** | |
93 | - * | |
94 | - */ | |
95 | - private String card; | |
96 | - | |
97 | - } | |
98 | - | |
99 | -} | |
100 | 0 | \ No newline at end of file |
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/member/MemberRpcService.java
1 | 1 | package cn.fw.valhalla.rpc.member; |
2 | 2 | |
3 | +import cn.fw.common.util.MobileUtil; | |
3 | 4 | import cn.fw.data.base.domain.common.Message; |
5 | +import cn.fw.member.sdk.api.FunctionApi; | |
4 | 6 | import cn.fw.member.sdk.api.MemberApi; |
5 | 7 | import cn.fw.member.sdk.vo.BatchUserParam; |
8 | +import cn.fw.member.sdk.vo.MobileLocation; | |
6 | 9 | import cn.fw.member.sdk.vo.UserBaseInfoVO; |
7 | 10 | import cn.fw.member.sdk.vo.UserRegistryVO; |
8 | 11 | import cn.fw.valhalla.rpc.member.dto.MemberUserDTO; |
... | ... | @@ -10,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; |
10 | 13 | import org.apache.commons.lang3.StringUtils; |
11 | 14 | import org.springframework.beans.BeanUtils; |
12 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
16 | +import org.springframework.cache.annotation.Cacheable; | |
13 | 17 | import org.springframework.stereotype.Service; |
14 | 18 | import org.springframework.util.CollectionUtils; |
15 | 19 | |
... | ... | @@ -33,13 +37,16 @@ public class MemberRpcService { |
33 | 37 | * 会员服务 |
34 | 38 | */ |
35 | 39 | private final MemberApi memberApi; |
40 | + private final FunctionApi functionApi; | |
36 | 41 | |
37 | 42 | /** |
38 | 43 | * 默认构造器 |
39 | 44 | */ |
40 | 45 | @Autowired |
41 | - public MemberRpcService(final MemberApi memberApi) { | |
46 | + public MemberRpcService(final MemberApi memberApi, | |
47 | + final FunctionApi functionApi) { | |
42 | 48 | this.memberApi = memberApi; |
49 | + this.functionApi = functionApi; | |
43 | 50 | } |
44 | 51 | |
45 | 52 | /** |
... | ... | @@ -128,7 +135,6 @@ public class MemberRpcService { |
128 | 135 | log.error("调用Member系统根据会员手机号[{}]获取会员信息失败,原因:{}", mobile, e); |
129 | 136 | } |
130 | 137 | return null; |
131 | - | |
132 | 138 | } |
133 | 139 | |
134 | 140 | /** |
... | ... | @@ -143,12 +149,43 @@ public class MemberRpcService { |
143 | 149 | BeanUtils.copyProperties(memberUser, vo); |
144 | 150 | vo.setNickName(StringUtils.isNotBlank(memberUser.getNickName()) ? memberUser.getNickName() : memberUser.getRealName()); |
145 | 151 | final Message<UserBaseInfoVO> msg = memberApi.register(vo); |
146 | - isTrue(msg.isSuccess(), String.format("调用Member[注册会员[{}]]系统失败", vo)); | |
152 | + isTrue(msg.isSuccess(), String.format("调用Member[注册会员[%s]]系统失败", vo)); | |
147 | 153 | final UserBaseInfoVO user = msg.getData(); |
148 | - notNull(user, String.format("调用Member[注册会员[{}]]系统失败,返回会员信息为空", vo)); | |
154 | + notNull(user, String.format("调用Member[注册会员[%s]]系统失败,返回会员信息为空", vo)); | |
149 | 155 | final MemberUserDTO userDTO = new MemberUserDTO(); |
150 | 156 | BeanUtils.copyProperties(user, userDTO); |
151 | 157 | return userDTO; |
152 | 158 | } |
153 | 159 | |
160 | + /** | |
161 | + * 查询手机号归属地 | |
162 | + * | |
163 | + * @param mobile | |
164 | + * @return | |
165 | + */ | |
166 | + @Cacheable(cacheNames = "mobile:attribution", key = "#mobile", unless = "#result.isEmpty()") | |
167 | + public String attribution(final String mobile) { | |
168 | + if (StringUtils.isBlank(mobile)) { | |
169 | + return ""; | |
170 | + } | |
171 | + try { | |
172 | + MobileUtil.Result result = MobileUtil.attribution(mobile); | |
173 | + if (Objects.nonNull(result) && StringUtils.isNotBlank(result.getCityDesc())) { | |
174 | + return result.getCityDesc(); | |
175 | + } | |
176 | + Message<MobileLocation> msg = functionApi.queryMobileLocation(mobile); | |
177 | + if (!msg.isSuccess()) { | |
178 | + return ""; | |
179 | + } | |
180 | + MobileLocation data = msg.getData(); | |
181 | + if (data != null) { | |
182 | + String province = data.getProvince(); | |
183 | + String city = data.getCity(); | |
184 | + return province.concat(" ").concat(city); | |
185 | + } | |
186 | + } catch (Exception ignored) { | |
187 | + } | |
188 | + return ""; | |
189 | + } | |
190 | + | |
154 | 191 | } | ... | ... |
fw-valhalla-server/src/main/resources/application.yml
... | ... | @@ -7,11 +7,12 @@ spring: |
7 | 7 | locker: |
8 | 8 | key-prefix: 'valhalla:locker:' |
9 | 9 | custom: |
10 | - global-prefix: valhalla | |
10 | + global-prefix: 'valhalla' | |
11 | 11 | global: |
12 | - ttl: 10m | |
13 | - use-json: true | |
12 | + ttl: 12h | |
14 | 13 | cache: |
14 | + - name: mobile:attribution | |
15 | + ttl: 8h | |
15 | 16 | - name: pub:stand |
16 | 17 | ttl: 12h |
17 | 18 | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/ContactBizService.java
... | ... | @@ -6,7 +6,6 @@ import cn.fw.data.base.domain.common.Message; |
6 | 6 | import cn.fw.hermes.sdk.api.ImSendMessage; |
7 | 7 | import cn.fw.hermes.sdk.api.para.BusinessType; |
8 | 8 | import cn.fw.hermes.sdk.api.para.MsgParamCondition; |
9 | -import cn.fw.valhalla.common.utils.MobileUtil; | |
10 | 9 | import cn.fw.valhalla.common.utils.StringUtils; |
11 | 10 | import cn.fw.valhalla.domain.db.customer.Customer; |
12 | 11 | import cn.fw.valhalla.domain.db.customer.CustomerBaseInfo; |
... | ... | @@ -100,7 +99,7 @@ public class ContactBizService { |
100 | 99 | contactVO.setPhone(baseInfo.getMobile()); |
101 | 100 | contactVO.setMemberId(baseInfo.getMemberId()); |
102 | 101 | contactVO.setRelation(ContactRelationEnum.SELF.getValue()); |
103 | - contactVO.setRegion(MobileUtil.attribution(baseInfo.getMobile())); | |
102 | + contactVO.setRegion(memberRpcService.attribution(baseInfo.getMobile())); | |
104 | 103 | } |
105 | 104 | voList.add(contactVO); |
106 | 105 | final List<CustomerContact> list = contactsService.list(Wrappers.<CustomerContact>lambdaQuery() |
... | ... | @@ -114,7 +113,7 @@ public class ContactBizService { |
114 | 113 | vo.setId(contact.getId()); |
115 | 114 | vo.setType(contact.getType().getValue()); |
116 | 115 | vo.setRelation(contact.getRelation().getValue()); |
117 | - vo.setRegion(MobileUtil.attribution(contact.getPhone())); | |
116 | + vo.setRegion(memberRpcService.attribution(contact.getPhone())); | |
118 | 117 | voList.add(vo); |
119 | 118 | } |
120 | 119 | return voList; | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PCFollowBizService.java
1 | 1 | package cn.fw.valhalla.service.bus.follow; |
2 | 2 | |
3 | -import cn.fw.valhalla.common.utils.MobileUtil; | |
4 | 3 | import cn.fw.valhalla.domain.db.follow.FollowRecord; |
5 | 4 | import cn.fw.valhalla.domain.db.follow.FollowRecordLog; |
6 | 5 | import cn.fw.valhalla.domain.db.pool.PublicCluePool; |
... | ... | @@ -11,6 +10,7 @@ import cn.fw.valhalla.domain.enums.FollowTypeEnum; |
11 | 10 | import cn.fw.valhalla.domain.vo.follow.FollowDetailVO; |
12 | 11 | import cn.fw.valhalla.domain.vo.follow.FollowRecordVO; |
13 | 12 | import cn.fw.valhalla.domain.vo.follow.PublicPoolDetailVO; |
13 | +import cn.fw.valhalla.rpc.member.MemberRpcService; | |
14 | 14 | import cn.fw.valhalla.service.bus.cust.CustomerBizService; |
15 | 15 | import cn.fw.valhalla.service.data.FollowRecordLogService; |
16 | 16 | import cn.fw.valhalla.service.data.FollowRecordService; |
... | ... | @@ -42,6 +42,7 @@ public class PCFollowBizService { |
42 | 42 | private final CustomerBizService customerBizService; |
43 | 43 | private final FollowRecordService followRecordService; |
44 | 44 | private final FollowRecordLogService followRecordLogService; |
45 | + private final MemberRpcService memberRpcService; | |
45 | 46 | |
46 | 47 | |
47 | 48 | public FollowDetailVO getDetail(Long id) { |
... | ... | @@ -156,7 +157,7 @@ public class PCFollowBizService { |
156 | 157 | vo.setCustomerId(customerId); |
157 | 158 | vo.setName(customerDetailDto.getName()); |
158 | 159 | vo.setMobile(customerDetailDto.getMobile()); |
159 | - vo.setRegion(MobileUtil.attribution(customerDetailDto.getMobile())); | |
160 | + vo.setRegion(memberRpcService.attribution(customerDetailDto.getMobile())); | |
160 | 161 | vo.setRealMobile(customerDetailDto.getMobile()); |
161 | 162 | vo.setPlateNo(customerDetailDto.getPlateNo()); |
162 | 163 | vo.setVin(customerDetailDto.getFrameNo()); | ... | ... |