From a223d5e29e9384f720ae98c44cbe10f8fa4f73e7 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 21 八月 2025 13:42:16 +0800
Subject: [PATCH] 优化
---
server/services/src/main/java/com/doumee/service/business/impl/IdentityInfoServiceImpl.java | 160 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 113 insertions(+), 47 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 0961efe..fb5d5b4 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
@@ -2,6 +2,7 @@
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;
@@ -23,6 +24,7 @@
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;
@@ -52,11 +54,12 @@
private SystemDictDataBiz systemDictDataBiz;
@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())
@@ -70,14 +73,28 @@
){
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);
+ if(Objects.nonNull(identityInfo.getId())){
+ this.updateById(identityInfo);
+ }else{
+ //鏌ヨ鐢ㄦ埛鏄惁宸插瓨鍦ㄥ綋鍓嶈韩浠�
+ 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();
}
@@ -101,6 +118,7 @@
}
@Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
public void updateById(IdentityInfo identityInfo) {
if(Objects.isNull(identityInfo)
|| Objects.isNull(identityInfo.getId())
@@ -131,11 +149,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())
@@ -175,24 +200,50 @@
@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;
}
@@ -286,7 +337,7 @@
queryWrapper.le(IdentityInfo::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime()));
}
if (pageWrap.getModel().getRemark() != null) {
- queryWrapper.eq(IdentityInfo::getRemark, pageWrap.getModel().getRemark());
+ queryWrapper.like(IdentityInfo::getRemark, pageWrap.getModel().getRemark());
}
if (pageWrap.getModel().getType() != null) {
queryWrapper.eq(IdentityInfo::getType, pageWrap.getModel().getType());
@@ -298,16 +349,16 @@
queryWrapper.eq(IdentityInfo::getAuthType, pageWrap.getModel().getAuthType());
}
if (pageWrap.getModel().getLinkName() != null) {
- queryWrapper.eq(IdentityInfo::getLinkName, pageWrap.getModel().getLinkName());
+ queryWrapper.like(IdentityInfo::getLinkName, pageWrap.getModel().getLinkName());
}
if (pageWrap.getModel().getTelephone() != null) {
- queryWrapper.eq(IdentityInfo::getTelephone, pageWrap.getModel().getTelephone());
+ queryWrapper.like(IdentityInfo::getTelephone, pageWrap.getModel().getTelephone());
}
if (pageWrap.getModel().getLocation() != null) {
- queryWrapper.eq(IdentityInfo::getLocation, pageWrap.getModel().getLocation());
+ queryWrapper.like(IdentityInfo::getLocation, pageWrap.getModel().getLocation());
}
if (pageWrap.getModel().getCompanyName() != null) {
- queryWrapper.eq(IdentityInfo::getCompanyName, pageWrap.getModel().getCompanyName());
+ queryWrapper.like(IdentityInfo::getCompanyName, pageWrap.getModel().getCompanyName());
}
if (pageWrap.getModel().getLat() != null) {
queryWrapper.eq(IdentityInfo::getLat, pageWrap.getModel().getLat());
@@ -323,15 +374,10 @@
queryWrapper.le(IdentityInfo::getAuditTime, Utils.Date.getEnd(pageWrap.getModel().getAuditTime()));
}
if (pageWrap.getModel().getAuditRemark() != null) {
- queryWrapper.eq(IdentityInfo::getAuditRemark, pageWrap.getModel().getAuditRemark());
+ queryWrapper.like(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());
- }
- }
+ queryWrapper.orderByAsc(IdentityInfo::getAuditStatus );
+ queryWrapper.orderByDesc(IdentityInfo::getCreateTime );
PageData<IdentityInfo> result = PageData.from(identityInfoMapper.selectJoinPage(page,IdentityInfo.class, queryWrapper));
if(result!=null && result.getRecords()!=null){
String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode()
@@ -372,12 +418,17 @@
}
+ @Autowired
+ private SendWxMessage sendWxMessage;
+
@Override
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
public void audit(AuditDTO auditDTO){
if(Objects.isNull(auditDTO)
- || Objects.isNull(auditDTO.getId())
- || Objects.isNull(auditDTO.getAuditStatus())){
+ || 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();
@@ -388,27 +439,42 @@
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,Constants.equalsInteger(auditDTO.getAuditStatus(),Constants.ZERO)?Constants.TWO:Constants.THREE)
+ .set(IdentityInfo::getAuditStatus, auditDTO.getAuditStatus() )
.set(StringUtils.isNotBlank(auditDTO.getAuditRemark()),IdentityInfo::getAuditRemark,auditDTO.getAuditRemark())
- .set(IdentityInfo::getAuditTime,"now()")
+ .set(IdentityInfo::getAuditTime,date)
.set(IdentityInfo::getUpdateUser,user.getId())
- .set(IdentityInfo::getUpdateTime,"now()")
+ .set(IdentityInfo::getUpdateTime,date)
.eq(IdentityInfo::getId,identityInfo.getId())
);
memberMapper.update(new UpdateWrapper<Member>().lambda()
.set(Member::getUpdateUser,user.getId())
- .set(Member::getUpdateTime,"now()")
- .set(Constants.equalsInteger(identityInfo.getType(),Constants.ZERO),Member::getWorkerIdentity,Constants.equalsInteger(auditDTO.getAuditStatus(),Constants.ZERO)?Constants.TWO:Constants.THREE)
- .set(Constants.equalsInteger(identityInfo.getType(),Constants.ONE),Member::getDriverIdentity,Constants.equalsInteger(auditDTO.getAuditStatus(),Constants.ZERO)?Constants.TWO:Constants.THREE)
- .set(Constants.equalsInteger(identityInfo.getType(),Constants.TWO),Member::getChefIdentity,Constants.equalsInteger(auditDTO.getAuditStatus(),Constants.ZERO)?Constants.TWO:Constants.THREE)
+ .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())
);
+ try{
+ //鍙戦�佸井淇¢�氱煡
+ if(StringUtils.isNotBlank(member.getOpenid())){
+ sendWxMessage.identityInfoMessage(member.getOpenid(),identityInfo);
+ }
+ }catch (WxErrorException wxErrorException){
+
+ }
+
+
+
}
-
-
-
-
}
--
Gitblit v1.9.3