|
|
|
@ -20,7 +20,9 @@ package com.elink.esua.epdc.service.impl; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
@ -28,27 +30,22 @@ import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.constant.UserFieldConsant; |
|
|
|
import com.elink.esua.epdc.dao.PartyMembersDao; |
|
|
|
import com.elink.esua.epdc.dao.UserDao; |
|
|
|
import com.elink.esua.epdc.dto.PartyMembersDTO; |
|
|
|
import com.elink.esua.epdc.dto.UserDTO; |
|
|
|
import com.elink.esua.epdc.dto.UserGridRelationDTO; |
|
|
|
import com.elink.esua.epdc.dto.UserTagRelationDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcCheckUserRegisterFromDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcGridLeaderRegisterFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegistFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegisterBindGridFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.*; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterAuditMsgResultDTO; |
|
|
|
import com.elink.esua.epdc.entity.PartyMembersEntity; |
|
|
|
import com.elink.esua.epdc.entity.UserEntity; |
|
|
|
import com.elink.esua.epdc.entity.UserGridRelationEntity; |
|
|
|
import com.elink.esua.epdc.enums.AppUserAuditStateEnum; |
|
|
|
import com.elink.esua.epdc.redis.UserRedis; |
|
|
|
import com.elink.esua.epdc.enums.AppUserStatesEnum; |
|
|
|
import com.elink.esua.epdc.service.PartyMembersService; |
|
|
|
import com.elink.esua.epdc.service.UserGridRelationService; |
|
|
|
import com.elink.esua.epdc.service.UserService; |
|
|
|
@ -73,10 +70,7 @@ import java.util.Map; |
|
|
|
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserRedis userRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PartyMembersService partyMembersService; |
|
|
|
private PartyMembersDao partyMembersDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserTagRelationService userTagRelationService; |
|
|
|
@ -84,59 +78,32 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserDTO> page(Map<String, Object> params) { |
|
|
|
IPage<UserEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
|
|
|
|
return getPageData(page, UserDTO.class); |
|
|
|
this.verifyParams(params); |
|
|
|
IPage<UserDTO> iPage = this.getPage(params); |
|
|
|
List<UserDTO> userDtoList = this.baseDao.selectListUserDto(params); |
|
|
|
return new PageData<>(userDtoList, iPage.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<UserDTO> list(Map<String, Object> params) { |
|
|
|
List<UserEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
return ConvertUtils.sourceToTarget(entityList, UserDTO.class); |
|
|
|
this.verifyParams(params); |
|
|
|
return this.baseDao.selectListUserDto(params); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<UserEntity> getWrapper(Map<String, Object> params) { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
//部门ID列表
|
|
|
|
List<Long> deptIdList = user.getDeptIdList(); |
|
|
|
String auditState = (String) params.get("auditState"); |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String streetId = (String) params.get(FieldConstant.STREET_ID_HUMP); |
|
|
|
String communityId = (String) params.get(FieldConstant.COMMUNITY_ID_HUMP); |
|
|
|
String gridId = (String) params.get(FieldConstant.GRID_ID_HUMP); |
|
|
|
String realName = (String) params.get("realName"); |
|
|
|
if (StringUtils.isNotBlank(realName)) { |
|
|
|
realName = realName.trim(); |
|
|
|
private Map<String, Object> verifyParams(Map<String, Object> params) { |
|
|
|
String param = (String) params.get("realName"); |
|
|
|
if (StringUtils.isNotBlank(param)) { |
|
|
|
params.put("realName", param.trim()); |
|
|
|
} |
|
|
|
String mobile = (String) params.get(FieldConstant.MOBILE_HUMP); |
|
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
|
mobile = mobile.trim(); |
|
|
|
param = (String) params.get(FieldConstant.MOBILE_HUMP); |
|
|
|
if (StringUtils.isNotBlank(param)) { |
|
|
|
params.put(FieldConstant.MOBILE_HUMP, param.trim()); |
|
|
|
} |
|
|
|
String identityNo = (String) params.get("identityNo"); |
|
|
|
if (StringUtils.isNotBlank(identityNo)) { |
|
|
|
identityNo = identityNo.trim(); |
|
|
|
param = (String) params.get("identityNo"); |
|
|
|
if (StringUtils.isNotBlank(param)) { |
|
|
|
params.put("identityNo", param.trim()); |
|
|
|
} |
|
|
|
String startTime = (String) params.get("startTime"); |
|
|
|
String endTime = (String) params.get("endTime"); |
|
|
|
String isParty = (String) params.get("isParty"); |
|
|
|
|
|
|
|
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(streetId), FieldConstant.STREET_ID, streetId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(communityId), FieldConstant.COMMUNITY_ID, communityId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId); |
|
|
|
wrapper.like(StringUtils.isNotBlank(realName), UserFieldConsant.REAL_NAME, realName); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(mobile), FieldConstant.MOBILE, mobile); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(identityNo), UserFieldConsant.IDENTITY_NO, identityNo); |
|
|
|
wrapper.ge(StringUtils.isNotBlank(startTime), UserFieldConsant.REGISTER_TIME, startTime); |
|
|
|
wrapper.lt(StringUtils.isNotBlank(endTime), UserFieldConsant.REGISTER_TIME, endTime); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(auditState), FieldConstant.STATE, auditState); |
|
|
|
wrapper.in(CollUtil.isNotEmpty(deptIdList), FieldConstant.GRID_ID, deptIdList); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(isParty), UserFieldConsant.PARTY_FLAG, isParty); |
|
|
|
return wrapper; |
|
|
|
return params; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -172,37 +139,18 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void audit(UserDTO dto) { |
|
|
|
//先删除以前审核未通过的那条数据
|
|
|
|
this.baseDao.deleteAuditFailureByOpenId(dto.getWxOpenId()); |
|
|
|
UserEntity entity = ConvertUtils.sourceToTarget(dto, UserEntity.class); |
|
|
|
//是否通过审核
|
|
|
|
if (AppUserAuditStateEnum.AUDIT_SUCCESS.value().equals(dto.getPass())) { |
|
|
|
entity.setState(AppUserAuditStateEnum.AUDIT_SUCCESS.value()); |
|
|
|
} else if (AppUserAuditStateEnum.AUDIT_FAILURE.value().equals(dto.getPass())) { |
|
|
|
entity.setState(AppUserAuditStateEnum.AUDIT_FAILURE.value()); |
|
|
|
} |
|
|
|
// createdTime作为提交注册时间,registerTime作为注册审核时间(即注册时间)
|
|
|
|
entity.setRegisterTime(new Date()); |
|
|
|
updateById(entity); |
|
|
|
//判断是否是党员
|
|
|
|
if (YesOrNoEnum.YES.value().equals(dto.getPartyFlag()) && YesOrNoEnum.YES.value().equals(dto.getPass())) { |
|
|
|
PartyMembersDTO partyMembersDTO = ConvertUtils.sourceToTarget(dto, PartyMembersDTO.class); |
|
|
|
partyMembersDTO.setStreetName(dto.getStreet()); |
|
|
|
partyMembersDTO.setCommunityName(dto.getCommunity()); |
|
|
|
partyMembersDTO.setRegistTime(dto.getRegisterTime()); |
|
|
|
partyMembersDTO.setGridName(dto.getGrid()); |
|
|
|
partyMembersDTO.setTagIds(dto.getTagIds()); |
|
|
|
partyMembersService.save(partyMembersDTO); |
|
|
|
} else { |
|
|
|
//不是党员的话 插入用户标签关系表
|
|
|
|
JSONArray jsonArray = JSON.parseArray(dto.getTagIds()); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
String tagId = jsonArray.getString(i); |
|
|
|
UserTagRelationDTO userTagRelationDTO = new UserTagRelationDTO(); |
|
|
|
userTagRelationDTO.setUserId(entity.getId()); |
|
|
|
userTagRelationDTO.setTagId(tagId); |
|
|
|
userTagRelationService.save(userTagRelationDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
/*JSONArray jsonArray = JSON.parseArray(dto.getTagIds()); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
String tagId = jsonArray.getString(i); |
|
|
|
UserTagRelationDTO userTagRelationDTO = new UserTagRelationDTO(); |
|
|
|
userTagRelationDTO.setUserId(entity.getId()); |
|
|
|
userTagRelationDTO.setTagId(tagId); |
|
|
|
userTagRelationService.save(userTagRelationDTO); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -284,8 +232,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
String mobile = formDto.getMobile(); |
|
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
|
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(FieldConstant.MOBILE, mobile) |
|
|
|
.ne(FieldConstant.STATE, AppUserAuditStateEnum.AUDIT_FAILURE.value()); |
|
|
|
wrapper.eq(FieldConstant.MOBILE, mobile); |
|
|
|
Integer count = this.baseDao.selectCount(wrapper); |
|
|
|
if (count > NumConstant.ZERO) { |
|
|
|
return new Result().error("手机号已被注册"); |
|
|
|
@ -296,8 +243,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
String identityNo = formDto.getIdentityNo(); |
|
|
|
if (StringUtils.isNotBlank(identityNo)) { |
|
|
|
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("IDENTITY_NO", identityNo) |
|
|
|
.ne(FieldConstant.STATE, AppUserAuditStateEnum.AUDIT_FAILURE.value()); |
|
|
|
wrapper.eq(UserFieldConsant.IDENTITY_NO, identityNo); |
|
|
|
Integer count = this.baseDao.selectCount(wrapper); |
|
|
|
if (count > NumConstant.ZERO) { |
|
|
|
return new Result().error("身份证号已被注册"); |
|
|
|
@ -329,6 +275,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
List<UserGridRelationDTO> userGridList = registerDto.getUserGridList(); |
|
|
|
for (UserGridRelationDTO dto : userGridList) { |
|
|
|
dto.setUserId(userId); |
|
|
|
dto.setLeaderFlag(YesOrNoEnum.YES.value()); |
|
|
|
} |
|
|
|
|
|
|
|
List<UserGridRelationEntity> userGridRelationEntityList = ConvertUtils.sourceToTarget(userGridList, UserGridRelationEntity.class); |
|
|
|
@ -373,7 +320,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
} |
|
|
|
} |
|
|
|
// 未注册
|
|
|
|
else { |
|
|
|
else { |
|
|
|
resultDto.setRegisterState(NumConstant.ZERO); |
|
|
|
} |
|
|
|
|
|
|
|
@ -407,4 +354,74 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem |
|
|
|
|
|
|
|
return new Result<EpdcUserRegisterInfoResultDTO>().ok(resultDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result verifyUserCompleteData(UserDTO userDto) { |
|
|
|
|
|
|
|
UserEntity userEntity = this.selectById(userDto.getId()); |
|
|
|
|
|
|
|
if (!userEntity.getMobile().equals(userDto.getMobile())) { |
|
|
|
return new Result().error("手机号与注册手机号不匹配"); |
|
|
|
} |
|
|
|
|
|
|
|
if (AppUserStatesEnum.STATE_COMPLETED_INFORMATION_PENDING_REVIEW.value().equals(userEntity.getState()) |
|
|
|
|| AppUserStatesEnum.STATE_INFORMATION_PASSED.value().equals(userEntity.getState())) { |
|
|
|
return new Result().error("用户信息已审核通过或正在审核中"); |
|
|
|
} |
|
|
|
|
|
|
|
if (YesOrNoEnum.YES.value().equals(userDto.getPartyFlag())) { |
|
|
|
QueryWrapper<PartyMembersEntity> partyWrapper = new QueryWrapper<>(); |
|
|
|
partyWrapper.eq(UserFieldConsant.IDENTITY_NO, userDto.getIdentityNo()) |
|
|
|
.eq(UserFieldConsant.REAL_NAME, userDto.getRealName()); |
|
|
|
Integer selectCount = this.partyMembersDao.selectCount(partyWrapper); |
|
|
|
if (selectCount != NumConstant.ONE) { |
|
|
|
return new Result().error("无法匹配党员信息"); |
|
|
|
} |
|
|
|
|
|
|
|
QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>(); |
|
|
|
userWrapper.eq(UserFieldConsant.IDENTITY_NO, userDto.getIdentityNo()) |
|
|
|
.ne(FieldConstant.ID, userDto.getId()); |
|
|
|
selectCount = this.baseDao.selectCount(userWrapper); |
|
|
|
if (selectCount > NumConstant.ZERO) { |
|
|
|
return new Result().error("身份证号已被注册"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result completeUserInfo(EpdcAppUserCompleteInfoFormDTO formDto) { |
|
|
|
|
|
|
|
UserDTO userDto = formDto.getUserDto(); |
|
|
|
|
|
|
|
UserGridRelationDTO userGridRelation = formDto.getUserGridRelation(); |
|
|
|
|
|
|
|
if (YesOrNoEnum.YES.value().equals(userDto.getPartyFlag())) { |
|
|
|
PartyMembersEntity partyMembersEntity = new PartyMembersEntity(); |
|
|
|
partyMembersEntity.setStreetId(userGridRelation.getStreetId()); |
|
|
|
partyMembersEntity.setStreetName(userGridRelation.getStreet()); |
|
|
|
partyMembersEntity.setCommunityId(userGridRelation.getCommunityId()); |
|
|
|
partyMembersEntity.setCommunityName(userGridRelation.getCommunity()); |
|
|
|
partyMembersEntity.setGridId(userGridRelation.getGridId()); |
|
|
|
partyMembersEntity.setGridName(userGridRelation.getGrid()); |
|
|
|
|
|
|
|
UpdateWrapper<PartyMembersEntity> partyUpdate = new UpdateWrapper<>(); |
|
|
|
partyUpdate.eq(UserFieldConsant.IDENTITY_NO, userDto.getIdentityNo()) |
|
|
|
.eq(UserFieldConsant.REAL_NAME, userDto.getRealName()); |
|
|
|
|
|
|
|
if (this.partyMembersDao.update(partyMembersEntity, partyUpdate) != NumConstant.ONE) { |
|
|
|
throw new RenException("保存党员信息异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UserEntity userEntity = ConvertUtils.sourceToTarget(userDto, UserEntity.class); |
|
|
|
boolean updateUser = this.updateById(userEntity); |
|
|
|
if (!updateUser) { |
|
|
|
throw new RenException("保存用户信息异常"); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
} |