package com.doumee.service.business.impl;
|
|
import com.doumee.core.constants.Constants;
|
import com.doumee.core.constants.ResponseStatus;
|
import com.doumee.core.exception.BusinessException;
|
import com.doumee.core.model.PageData;
|
import com.doumee.core.model.PageWrap;
|
import com.doumee.core.utils.Utils;
|
import com.doumee.dao.business.IdentityInfoMapper;
|
import com.doumee.dao.business.model.IdentityInfo;
|
import com.doumee.service.business.IdentityInfoService;
|
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.StringUtils;
|
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 会员身份认证信息表Service实现
|
* @author 江蹄蹄
|
* @date 2025/07/09 12:00
|
*/
|
@Service
|
public class IdentityInfoServiceImpl implements IdentityInfoService {
|
|
@Autowired
|
private IdentityInfoMapper identityInfoMapper;
|
|
@Override
|
public Integer create(IdentityInfo identityInfo) {
|
if(Objects.isNull(identityInfo)
|
|| Objects.isNull(identityInfo.getType())
|
|| Objects.isNull(identityInfo.getMemberId())
|
|| Objects.isNull(identityInfo.getAuthType())
|
|| StringUtils.isEmpty(identityInfo.getLinkName())
|
|| StringUtils.isEmpty(identityInfo.getTelephone())
|
|| StringUtils.isEmpty(identityInfo.getLocation())
|
|| StringUtils.isEmpty(identityInfo.getImg1())
|
|| Objects.isNull(identityInfo.getLat())
|
|| Objects.isNull(identityInfo.getLgt())
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && StringUtils.isEmpty(identityInfo.getCompanyName()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ZERO) && StringUtils.isEmpty(identityInfo.getImg2()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && Constants.equalsInteger(identityInfo.getType(),Constants.ONE) && StringUtils.isEmpty(identityInfo.getImg2()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && Constants.equalsInteger(identityInfo.getType(),Constants.TWO) && (StringUtils.isEmpty(identityInfo.getImg2())||StringUtils.isEmpty(identityInfo.getImg3())))
|
){
|
throw new BusinessException(ResponseStatus.BAD_REQUEST);
|
}
|
//查询用户是否已存在当前身份
|
if(identityInfoMapper.selectCount(new QueryWrapper<IdentityInfo>().lambda().eq(IdentityInfo::getMemberId,identityInfo.getMemberId())
|
.eq(IdentityInfo::getType,identityInfo.getType()))>Constants.ZERO){
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已存在该身份请刷新查看!");
|
};
|
identityInfo.setCreateTime(new Date());
|
identityInfo.setAuditStatus(Constants.ZERO);
|
identityInfoMapper.insert(identityInfo);
|
return identityInfo.getId();
|
}
|
|
@Override
|
public void deleteById(Integer id) {
|
identityInfoMapper.deleteById(id);
|
}
|
|
@Override
|
public void delete(IdentityInfo identityInfo) {
|
UpdateWrapper<IdentityInfo> deleteWrapper = new UpdateWrapper<>(identityInfo);
|
identityInfoMapper.delete(deleteWrapper);
|
}
|
|
@Override
|
public void deleteByIdInBatch(List<Integer> ids) {
|
if (CollectionUtils.isEmpty(ids)) {
|
return;
|
}
|
identityInfoMapper.deleteBatchIds(ids);
|
}
|
|
@Override
|
public void updateById(IdentityInfo identityInfo) {
|
if(Objects.isNull(identityInfo)
|
|| Objects.isNull(identityInfo.getId())
|
|| Objects.isNull(identityInfo.getType())
|
|| Objects.isNull(identityInfo.getMemberId())
|
|| Objects.isNull(identityInfo.getAuthType())
|
|| StringUtils.isEmpty(identityInfo.getLinkName())
|
|| StringUtils.isEmpty(identityInfo.getTelephone())
|
|| StringUtils.isEmpty(identityInfo.getLocation())
|
|| StringUtils.isEmpty(identityInfo.getImg1())
|
|| Objects.isNull(identityInfo.getLat())
|
|| Objects.isNull(identityInfo.getLgt())
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && StringUtils.isEmpty(identityInfo.getCompanyName()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ZERO) && StringUtils.isEmpty(identityInfo.getImg2()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && Constants.equalsInteger(identityInfo.getType(),Constants.ONE) && StringUtils.isEmpty(identityInfo.getImg2()))
|
|| (Constants.equalsInteger(identityInfo.getAuthType(),Constants.ONE) && Constants.equalsInteger(identityInfo.getType(),Constants.TWO) && (StringUtils.isEmpty(identityInfo.getImg2())||StringUtils.isEmpty(identityInfo.getImg3())))
|
){
|
throw new BusinessException(ResponseStatus.BAD_REQUEST);
|
}
|
IdentityInfo model = identityInfoMapper.selectById(identityInfo.getId());
|
if (Objects.isNull(model)){
|
throw new BusinessException(ResponseStatus.DATA_EMPTY);
|
}
|
if(!Constants.equalsInteger(model.getMemberId(),identityInfo.getMemberId())){
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的数据无法进行该操作");
|
}
|
if(!Constants.equalsInteger(model.getAuditStatus(),Constants.THREE)){
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作");
|
}
|
identityInfo.setUpdateTime(new Date());
|
identityInfoMapper.updateById(identityInfo);
|
}
|
|
|
@Override
|
public void updateLocation(IdentityInfo identityInfo) {
|
if(Objects.isNull(identityInfo)
|
|| Objects.isNull(identityInfo.getId())
|
|| Objects.isNull(identityInfo.getMemberId())
|
|| StringUtils.isEmpty(identityInfo.getLocation())
|
|| Objects.isNull(identityInfo.getLat())
|
|| Objects.isNull(identityInfo.getLgt())
|
){
|
throw new BusinessException(ResponseStatus.BAD_REQUEST);
|
}
|
IdentityInfo model = identityInfoMapper.selectById(identityInfo.getId());
|
if (Objects.isNull(model)){
|
throw new BusinessException(ResponseStatus.DATA_EMPTY);
|
}
|
if(!Constants.equalsInteger(model.getMemberId(),identityInfo.getMemberId())){
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的数据无法进行该操作");
|
}
|
if(!Constants.equalsInteger(model.getAuditStatus(),Constants.TWO)){
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作");
|
}
|
model.setLocation(identityInfo.getLocation());
|
model.setLat(identityInfo.getLat());
|
model.setLgt(identityInfo.getLgt());
|
model.setUpdateTime(new Date());
|
identityInfoMapper.updateById(model);
|
}
|
|
@Override
|
public void updateByIdInBatch(List<IdentityInfo> identityInfos) {
|
if (CollectionUtils.isEmpty(identityInfos)) {
|
return;
|
}
|
for (IdentityInfo identityInfo: identityInfos) {
|
this.updateById(identityInfo);
|
}
|
}
|
|
@Override
|
public IdentityInfo findById(Integer id) {
|
IdentityInfo identityInfo = identityInfoMapper.selectById(id);
|
//缺失前缀
|
identityInfo.setPrefix("");
|
return identityInfo;
|
}
|
|
|
@Override
|
public IdentityInfo findByMemberType(Integer type,Integer memberId){
|
IdentityInfo identityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda()
|
.eq(IdentityInfo::getMemberId,memberId).eq(IdentityInfo::getType,type));
|
if(Objects.nonNull(identityInfo)){
|
//缺失前缀
|
identityInfo.setPrefix("");
|
}else{
|
identityInfo = new IdentityInfo();
|
}
|
return identityInfo;
|
}
|
|
|
|
@Override
|
public IdentityInfo findOne(IdentityInfo identityInfo) {
|
QueryWrapper<IdentityInfo> wrapper = new QueryWrapper<>(identityInfo);
|
return identityInfoMapper.selectOne(wrapper);
|
}
|
|
@Override
|
public List<IdentityInfo> findList(IdentityInfo identityInfo) {
|
QueryWrapper<IdentityInfo> wrapper = new QueryWrapper<>(identityInfo);
|
return identityInfoMapper.selectList(wrapper);
|
}
|
|
@Override
|
public PageData<IdentityInfo> findPage(PageWrap<IdentityInfo> pageWrap) {
|
IPage<IdentityInfo> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
|
QueryWrapper<IdentityInfo> queryWrapper = new QueryWrapper<>();
|
Utils.MP.blankToNull(pageWrap.getModel());
|
if (pageWrap.getModel().getId() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getId, pageWrap.getModel().getId());
|
}
|
if (pageWrap.getModel().getDeleted() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getDeleted, pageWrap.getModel().getDeleted());
|
}
|
if (pageWrap.getModel().getCreateUser() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getCreateUser, pageWrap.getModel().getCreateUser());
|
}
|
if (pageWrap.getModel().getCreateTime() != null) {
|
queryWrapper.lambda().ge(IdentityInfo::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime()));
|
queryWrapper.lambda().le(IdentityInfo::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime()));
|
}
|
if (pageWrap.getModel().getUpdateUser() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getUpdateUser, pageWrap.getModel().getUpdateUser());
|
}
|
if (pageWrap.getModel().getUpdateTime() != null) {
|
queryWrapper.lambda().ge(IdentityInfo::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime()));
|
queryWrapper.lambda().le(IdentityInfo::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime()));
|
}
|
if (pageWrap.getModel().getRemark() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getRemark, pageWrap.getModel().getRemark());
|
}
|
if (pageWrap.getModel().getType() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getType, pageWrap.getModel().getType());
|
}
|
if (pageWrap.getModel().getMemberId() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getMemberId, pageWrap.getModel().getMemberId());
|
}
|
if (pageWrap.getModel().getAuthType() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getAuthType, pageWrap.getModel().getAuthType());
|
}
|
if (pageWrap.getModel().getLinkName() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getLinkName, pageWrap.getModel().getLinkName());
|
}
|
if (pageWrap.getModel().getTelephone() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getTelephone, pageWrap.getModel().getTelephone());
|
}
|
if (pageWrap.getModel().getLocation() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getLocation, pageWrap.getModel().getLocation());
|
}
|
if (pageWrap.getModel().getCompanyName() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getCompanyName, pageWrap.getModel().getCompanyName());
|
}
|
if (pageWrap.getModel().getLat() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getLat, pageWrap.getModel().getLat());
|
}
|
if (pageWrap.getModel().getLgt() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getLgt, pageWrap.getModel().getLgt());
|
}
|
if (pageWrap.getModel().getAuditStatus() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getAuditStatus, pageWrap.getModel().getAuditStatus());
|
}
|
if (pageWrap.getModel().getAuditTime() != null) {
|
queryWrapper.lambda().ge(IdentityInfo::getAuditTime, Utils.Date.getStart(pageWrap.getModel().getAuditTime()));
|
queryWrapper.lambda().le(IdentityInfo::getAuditTime, Utils.Date.getEnd(pageWrap.getModel().getAuditTime()));
|
}
|
if (pageWrap.getModel().getAuditRemark() != null) {
|
queryWrapper.lambda().eq(IdentityInfo::getAuditRemark, pageWrap.getModel().getAuditRemark());
|
}
|
for(PageWrap.SortData sortData: pageWrap.getSorts()) {
|
if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
|
queryWrapper.orderByDesc(sortData.getProperty());
|
} else {
|
queryWrapper.orderByAsc(sortData.getProperty());
|
}
|
}
|
return PageData.from(identityInfoMapper.selectPage(page, queryWrapper));
|
}
|
|
@Override
|
public long count(IdentityInfo identityInfo) {
|
QueryWrapper<IdentityInfo> wrapper = new QueryWrapper<>(identityInfo);
|
return identityInfoMapper.selectCount(wrapper);
|
}
|
}
|