|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.service.model.union.response.PageuserRegisterBuyResponseBO;
|
|
|
import com.yoho.unions.bo.UserRegisterBuyBO;
|
|
|
import com.yoho.unions.common.redis.RedisTemplate;
|
|
|
import com.yoho.unions.common.redis.RedisValueCache;
|
|
|
import com.yoho.unions.common.service.IBusinessImportService;
|
|
|
import com.yoho.unions.dal.IOrdersMapper;
|
|
|
import com.yoho.unions.dal.IUserProfileDAO;
|
|
|
import com.yoho.unions.dal.model.UserProfile;
|
|
|
import com.yoho.unions.utils.DateUtils;
|
|
|
import com.yoho.unions.vo.UserMobileAndUidVO;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@Service
|
|
|
public class userInfoImportServiceImpl implements IBusinessImportService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(userInfoImportServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
IOrdersMapper ordersMapper;
|
|
|
@Autowired
|
|
|
IUserProfileDAO userProfileDAO;
|
|
|
@Autowired
|
|
|
private RedisValueCache redisValueCache;
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
@Override
|
|
|
public Class getDataClass() {
|
|
|
return UserMobileAndUidVO.class;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object batchImport(List<Object> dataList) throws ExecutionException, InterruptedException {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object batchImport(List<Object> dataList, String args) throws ExecutionException, InterruptedException {
|
|
|
logger.debug("method batchImport(List<Object>) in.dataList is {}, args:{}", dataList, args);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
|
|
logger.warn("batch import dataList is empty");
|
|
|
}
|
|
|
|
|
|
List<UserMobileAndUidVO> userMobileAndUidVOList = Lists.newArrayList();
|
|
|
|
|
|
for (Object userMobileAndUidVO : dataList) {
|
|
|
userMobileAndUidVOList.add((UserMobileAndUidVO) userMobileAndUidVO);
|
|
|
}
|
|
|
UserProfile userProfile = new UserProfile();
|
|
|
|
|
|
List<UserRegisterBuyBO> userRegisterBuyList = new ArrayList<>();
|
|
|
|
|
|
List<UserRegisterBuyBO> TestuserRegisterBuyList = new ArrayList<>();
|
|
|
|
|
|
redisTemplate.delete("userRegisterBuyListKey*");
|
|
|
|
|
|
for (int i = 0; i < userMobileAndUidVOList.size(); i++) {
|
|
|
String mobile = userMobileAndUidVOList.get(i).getMobile();
|
|
|
int uid = userMobileAndUidVOList.get(i).getUid();
|
|
|
|
|
|
if (uid > 0) {
|
|
|
userProfile = userProfileDAO.selectByPrimaryKey(uid);
|
|
|
}
|
|
|
if (uid <= 0 && StringUtils.isNoneEmpty(mobile)) {
|
|
|
userProfile = userProfileDAO.selectProfileByMobile(mobile);
|
|
|
}
|
|
|
UserRegisterBuyBO userRegisterBuyBO_i = new UserRegisterBuyBO();
|
|
|
if (userProfile == null) {
|
|
|
// logger.warn("UserRegisterBuyInfo:uid is {},mobile is {},userSource is {}", userProfile.getUid(), userProfile.getMobile(), userProfile.getUserSource());
|
|
|
// throw new ServiceException(ServiceError.USER_NOT_EXIST);
|
|
|
userRegisterBuyBO_i.setId(i + 1);
|
|
|
userRegisterBuyBO_i.setMobile(mobile.substring(0, 3) + " **** " + mobile.substring(6, 10));
|
|
|
userRegisterBuyBO_i.setRegister("未注册");
|
|
|
userRegisterBuyBO_i.setUid(uid <= 0 ? 0 : uid);
|
|
|
userRegisterBuyBO_i.setRegisterTime("0");
|
|
|
userRegisterBuyBO_i.setBuy("未购买");
|
|
|
} else {
|
|
|
userRegisterBuyBO_i.setId(i + 1);
|
|
|
userRegisterBuyBO_i.setMobile(userProfile.getMobile().substring(0, 3) + " **** " + userProfile.getMobile().substring(6, 10));
|
|
|
userRegisterBuyBO_i.setRegister("已注册");
|
|
|
userRegisterBuyBO_i.setUid(userProfile.getUid());
|
|
|
userRegisterBuyBO_i.setRegisterTime(DateUtils.getDateString(userProfile.getCreateTime()));
|
|
|
|
|
|
int flag = ordersMapper.selectCountShipStatusOrderSince(userProfile.getUid(), userProfile.getCreateTime());
|
|
|
if (flag > 0) {
|
|
|
userRegisterBuyBO_i.setBuy("已购买");
|
|
|
} else {
|
|
|
userRegisterBuyBO_i.setBuy("未购买");
|
|
|
}
|
|
|
}
|
|
|
userRegisterBuyList.add(userRegisterBuyBO_i);
|
|
|
|
|
|
// redisTemplate.delete("userRegisterBuyListKey"+Integer.toString(i));
|
|
|
redisValueCache.set("userRegisterBuyListKey"+Integer.toString(i),userRegisterBuyBO_i,120, TimeUnit.MINUTES);
|
|
|
}
|
|
|
|
|
|
|
|
|
// if (redisValueCache.get(ListKey) == null) {
|
|
|
// redisValueCache.set(ListKey, userRegisterBuyList, 120, TimeUnit.MINUTES);
|
|
|
// } else {
|
|
|
// redisTemplate.delete(ListKey);
|
|
|
// redisValueCache.set(ListKey, userRegisterBuyList, 120, TimeUnit.MINUTES);
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/* redisTemplate.delete(ListKey);
|
|
|
|
|
|
redisListCache.rightPushAll(ListKey, userRegisterBuyList.toString(), 120, TimeUnit.MINUTES);
|
|
|
|
|
|
redisListCache.range(ListKey, UserRegisterBuyBO.class, 0, -1);
|
|
|
*/
|
|
|
|
|
|
|
|
|
// redisValueCache.set(ListKey, userRegisterBuyList, 120, TimeUnit.MINUTES);
|
|
|
|
|
|
userRegisterBuyList = Lists.transform(Lists.newArrayList(userRegisterBuyList), input -> {
|
|
|
UserRegisterBuyBO output = new UserRegisterBuyBO();
|
|
|
BeanUtils.copyProperties(input, output);
|
|
|
return output;
|
|
|
});
|
|
|
|
|
|
PageuserRegisterBuyResponseBO pageuserRegisterBuyResponseBO = new PageuserRegisterBuyResponseBO();
|
|
|
pageuserRegisterBuyResponseBO.setList(userRegisterBuyList);
|
|
|
pageuserRegisterBuyResponseBO.setTotal(userRegisterBuyList.size());
|
|
|
pageuserRegisterBuyResponseBO.setPage(1);
|
|
|
pageuserRegisterBuyResponseBO.setTotalPage(1);
|
|
|
|
|
|
logger.debug("method batchImport(List<Object>) out.");
|
|
|
return pageuserRegisterBuyResponseBO;
|
|
|
}
|
|
|
} |