|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.unions.bo.UserRegisterBuyBO;
|
|
|
import com.yoho.service.model.response.PageResponseBO;
|
|
|
import com.yoho.service.model.union.request.UserRegisterBuyVO;
|
|
|
import com.yoho.service.model.union.response.UserRegisterBuyBO;
|
|
|
import com.yoho.unions.common.redis.RedisValueCache;
|
|
|
import com.yoho.unions.common.service.IBusinessExportService;
|
|
|
import com.yoho.unions.dal.IOrdersMapper;
|
|
|
import com.yoho.unions.dal.IUserProfileDAO;
|
|
|
import com.yoho.unions.dal.model.UserProfile;
|
|
|
import com.yoho.unions.server.service.IUserRegisterBuyInfoService;
|
|
|
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;
|
...
|
...
|
@@ -20,8 +27,9 @@ import java.util.List; |
|
|
/**
|
|
|
* Created by jianhui.wang on 2017/7/25.
|
|
|
*/
|
|
|
@Service
|
|
|
public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoService {
|
|
|
@Service("UserRegisterBuy")
|
|
|
public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoService, IBusinessExportService {
|
|
|
|
|
|
static Logger logger = LoggerFactory.getLogger("UserRegisterBuyInfoserviceImpl");
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -30,6 +38,9 @@ public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoServi |
|
|
@Autowired
|
|
|
IOrdersMapper ordersMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisValueCache redisValueCache;
|
|
|
|
|
|
@Override
|
|
|
public List<UserRegisterBuyBO> UserRegisterBuyInfo(UserMobileAndUidVO userPhoneNumberVO) {
|
|
|
logger.info("enter UserRegisterBuyInfo with mobile={}", userPhoneNumberVO.getMobile());
|
...
|
...
|
@@ -37,8 +48,8 @@ public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoServi |
|
|
logger.warn("UserRegisterBuyInfo: request param is null");
|
|
|
throw new ServiceException(ServiceError.REQUEST_PARAM_INVALID);
|
|
|
}
|
|
|
boolean isMobile =false;
|
|
|
// PhoneUtil.areaMobileVerify(userPhoneNumberVO.getUid(), userPhoneNumberVO.getMobile());
|
|
|
boolean isMobile = false;
|
|
|
// PhoneUtil.areaMobileVerify(userPhoneNumberVO.getUid(), userPhoneNumberVO.getMobile());
|
|
|
if (!isMobile) {
|
|
|
// 402, '手机号码格式错误'
|
|
|
logger.warn("checkBindParam error because MOBILE_IS_ERROR mobile={}", userPhoneNumberVO.getMobile());
|
...
|
...
|
@@ -51,16 +62,86 @@ public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoServi |
|
|
}
|
|
|
|
|
|
UserRegisterBuyBO userRegisterBuyBO = new UserRegisterBuyBO();
|
|
|
userRegisterBuyBO.setRegister(true);
|
|
|
userRegisterBuyBO.setRegister("");
|
|
|
userRegisterBuyBO.setUid(userProfile.getUid());
|
|
|
userRegisterBuyBO.setRegisterTime(userProfile.getCreateTime());
|
|
|
userRegisterBuyBO.setRegisterTime(DateUtils.getDateString(userProfile.getCreateTime()));
|
|
|
|
|
|
int flag = ordersMapper.selectCountShipStatusOrderSince(userProfile.getUid(), userProfile.getCreateTime());
|
|
|
if (flag > 0) {
|
|
|
userRegisterBuyBO.setBuy(true);
|
|
|
userRegisterBuyBO.setBuy("已购买");
|
|
|
}
|
|
|
List<UserRegisterBuyBO> UserRegisterBuyList = new ArrayList<>();
|
|
|
UserRegisterBuyList.add(userRegisterBuyBO);
|
|
|
return UserRegisterBuyList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<UserRegisterBuyBO> getUserRegisterBuyList(UserRegisterBuyVO userRegisterBuyVO) {
|
|
|
PageResponseBO<UserRegisterBuyBO> page = new PageResponseBO<>();
|
|
|
List<UserRegisterBuyBO> userInfoList = new ArrayList<>();
|
|
|
List<UserRegisterBuyBO> getuserInfoList = new ArrayList<>();
|
|
|
|
|
|
int i = 0;
|
|
|
UserRegisterBuyBO userRegisterBuyBO = new UserRegisterBuyBO();
|
|
|
do {
|
|
|
userRegisterBuyBO = redisValueCache.get("userRegisterBuyListKey" + Integer.toString(i), UserRegisterBuyBO.class);
|
|
|
if (userRegisterBuyBO == null) {
|
|
|
break;
|
|
|
}
|
|
|
userInfoList.add(i, userRegisterBuyBO);
|
|
|
i++;
|
|
|
}
|
|
|
while (userRegisterBuyBO != null);
|
|
|
|
|
|
for (int k = 0; k < userInfoList.size(); k++) {
|
|
|
if ("0".equals(userRegisterBuyVO.getRegister()) && ("0".equals(userInfoList.get(k).getBuy()) || "1".equals(userInfoList.get(k).getBuy()))) {
|
|
|
if ("未注册".equals(userInfoList.get(k).getRegister()) && "未购买".equals(userInfoList.get(k).getBuy())) {
|
|
|
getuserInfoList.add(userInfoList.get(k));
|
|
|
}
|
|
|
}
|
|
|
if ("1".equals(userRegisterBuyVO.getRegister()) && "0".equals(userRegisterBuyVO.getBuy())) {
|
|
|
if ("已注册".equals(userInfoList.get(k).getRegister()) && "未购买".equals(userInfoList.get(k).getBuy())) {
|
|
|
getuserInfoList.add(userInfoList.get(k));
|
|
|
}
|
|
|
}
|
|
|
if ("1".equals(userRegisterBuyVO.getRegister()) && "1".equals(userRegisterBuyVO.getBuy())) {
|
|
|
if ("已注册".equals(userInfoList.get(k).getRegister()) && "已购买".equals(userInfoList.get(k).getBuy())) {
|
|
|
getuserInfoList.add(userInfoList.get(k));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
page.setPage_total(1);
|
|
|
page.setTotal(getuserInfoList.size());
|
|
|
page.setPageSize(getuserInfoList.size());
|
|
|
page.setPage(1);
|
|
|
page.setList(getuserInfoList);
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Class getDataClass() {
|
|
|
return UserRegisterBuyBO.class;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<? extends Object> batchExport(String confStr) {
|
|
|
try {
|
|
|
UserRegisterBuyVO userRegisterBuyVO =new UserRegisterBuyVO();
|
|
|
userRegisterBuyVO.setRegister(confStr.substring(15,16));
|
|
|
userRegisterBuyVO.setBuy(confStr.substring(27,28));
|
|
|
PageResponseBO<UserRegisterBuyBO> pageResponseBO = getUserRegisterBuyList(userRegisterBuyVO);
|
|
|
List<UserRegisterBuyBO> UserRegisterBuyBOList = pageResponseBO.getList();
|
|
|
if (CollectionUtils.isEmpty(UserRegisterBuyBOList)) {
|
|
|
throw new ServiceException(400, "没有要导出的数据");
|
|
|
}
|
|
|
return UserRegisterBuyBOList;
|
|
|
} catch (JSONException e) {
|
|
|
logger.warn("parse confStr error: confStr {}, e {}", confStr, e);
|
|
|
throw new ServiceException(400, "传入数据格式错误");
|
|
|
} catch (com.yoho.error.exception.ServiceException e) {
|
|
|
logger.warn("make url error params is confStr {}, e {}", confStr, e);
|
|
|
throw new ServiceException(e.getCode(), e.getErrorMessage());
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|