1
|
package com.yoho.ufo.service;
|
1
|
package com.yoho.ufo.service;
|
2
|
|
2
|
|
|
|
3
|
+import java.util.List;
|
|
|
4
|
+import java.util.Map;
|
|
|
5
|
+import java.util.Objects;
|
|
|
6
|
+import java.util.concurrent.TimeUnit;
|
|
|
7
|
+import java.util.stream.Collectors;
|
|
|
8
|
+
|
|
|
9
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
10
|
+import org.slf4j.Logger;
|
|
|
11
|
+import org.slf4j.LoggerFactory;
|
|
|
12
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
13
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
14
|
+import org.springframework.stereotype.Service;
|
|
|
15
|
+
|
3
|
import com.alibaba.fastjson.JSONArray;
|
16
|
import com.alibaba.fastjson.JSONArray;
|
4
|
import com.alibaba.fastjson.JSONObject;
|
17
|
import com.alibaba.fastjson.JSONObject;
|
|
|
18
|
+import com.google.common.collect.Lists;
|
5
|
import com.google.common.collect.Maps;
|
19
|
import com.google.common.collect.Maps;
|
6
|
import com.yoho.core.rest.client.ServiceCaller;
|
20
|
import com.yoho.core.rest.client.ServiceCaller;
|
7
|
import com.yoho.error.ServiceError;
|
21
|
import com.yoho.error.ServiceError;
|
8
|
import com.yoho.error.exception.ServiceException;
|
22
|
import com.yoho.error.exception.ServiceException;
|
9
|
import com.yoho.service.model.request.UserAddressReqBO;
|
23
|
import com.yoho.service.model.request.UserAddressReqBO;
|
|
|
24
|
+import com.yoho.service.model.response.ProfileInfoRsp;
|
10
|
import com.yoho.ufo.convert.AddressInfoConvertor;
|
25
|
import com.yoho.ufo.convert.AddressInfoConvertor;
|
11
|
import com.yohobuy.ufo.model.common.ApiResponse;
|
26
|
import com.yohobuy.ufo.model.common.ApiResponse;
|
12
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
27
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
13
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
14
|
-import org.slf4j.Logger;
|
|
|
15
|
-import org.slf4j.LoggerFactory;
|
|
|
16
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
17
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
18
|
-import org.springframework.stereotype.Service;
|
|
|
19
|
-
|
|
|
20
|
-import java.util.Map;
|
|
|
21
|
-import java.util.Objects;
|
|
|
22
|
-import java.util.concurrent.TimeUnit;
|
|
|
23
|
|
28
|
|
24
|
/**
|
29
|
/**
|
25
|
* Created by chenchao on 2018/9/18.
|
30
|
* Created by chenchao on 2018/9/18.
|
|
@@ -38,6 +43,9 @@ public class UserProxyService { |
|
@@ -38,6 +43,9 @@ public class UserProxyService { |
38
|
|
43
|
|
39
|
@Value("${uic.url:http://uic.yohoops.org/uic}")
|
44
|
@Value("${uic.url:http://uic.yohoops.org/uic}")
|
40
|
private String uicUrl;
|
45
|
private String uicUrl;
|
|
|
46
|
+
|
|
|
47
|
+ @Value("${ip.port.uic.server}")
|
|
|
48
|
+ private String uicServerIpAndPort;
|
41
|
|
49
|
|
42
|
/**
|
50
|
/**
|
43
|
* 获取用户信息
|
51
|
* 获取用户信息
|
|
@@ -110,6 +118,8 @@ public class UserProxyService { |
|
@@ -110,6 +118,8 @@ public class UserProxyService { |
110
|
* @return
|
118
|
* @return
|
111
|
*/
|
119
|
*/
|
112
|
public static final String PRFILE_API = "/profile/getProfile";
|
120
|
public static final String PRFILE_API = "/profile/getProfile";
|
|
|
121
|
+
|
|
|
122
|
+ public static final String GET_USER_PROFILES_BY_UIDS = "/profile/getUserProfilesByUids";
|
113
|
public String getMobile(int uid){
|
123
|
public String getMobile(int uid){
|
114
|
String url = uicUrl + PRFILE_API;
|
124
|
String url = uicUrl + PRFILE_API;
|
115
|
Map<String,Object> params = Maps.newHashMap();
|
125
|
Map<String,Object> params = Maps.newHashMap();
|
|
@@ -134,5 +144,29 @@ public class UserProxyService { |
|
@@ -134,5 +144,29 @@ public class UserProxyService { |
134
|
}
|
144
|
}
|
135
|
return mobile;
|
145
|
return mobile;
|
136
|
}
|
146
|
}
|
|
|
147
|
+
|
|
|
148
|
+ public List<String> queryMobilesByUids(List<Integer> uidList) {
|
|
|
149
|
+ String url = uicUrl + GET_USER_PROFILES_BY_UIDS;
|
|
|
150
|
+ String uids = getUidStrs(uidList);
|
|
|
151
|
+ List<ProfileInfoRsp> result = Lists.newArrayList();
|
|
|
152
|
+ try {
|
|
|
153
|
+ result = serviceCaller.post("uic.getUserProfilesByUids", url, uids, List.class, null).get(5);
|
|
|
154
|
+ } catch (Exception e) {
|
|
|
155
|
+ logger.error("call"+ url + " fail!!! uids is {}", uids);
|
|
|
156
|
+ }
|
|
|
157
|
+ logger.info("result is {}", result);
|
|
|
158
|
+
|
|
|
159
|
+ return result.stream().map(ProfileInfoRsp::getMobile).collect(Collectors.toList());
|
|
|
160
|
+
|
|
|
161
|
+ }
|
|
|
162
|
+
|
|
|
163
|
+ private String getUidStrs(List<Integer> uidList) {
|
|
|
164
|
+ List<String> uidStrList = Lists.newArrayList();
|
|
|
165
|
+ for(Integer uid : uidList) {
|
|
|
166
|
+ uidStrList.add(String.valueOf(uid));
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ return String.join(",", uidStrList);
|
|
|
170
|
+ }
|
137
|
|
171
|
|
138
|
} |
172
|
} |