|
|
package com.yoho.ufo.service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.request.UserAddressReqBO;
|
|
|
import com.yoho.service.model.response.ProfileInfoRsp;
|
|
|
import com.yoho.ufo.convert.AddressInfoConvertor;
|
|
|
import com.yohobuy.ufo.model.common.ApiResponse;
|
|
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* Created by chenchao on 2018/9/18.
|
...
|
...
|
@@ -38,6 +43,9 @@ public class UserProxyService { |
|
|
|
|
|
@Value("${uic.url:http://uic.yohoops.org/uic}")
|
|
|
private String uicUrl;
|
|
|
|
|
|
@Value("${ip.port.uic.server}")
|
|
|
private String uicServerIpAndPort;
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息
|
...
|
...
|
@@ -110,6 +118,8 @@ public class UserProxyService { |
|
|
* @return
|
|
|
*/
|
|
|
public static final String PRFILE_API = "/profile/getProfile";
|
|
|
|
|
|
public static final String GET_USER_PROFILES_BY_UIDS = "/profile/getUserProfilesByUids";
|
|
|
public String getMobile(int uid){
|
|
|
String url = uicUrl + PRFILE_API;
|
|
|
Map<String,Object> params = Maps.newHashMap();
|
...
|
...
|
@@ -134,5 +144,29 @@ public class UserProxyService { |
|
|
}
|
|
|
return mobile;
|
|
|
}
|
|
|
|
|
|
public List<String> queryMobilesByUids(List<Integer> uidList) {
|
|
|
String url = uicUrl + GET_USER_PROFILES_BY_UIDS;
|
|
|
String uids = getUidStrs(uidList);
|
|
|
List<ProfileInfoRsp> result = Lists.newArrayList();
|
|
|
try {
|
|
|
result = serviceCaller.post("uic.getUserProfilesByUids", url, uids, List.class, null).get(5);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("call"+ url + " fail!!! uids is {}", uids);
|
|
|
}
|
|
|
logger.info("result is {}", result);
|
|
|
|
|
|
return result.stream().map(ProfileInfoRsp::getMobile).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
private String getUidStrs(List<Integer> uidList) {
|
|
|
List<String> uidStrList = Lists.newArrayList();
|
|
|
for(Integer uid : uidList) {
|
|
|
uidStrList.add(String.valueOf(uid));
|
|
|
}
|
|
|
|
|
|
return String.join(",", uidStrList);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|