|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.config.wx.SendWxMessage; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelColumn; | 
|---|
|  |  |  | import com.doumee.core.constants.Constants; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.CategoryMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.IdentityInfoMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.IdentityInfo; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.dto.AuditDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.AliSmsService; | 
|---|
|  |  |  | 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.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import io.swagger.annotations.ApiModelProperty; | 
|---|
|  |  |  | import me.chanjar.weixin.common.error.WxErrorException; | 
|---|
|  |  |  | import nonapi.io.github.classgraph.json.Id; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AliSmsService aliSmsService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategoryMapper categoryMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public Integer create(IdentityInfo identityInfo) { | 
|---|
|  |  |  | if(Objects.isNull(identityInfo) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getType()) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getMemberId()) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getAuthType()) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getType()) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getMemberId()) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getAuthType()) | 
|---|
|  |  |  | || StringUtils.isEmpty(identityInfo.getLinkName()) | 
|---|
|  |  |  | || StringUtils.isEmpty(identityInfo.getTelephone()) | 
|---|
|  |  |  | || StringUtils.isEmpty(identityInfo.getLocation()) | 
|---|
|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | IdentityInfo model = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,identityInfo.getMemberId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,identityInfo.getType()) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(model)){ | 
|---|
|  |  |  | identityInfo.setId(model.getId()); | 
|---|
|  |  |  | this.updateById(identityInfo); | 
|---|
|  |  |  | return identityInfo.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询用户是否已存在当前身份 | 
|---|
|  |  |  | if(identityInfoMapper.selectCount(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getDeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,identityInfo.getMemberId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,identityInfo.getType()))>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已存在该身份请刷新查看!"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | identityInfo.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | identityInfo.setCreateTime(new Date()); | 
|---|
|  |  |  | identityInfo.setUpdateTime(identityInfo.getCreateTime()); | 
|---|
|  |  |  | identityInfo.setAuditStatus(Constants.ONE); | 
|---|
|  |  |  | identityInfoMapper.insert(identityInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ZERO),Member::getWorkerIdentity,Constants.ONE) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ONE),Member::getDriverIdentity,Constants.ONE) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.TWO),Member::getChefIdentity,Constants.ONE) | 
|---|
|  |  |  | .eq(Member::getId,identityInfo.getMemberId())); | 
|---|
|  |  |  | return identityInfo.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void updateById(IdentityInfo identityInfo) { | 
|---|
|  |  |  | if(Objects.isNull(identityInfo) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getAuditStatus(),Constants.THREE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | identityInfo.setAuditRemark(""); | 
|---|
|  |  |  | identityInfo.setUpdateTime(new Date()); | 
|---|
|  |  |  | identityInfo.setAuditStatus(Constants.ONE); | 
|---|
|  |  |  | identityInfoMapper.updateById(identityInfo); | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ZERO),Member::getWorkerIdentity,Constants.ONE) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ONE),Member::getDriverIdentity,Constants.ONE) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.TWO),Member::getChefIdentity,Constants.ONE) | 
|---|
|  |  |  | .eq(Member::getId,identityInfo.getMemberId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void updateLocation(IdentityInfo identityInfo) { | 
|---|
|  |  |  | if(Objects.isNull(identityInfo) | 
|---|
|  |  |  | || Objects.isNull(identityInfo.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IdentityInfo findById(Integer id) { | 
|---|
|  |  |  | IdentityInfo identityInfo = identityInfoMapper.selectById(id); | 
|---|
|  |  |  | //缺失前缀 | 
|---|
|  |  |  | identityInfo.setPrefix(""); | 
|---|
|  |  |  | return identityInfo; | 
|---|
|  |  |  | IdentityInfo model = identityInfoMapper.selectById(id); | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.INENTITY_FILES).getCode(); | 
|---|
|  |  |  | model.setImgList(new ArrayList<>()); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg1())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg1()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg2())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg2()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg3())) { | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg3()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg4())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg4()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IdentityInfo findByMemberType(Integer type,Integer memberId){ | 
|---|
|  |  |  | IdentityInfo identityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | IdentityInfo model = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,memberId).eq(IdentityInfo::getType,type)); | 
|---|
|  |  |  | if(Objects.nonNull(identityInfo)){ | 
|---|
|  |  |  | //缺失前缀 | 
|---|
|  |  |  | identityInfo.setPrefix(""); | 
|---|
|  |  |  | if(Objects.nonNull(model)){ | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.INENTITY_FILES).getCode(); | 
|---|
|  |  |  | model.setImgList(new ArrayList<>()); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg1())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg1()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg2())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg2()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg3())) { | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg3()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getImg4())){ | 
|---|
|  |  |  | model.getImgList().add(path + model.getImg4()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | identityInfo = new IdentityInfo(); | 
|---|
|  |  |  | model = new IdentityInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return identityInfo; | 
|---|
|  |  |  | return model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SendWxMessage sendWxMessage; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void audit(AuditDTO auditDTO){ | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(identityInfo.getAuditStatus(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已审批,请勿重复操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Member member = memberMapper.selectById(identityInfo.getMemberId()); | 
|---|
|  |  |  | if(Objects.isNull(member)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | identityInfo.setAuditStatus(auditDTO.getAuditStatus()); | 
|---|
|  |  |  | identityInfo.setAuditRemark(auditDTO.getAuditRemark()); | 
|---|
|  |  |  | identityInfo.setAuditTime(new Date()); | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | identityInfoMapper.update(new UpdateWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .set(IdentityInfo::getAuditStatus, auditDTO.getAuditStatus() ) | 
|---|
|  |  |  | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Member::getUpdateUser,user.getId()) | 
|---|
|  |  |  | .set(Member::getUpdateTime,date) | 
|---|
|  |  |  | .set(Constants.equalsInteger(auditDTO.getAuditStatus(),Constants.ZERO),Member::getAutoReceiveStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ZERO),Member::getWorkerIdentity, auditDTO.getAuditStatus() ) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.ONE),Member::getDriverIdentity , auditDTO.getAuditStatus() ) | 
|---|
|  |  |  | .set(Constants.equalsInteger(identityInfo.getType(),Constants.TWO),Member::getChefIdentity , auditDTO.getAuditStatus() ) | 
|---|
|  |  |  | .eq(Member::getId,identityInfo.getMemberId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //发送微信通知 | 
|---|
|  |  |  | if(StringUtils.isNotBlank(member.getOpenid())){ | 
|---|
|  |  |  | sendWxMessage.identityInfoMessage(member.getOpenid(),identityInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //短信通知 | 
|---|
|  |  |  | aliSmsService.businessSendSms(Constants.smsContent.authentication.getKey(), | 
|---|
|  |  |  | member.getTelephone(),null,null, | 
|---|
|  |  |  | identityInfo,categoryMapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|