|
|
package com.yohobuy.platform.grass.service.impl;
|
|
|
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.quartz.utils.DateUtils;
|
|
|
import com.yoho.service.model.request.UserBaseReqBO;
|
|
|
import com.yoho.service.model.response.CommonRspBO;
|
|
|
import com.yoho.service.model.social.request.BaseReqBO;
|
|
|
import com.yoho.service.model.social.request.UicUserReqBO;
|
|
|
import com.yoho.service.model.social.response.UserInfoRspBO;
|
...
|
...
|
@@ -8,12 +11,16 @@ import com.yoho.service.model.social.response.UserLoginInfoRspBO; |
|
|
import com.yohobuy.platform.common.util.DateUtil;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassArticleDao;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassVirtualUserDao;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassArticle;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassUserAchieve;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassVirtualUser;
|
|
|
import com.yohobuy.platform.grass.service.IGrassArticleService;
|
|
|
import com.yohobuy.platform.grass.service.IGrassUserService;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
import com.yohobuy.platform.model.grass.request.GrassUserManageReq;
|
|
|
import com.yohobuy.platform.model.grass.response.GrassUserRespBo;
|
|
|
import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
...
|
...
|
@@ -45,6 +52,12 @@ public class GrassUserServiceImpl implements IGrassUserService{ |
|
|
private IGrassArticleDao articleDao;
|
|
|
|
|
|
@Autowired
|
|
|
private IGrassVirtualUserDao virtualUserDao;
|
|
|
|
|
|
@Autowired
|
|
|
IGrassArticleService grassArticleService;
|
|
|
|
|
|
@Autowired
|
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
@Value("${uic.service.url:http://uic.yohoops.org/uic}")
|
...
|
...
|
@@ -104,6 +117,123 @@ public class GrassUserServiceImpl implements IGrassUserService{ |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 马甲用户列表
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public PageResponseVO<GrassVirtualUserRespBo> grassVirtualList(GrassUserManageReq req) {
|
|
|
logger.info("enter grassVirtualList req={}", req);
|
|
|
PageResponseVO responseVO = new PageResponseVO();
|
|
|
responseVO.setList(new ArrayList());
|
|
|
responseVO.setTotal(0);
|
|
|
responseVO.setPage(req.getPage());
|
|
|
responseVO.setSize(req.getSize());
|
|
|
|
|
|
List<Integer> uids = new ArrayList<>();
|
|
|
if(StringUtils.isNotEmpty(req.getNickName())){//昵称,先去uic查
|
|
|
uids = grassArticleService.getUidByNickName(req.getNickName());
|
|
|
if(CollectionUtils.isEmpty(uids)){
|
|
|
logger.info("grassVirtualList result is null, nickName not found, req={}", req);
|
|
|
return responseVO;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(req.getUid() != null){
|
|
|
uids.add(req.getUid());
|
|
|
}
|
|
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
params.put("status",req.getStatus() == null || req.getStatus() == 8 ? null : req.getStatus());
|
|
|
params.put("nickName",req.getNickName());
|
|
|
params.put("uids",uids);
|
|
|
params.put("startTime",req.getStartTime());
|
|
|
params.put("endTime",req.getEndTime());
|
|
|
|
|
|
int total = virtualUserDao.countByCondition(params);
|
|
|
responseVO.setTotal(total);
|
|
|
if(total == 0){
|
|
|
logger.info("grassVirtualList total is 0, req={}", req);
|
|
|
return responseVO;
|
|
|
}
|
|
|
|
|
|
List<GrassVirtualUser> list = virtualUserDao.selectByPage(params, req.getStart(), req.getSize());
|
|
|
List<GrassVirtualUserRespBo> data = buildVirtualInfo(list);
|
|
|
responseVO.setList(data);
|
|
|
logger.info("grassVirtualList success! req={}, total = {}",req, total);
|
|
|
return responseVO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改马甲用户信息
|
|
|
* @param req
|
|
|
*/
|
|
|
@Override
|
|
|
public void updateVirtualUser(GrassUserManageReq req) {
|
|
|
logger.info("enter updateVirtualUser req={}", req);
|
|
|
Integer type = req.getType() == null ? 0 : req.getType() ;
|
|
|
if(type == 1){//修改状态
|
|
|
virtualUserDao.changeStatusByUid(req.getUid(), req.getStatus());
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
//修改基本信息(头像,签名等)
|
|
|
String url = uicUrl + "/UserInfoRest/updateUserBase";
|
|
|
UserBaseReqBO uicReq = new UserBaseReqBO();
|
|
|
uicReq.setUid(req.getUid());
|
|
|
uicReq.setNick_name(req.getNickName());
|
|
|
uicReq.setHeadIco(req.getHeadIcon());
|
|
|
logger.info("updateVirtualUser call uic.modifyUserBase url ={}, uicReq={}", url, uicReq);
|
|
|
//调uic 的接口(修改头像等)
|
|
|
serviceCaller.post("uic.modifyUserBase", url, uicReq, CommonRspBO.class, null).get();
|
|
|
//
|
|
|
GrassUserAchieve grassUserAchieve = userAchieveDAO.selectByUid(req.getUid());
|
|
|
if(grassUserAchieve == null){
|
|
|
grassUserAchieve = new GrassUserAchieve();
|
|
|
grassUserAchieve.setUid(req.getUid());
|
|
|
grassUserAchieve.setSignature(req.getSignature());
|
|
|
grassUserAchieve.setCreateTime((int) (System.currentTimeMillis() /1000));
|
|
|
userAchieveDAO.insertSelective(grassUserAchieve);
|
|
|
logger.info("updateVirtualUser create userAchieve success! req={} ", req);
|
|
|
}else{
|
|
|
grassUserAchieve.setSignature(Optional.ofNullable(req.getSignature()).orElse(""));
|
|
|
grassUserAchieve.setUpdateTime((int) (System.currentTimeMillis() /1000));
|
|
|
userAchieveDAO.updateSelective(grassUserAchieve);
|
|
|
logger.info("updateVirtualUser update userAchieve success! req={} ", req);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//马甲用户的详细信息
|
|
|
private List<GrassVirtualUserRespBo> buildVirtualInfo(List<GrassVirtualUser> list) {
|
|
|
List<GrassVirtualUserRespBo> result = new ArrayList<>();
|
|
|
if(CollectionUtils.isEmpty(list)){
|
|
|
return result;
|
|
|
}
|
|
|
//查询用户的头像等基本信息
|
|
|
//用户的基本信息(昵称 头像等)
|
|
|
List<Integer> uids = list.stream().map(GrassVirtualUser::getUid).collect(Collectors.toList());
|
|
|
Map<Integer,UserInfoRspBO> userInfoMap = getUsersInfo(uids);
|
|
|
|
|
|
//获取签名信息
|
|
|
List<GrassUserAchieve> userAchieves = userAchieveDAO.selectByUids(uids);
|
|
|
Map<Integer,String > userAchieveMap = userAchieves.stream().collect(Collectors.toMap(GrassUserAchieve::getUid, obj -> obj.getSignature() == null ? "" : obj.getSignature()));
|
|
|
|
|
|
//组装信息
|
|
|
for(GrassVirtualUser user : list){
|
|
|
GrassVirtualUserRespBo bo = new GrassVirtualUserRespBo();
|
|
|
bo.setUid(user.getUid());
|
|
|
UserInfoRspBO userInfoRspBO = userInfoMap.get(user.getUid());
|
|
|
bo.setNickName(userInfoRspBO == null ? "" : userInfoRspBO.getNickName());
|
|
|
bo.setHeadIcon(userInfoRspBO == null ? "" : buildHeadIcon(userInfoRspBO.getHeadIco()));
|
|
|
bo.setSignature(userAchieveMap.get(user.getUid()) == null ? "" : userAchieveMap.get(user.getUid()));
|
|
|
bo.setCreateTimeStr(DateUtil.getDateFormatFromInt(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
bo.setStatus(user.getStatus());
|
|
|
result.add(bo);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据昵称查询
|
|
|
* 先去查询uic --精确查询
|
|
|
* @param req
|
...
|
...
|
|