From 4406bf965a39cf9af71ed822abfce76f64be04f9 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期三, 16 七月 2025 18:17:24 +0800 Subject: [PATCH] 111 --- server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java | 67 ++++++++++++++++++++++++++++++--- 1 files changed, 60 insertions(+), 7 deletions(-) diff --git a/server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java index 8545329..34ae3da 100644 --- a/server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java +++ b/server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java @@ -6,6 +6,7 @@ import com.doumee.core.constants.Constants; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; +import com.doumee.core.model.LoginUserInfo; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Utils; @@ -13,6 +14,7 @@ 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.IdentityInfoService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -21,9 +23,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; import io.swagger.annotations.ApiModelProperty; +import nonapi.io.github.classgraph.json.Id; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.ArrayList; @@ -47,6 +52,7 @@ private SystemDictDataBiz systemDictDataBiz; @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) public Integer create(IdentityInfo identityInfo) { if(Objects.isNull(identityInfo) || Objects.isNull(identityInfo.getType()) @@ -66,13 +72,22 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST); } //鏌ヨ鐢ㄦ埛鏄惁宸插瓨鍦ㄥ綋鍓嶈韩浠� - if(identityInfoMapper.selectCount(new QueryWrapper<IdentityInfo>().lambda().eq(IdentityInfo::getMemberId,identityInfo.getMemberId()) + 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.setAuditStatus(Constants.ZERO); + 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(); } @@ -96,6 +111,7 @@ } @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) public void updateById(IdentityInfo identityInfo) { if(Objects.isNull(identityInfo) || Objects.isNull(identityInfo.getId()) @@ -126,11 +142,18 @@ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠鐘舵�佹棤娉曡繘琛岃鎿嶄綔"); } 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()) @@ -362,12 +385,42 @@ } - public void audit(){ + @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) + public void audit(AuditDTO auditDTO){ + if(Objects.isNull(auditDTO) + || Objects.isNull(auditDTO.getId()) + || Objects.isNull(auditDTO.getAuditStatus()) + || auditDTO.getAuditStatus()<2 + || auditDTO.getAuditStatus()>3){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + IdentityInfo identityInfo = identityInfoMapper.selectById(auditDTO.getId()); + if(Objects.isNull(identityInfo)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(!Constants.equalsInteger(identityInfo.getAuditStatus(),Constants.ONE)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"宸插鎵癸紝璇峰嬁閲嶅鎿嶄綔"); + } + Date date = new Date(); + identityInfoMapper.update(new UpdateWrapper<IdentityInfo>().lambda() + .set(IdentityInfo::getAuditStatus, auditDTO.getAuditStatus() ) + .set(StringUtils.isNotBlank(auditDTO.getAuditRemark()),IdentityInfo::getAuditRemark,auditDTO.getAuditRemark()) + .set(IdentityInfo::getAuditTime,date) + .set(IdentityInfo::getUpdateUser,user.getId()) + .set(IdentityInfo::getUpdateTime,date) + .eq(IdentityInfo::getId,identityInfo.getId()) + ); + memberMapper.update(new UpdateWrapper<Member>().lambda() + .set(Member::getUpdateUser,user.getId()) + .set(Member::getUpdateTime,date) + .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()) + ); } - - - - } -- Gitblit v1.9.3