|
|
@ -22,10 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.constant.*; |
|
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
@ -38,17 +35,12 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.commons.tools.utils.NameUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.UserRoleConstant; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.RegisterRelationDTO; |
|
|
|
import com.epmet.dto.UserBaseInfoDTO; |
|
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
|
import com.epmet.dto.UserWechatDTO; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.RegisterRelationEntity; |
|
|
|
import com.epmet.entity.UserBaseInfoEntity; |
|
|
|
import com.epmet.entity.UserEntity; |
|
|
|
import com.epmet.entity.UserWechatEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.redis.UserBaseInfoRedis; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; |
|
|
@ -56,6 +48,7 @@ import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; |
|
|
|
import com.epmet.service.RegisterRelationService; |
|
|
|
import com.epmet.service.UserBaseInfoService; |
|
|
|
import com.epmet.service.UserResiInfoService; |
|
|
|
import com.epmet.service.UserRoleService; |
|
|
|
import com.epmet.util.ModuleConstant; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -103,6 +96,13 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us |
|
|
|
private UserResiInfoService userResiInfoService; |
|
|
|
@Autowired |
|
|
|
private RegisterRelationDao registerRelationDao; |
|
|
|
@Autowired |
|
|
|
private UserResiRegisterVisitDao userResiRegisterVisitDao; |
|
|
|
@Autowired |
|
|
|
private UserCustomerDao userCustomerDao; |
|
|
|
@Autowired |
|
|
|
private UserRoleService userRoleService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private UserDao userDao; |
|
|
|
@Autowired |
|
|
@ -635,6 +635,237 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public DingLoginResiResDTO hFiveResiLogin(HfiveLoginResiFormDTO formDTO) { |
|
|
|
DingLoginResiResDTO result = new DingLoginResiResDTO(); |
|
|
|
result.setCustomerId(formDTO.getCustomerId()); |
|
|
|
result.setRegFlag(false); |
|
|
|
result.setGridId(StrConstant.EPMETY_STR); |
|
|
|
result.setGridName(StrConstant.EPMETY_STR); |
|
|
|
result.setAgencyId(StrConstant.EPMETY_STR); |
|
|
|
RLock lock = null; |
|
|
|
try { |
|
|
|
lock = distributedLock.getLock(String.format("epmet:lock:dingResiLogin:%s",formDTO.getMobile()), 120L, 3L, TimeUnit.SECONDS); |
|
|
|
//根据手机号从baseinfo查对应的信息,如果有则返回,没有则注册
|
|
|
|
UserBaseInfoEntity baseInfo = baseDao.selectUserByMobile(formDTO.getCustomerId(),formDTO.getMobile()); |
|
|
|
if (null == baseInfo) { |
|
|
|
//注册
|
|
|
|
UserEntity userEntity = new UserEntity(); |
|
|
|
userEntity.setFromApp(AppClientConstant.APP_RESI); |
|
|
|
userEntity.setFromClient(AppClientConstant.MINI_DING); |
|
|
|
userEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userDao.insert(userEntity); |
|
|
|
//信息存入baseinfo
|
|
|
|
baseInfo = new UserBaseInfoEntity(); |
|
|
|
baseInfo.setCustomerId(formDTO.getCustomerId()); |
|
|
|
baseInfo.setUserId(userEntity.getId()); |
|
|
|
baseInfo.setMobile(formDTO.getMobile()); |
|
|
|
// todo 没有值 假的
|
|
|
|
baseInfo.setRealName("h5"); |
|
|
|
baseInfo.setSurname("h5"); |
|
|
|
baseInfo.setName("h5"); |
|
|
|
baseInfo.setNickname("h5"); |
|
|
|
baseInfo.setHeadImgUrl(""); |
|
|
|
// todo--------- 以上都是假的
|
|
|
|
baseInfo.setGender(NumConstant.ZERO_STR); |
|
|
|
baseDao.insert(baseInfo); |
|
|
|
|
|
|
|
result.setEpmetUserId(userEntity.getId()); |
|
|
|
result.setRegFlag(false); |
|
|
|
} else { |
|
|
|
// 更新下user_Base_info信息
|
|
|
|
// todo h5那边没有传过来信息 所以不需要更新
|
|
|
|
/*if (StringUtils.isNotBlank(formDTO.getNick()) && StringUtils.isBlank(baseInfo.getRealName())) { |
|
|
|
baseInfo.setRealName(formDTO.getNick()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getNick()) && StringUtils.isBlank(baseInfo.getSurname())) { |
|
|
|
baseInfo.setSurname(NameUtils.getSurNameComplex(formDTO.getNick())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getNick()) && StringUtils.isBlank(baseInfo.getName())) { |
|
|
|
baseInfo.setName(NameUtils.getNameComplex(formDTO.getNick())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getNick()) && StringUtils.isBlank(baseInfo.getNickname())) { |
|
|
|
baseInfo.setNickname(formDTO.getNick()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getAvatarUrl()) && StringUtils.isBlank(baseInfo.getHeadImgUrl())) { |
|
|
|
baseInfo.setHeadImgUrl(formDTO.getAvatarUrl()); |
|
|
|
} |
|
|
|
baseDao.updateById(baseInfo); |
|
|
|
*/ |
|
|
|
|
|
|
|
result.setEpmetUserId(baseInfo.getUserId()); |
|
|
|
LambdaQueryWrapper<RegisterRelationEntity> registerWrapper = new LambdaQueryWrapper<>(); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getUserId, baseInfo.getUserId()); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); |
|
|
|
RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); |
|
|
|
if (null != registerRelation) { |
|
|
|
result.setAgencyId(registerRelation.getAgencyId()); |
|
|
|
result.setGridId(registerRelation.getGridId()); |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(registerRelation.getGridId()); |
|
|
|
if (null == gridInfo) { |
|
|
|
logger.error(String.format("获取用户注册网格信息为空,userId:%s,gridId:%s", baseInfo.getUserId(), registerRelation.getGridId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格信息为空", "获取小程序注册网格信息失败"); |
|
|
|
} |
|
|
|
result.setGridName(gridInfo.getGridNamePath()); |
|
|
|
result.setRegFlag(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
distributedLock.unLock(lock); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public LantuRegisterResiResDTO lantuRegisterResi(LantuRegisterResiFormDTO formDTO) { |
|
|
|
LantuRegisterResiResDTO result = new LantuRegisterResiResDTO(); |
|
|
|
result.setCustomerId(formDTO.getCustomerId()); |
|
|
|
RLock lock = null; |
|
|
|
try { |
|
|
|
lock = distributedLock.getLock(String.format("epmet:lock:dingResiLogin:%s",formDTO.getMobile()), 120L, 3L, TimeUnit.SECONDS); |
|
|
|
//根据手机号从baseinfo查对应的信息,如果有则返回,没有则注册
|
|
|
|
UserBaseInfoEntity baseInfo = baseDao.selectUserByMobile(formDTO.getCustomerId(),formDTO.getMobile()); |
|
|
|
if (null == baseInfo) { |
|
|
|
//注册 用户
|
|
|
|
UserEntity userEntity = new UserEntity(); |
|
|
|
userEntity.setFromApp(AppClientConstant.APP_RESI); |
|
|
|
userEntity.setFromClient(AppClientConstant.LAN_TU); |
|
|
|
userEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userDao.insert(userEntity); |
|
|
|
//信息存入baseinfo
|
|
|
|
baseInfo = new UserBaseInfoEntity(); |
|
|
|
baseInfo.setCustomerId(formDTO.getCustomerId()); |
|
|
|
baseInfo.setUserId(userEntity.getId()); |
|
|
|
baseInfo.setMobile(formDTO.getMobile()); |
|
|
|
baseInfo.setRealName(formDTO.getRealName()); |
|
|
|
baseInfo.setSurname(NameUtils.getSurNameComplex(formDTO.getRealName())); |
|
|
|
baseInfo.setName(NameUtils.getNameComplex(formDTO.getRealName())); |
|
|
|
baseInfo.setNickname(formDTO.getNick()); |
|
|
|
baseInfo.setHeadImgUrl(formDTO.getAvatarUrl()); |
|
|
|
baseInfo.setGender(formDTO.getSex()); |
|
|
|
baseDao.insert(baseInfo); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
// 更新下user_Base_info信息
|
|
|
|
if (StringUtils.isNotBlank(formDTO.getRealName()) && StringUtils.isBlank(baseInfo.getRealName())) { |
|
|
|
baseInfo.setRealName(formDTO.getRealName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getRealName()) && StringUtils.isBlank(baseInfo.getSurname())) { |
|
|
|
baseInfo.setSurname(NameUtils.getSurNameComplex(formDTO.getRealName())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getRealName()) && StringUtils.isBlank(baseInfo.getName())) { |
|
|
|
baseInfo.setName(NameUtils.getNameComplex(formDTO.getRealName())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getNick()) && StringUtils.isBlank(baseInfo.getNickname())) { |
|
|
|
baseInfo.setNickname(formDTO.getNick()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getSex()) && StringUtils.isBlank(baseInfo.getGender())) { |
|
|
|
baseInfo.setGender(formDTO.getSex()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getAvatarUrl()) && StringUtils.isBlank(baseInfo.getHeadImgUrl())) { |
|
|
|
baseInfo.setHeadImgUrl(formDTO.getAvatarUrl()); |
|
|
|
} |
|
|
|
baseDao.updateById(baseInfo); |
|
|
|
} |
|
|
|
result.setEpmetUserId(baseInfo.getId()); |
|
|
|
// 新增网格关系 先查询有没有网格关系
|
|
|
|
LambdaQueryWrapper<RegisterRelationEntity> registerWrapper = new LambdaQueryWrapper<>(); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getUserId, baseInfo.getUserId()); |
|
|
|
registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); |
|
|
|
RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); |
|
|
|
if (null == registerRelation){ |
|
|
|
registerRelation = new RegisterRelationEntity(); |
|
|
|
|
|
|
|
registerRelation.setCustomerId(formDTO.getCustomerId()); |
|
|
|
registerRelation.setGridId(formDTO.getGridId()); |
|
|
|
//表中新增字段 为其赋值
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getGridId()); |
|
|
|
if (null == gridInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格缓存失败", "获取网格缓存失败"); |
|
|
|
} |
|
|
|
registerRelation.setAgencyId(gridInfo.getPid()); |
|
|
|
registerRelation.setAgencyIdPath(gridInfo.getPids()); |
|
|
|
registerRelation.setUserId(baseInfo.getUserId()); |
|
|
|
//首次注册用户 (0表示不参与计数 1表示参与计数)
|
|
|
|
registerRelation.setFirstRegister(NumConstant.ONE_STR); |
|
|
|
//注册用户 (0表示不参与计数 1表示参与计数)
|
|
|
|
registerRelation.setRegister(NumConstant.ONE_STR); |
|
|
|
//参与用户 (0表示不参与计数 1表示参与计数)
|
|
|
|
registerRelation.setParticipation(NumConstant.ONE_STR); |
|
|
|
registerRelationDao.insert(registerRelation); |
|
|
|
}else{ |
|
|
|
// 如果已经存在的话就更新
|
|
|
|
registerRelation.setGridId(formDTO.getGridId()); |
|
|
|
registerRelationDao.updateById(registerRelation); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 先查询有没有用户居民端注册访问记录 新增用户居民端注册访问记录表
|
|
|
|
LambdaQueryWrapper<UserResiRegisterVisitEntity> resiRegisterVisitLW = new LambdaQueryWrapper<>(); |
|
|
|
resiRegisterVisitLW.eq(UserResiRegisterVisitEntity::getUserId,baseInfo.getUserId()); |
|
|
|
resiRegisterVisitLW.eq(UserResiRegisterVisitEntity::getCustomerId,baseInfo.getCustomerId()); |
|
|
|
UserResiRegisterVisitEntity visit = userResiRegisterVisitDao.selectOne(resiRegisterVisitLW); |
|
|
|
if (visit == null){ |
|
|
|
visit = new UserResiRegisterVisitEntity(); |
|
|
|
visit.setCustomerId(baseInfo.getCustomerId()); |
|
|
|
visit.setGridId(formDTO.getGridId()); |
|
|
|
visit.setUserId(baseInfo.getUserId()); |
|
|
|
visit.setVisitFrom("lantu"); |
|
|
|
visit.setLastOperateVisit("success"); |
|
|
|
visit.setVisitTime(new Date()); |
|
|
|
userResiRegisterVisitDao.insert(visit); |
|
|
|
}else{ |
|
|
|
visit.setGridId(formDTO.getGridId()); |
|
|
|
visit.setVisitFrom("lantu"); |
|
|
|
visit.setLastOperateVisit("success"); |
|
|
|
visit.setVisitTime(new Date()); |
|
|
|
userResiRegisterVisitDao.updateById(visit); |
|
|
|
} |
|
|
|
|
|
|
|
//新增该用户在该客户下的注册状态
|
|
|
|
LambdaQueryWrapper<UserCustomerEntity> userCustomerEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
userCustomerEntityLambdaQueryWrapper.eq(UserCustomerEntity::getCustomerId,baseInfo.getCustomerId()); |
|
|
|
userCustomerEntityLambdaQueryWrapper.eq(UserCustomerEntity::getUserId,baseInfo.getUserId()); |
|
|
|
UserCustomerEntity userCustomer = userCustomerDao.selectOne(userCustomerEntityLambdaQueryWrapper); |
|
|
|
if (userCustomer == null){ |
|
|
|
userCustomer = new UserCustomerEntity(); |
|
|
|
userCustomer.setCustomerId(baseInfo.getCustomerId()); |
|
|
|
userCustomer.setUserId(baseInfo.getUserId()); |
|
|
|
userCustomer.setIsRegister(NumConstant.ONE_STR); |
|
|
|
userCustomerDao.insert(userCustomer); |
|
|
|
}else{ |
|
|
|
userCustomer.setIsRegister(NumConstant.ONE_STR); |
|
|
|
userCustomerDao.updateById(userCustomer); |
|
|
|
} |
|
|
|
|
|
|
|
//2:角色表新增角色数据
|
|
|
|
LambdaQueryWrapper<UserRoleEntity> userRoleLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
userRoleLambdaQueryWrapper.eq(UserRoleEntity::getUserId,baseInfo.getUserId()); |
|
|
|
userRoleLambdaQueryWrapper.eq(UserRoleEntity::getCustomerId,baseInfo.getCustomerId()); |
|
|
|
UserRoleEntity userRoleEntity = userRoleDao.selectOne(userRoleLambdaQueryWrapper); |
|
|
|
if (userRoleEntity == null){ |
|
|
|
UserRoleDTO userRoleDTO = new UserRoleDTO(); |
|
|
|
userRoleDTO.setCustomerId(baseInfo.getCustomerId()); |
|
|
|
userRoleDTO.setUserId(baseInfo.getUserId()); |
|
|
|
userRoleDTO.setApp("resi"); |
|
|
|
userRoleDTO.setRoleKey(EpmetRoleKeyConstant.REGISTERED_RESI); |
|
|
|
//居民角色对应的网格Id存默认值-all
|
|
|
|
userRoleDTO.setGridId(UserRoleConstant.DEFAULT_GRID_ID); |
|
|
|
userRoleService.saveUserRole(userRoleDTO); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
distributedLock.unLock(lock); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户完善信息列表 |
|
|
|
* |
|
|
|