소스 검색

资质认证逻辑修改

small 2 년 전
부모
커밋
464ec41cef

+ 5 - 0
sckw-auth/src/main/java/com/sckw/auth/model/vo/res/EntInfoResVo.java

@@ -34,6 +34,11 @@ public class EntInfoResVo {
      */
     private Date regTime;
 
+    /**
+     * 是否有效
+     */
+    private Boolean valid;
+
     /**
      * 机构信息
      */

+ 24 - 3
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -1,5 +1,6 @@
 package com.sckw.auth.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
 import com.sckw.auth.model.vo.req.LoginReqVo;
@@ -8,8 +9,10 @@ import com.sckw.auth.model.vo.res.DeptInfoResVo;
 import com.sckw.auth.model.vo.res.EntInfoResVo;
 import com.sckw.auth.model.vo.res.LoginResVo;
 import com.sckw.auth.util.AsyncFactory;
+import com.sckw.core.model.enums.ApprovalEnum;
 import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.model.EntCertificateInfo;
 import com.sckw.core.web.model.LoginEntInfo;
 import com.sckw.core.web.model.LoginUserInfo;
@@ -97,7 +100,25 @@ public class AuthServiceImpl implements IAuthService {
         /* 4、查资质*/
         List<EntCertificateResDto> entCertificateResDtoList = remoteUserService.queryCertificateByEntId(entId);
         entInfoResVo.setCertificateInfo(entCertificateResDtoList);
-        /*4、生成token,一些信息存redis*/
+
+        //企业资质有效性判断  1、当前资质没过期,且状态是已认证  2、只要有认证过一次就算有效  参数判断
+        String checkType = "2";
+        if (checkType.equals("1")) {
+            for (EntCertificateResDto entCertificateResDto : entCertificateResDtoList) {
+                Date expireTime = entCertificateResDto.getExpireTime();
+                entInfoResVo.setValid(DateUtil.compare(new Date(), expireTime) <= 0);
+            }
+        } else {
+            List<EntCheckTrackResDto> entCheckTrackResDtoList = remoteUserService.checkTrackByEntId(entId);
+            if (CollectionUtils.isEmpty(entCheckTrackResDtoList)) {
+                entInfoResVo.setValid(false);
+                afterProcessor(loginResVo);
+                return loginResVo;
+            }
+            entInfoResVo.setValid(entCheckTrackResDtoList.stream().anyMatch(item -> item.getStatus() == Global.YES));
+        }
+
+        /*5、生成token,一些信息存redis*/
         afterProcessor(loginResVo);
         return loginResVo;
     }
@@ -209,7 +230,7 @@ public class AuthServiceImpl implements IAuthService {
             loginEntInfo.setApproval(entInfo.getApproval());
             loginEntInfo.setRegTime(entInfo.getRegTime());
             loginEntInfo.setCertificateInfo(BeanUtils.copyToList(entInfo.getCertificateInfo(), EntCertificateInfo.class));
-
+            loginEntInfo.setValid(entInfo.getValid());
             RedissonUtils.putString(Global.REDIS_ENTERPRISE_PREFIX + entInfo.getId(), JSON.toJSONString(loginEntInfo), Global.PC_TOKEN_EXPIRE);
         }
 
@@ -234,7 +255,7 @@ public class AuthServiceImpl implements IAuthService {
                 loginUserInfo.setEntId(entInfo.getId());
                 List<DeptInfoResVo> deptInfo = entInfo.getDeptInfo();
                 if (!CollectionUtils.isEmpty(deptInfo)) {
-                    loginUserInfo.setDeptIds(String.join(",", deptInfo.stream().map(item-> String.valueOf(item.getId())).toList()));
+                    loginUserInfo.setDeptIds(String.join(",", deptInfo.stream().map(item -> String.valueOf(item.getId())).toList()));
                 }
             }
             RedissonUtils.putString(Global.getFullUserLoginKey(loginResVo.getSystemType(), loginResVo.getId(), loginResVo.getClientType()), JSON.toJSONString(loginUserInfo), Global.PC_TOKEN_EXPIRE);

+ 27 - 22
sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/LoginFilter.java

@@ -54,11 +54,11 @@ public class LoginFilter implements Filter {
 
 
     /**
-     * @desc:  1、不需要token的请求直接放行
-     *         2、取token,校验
-     *         3、token校验没问题,判断当前用户角色 平台管理员直接放行
-     *         4、校验菜单权限,管理员不用校验,普通用户需要
-     *         4、菜单权限没问题,校验企业资质是否过期
+     * @desc: 1、不需要token的请求直接放行
+     * 2、取token,校验
+     * 3、token校验没问题,判断当前用户角色 平台管理员直接放行
+     * 4、校验菜单权限,管理员不用校验,普通用户需要
+     * 4、菜单权限没问题,校验企业资质是否过期
      * @author: czh
      * @date: 2023/6/29
      */
@@ -122,6 +122,7 @@ public class LoginFilter implements Filter {
 
     /**
      * @param loginUserInfo 登录信息
+     *                      产品(孙平逸夫)要求,只要第一次审批通过了,之后资质过期、重新审批背驳回,也不影响权限,不控制
      * @desc: 企业校验
      * @author: czh
      * @date: 2023/6/29
@@ -138,26 +139,30 @@ public class LoginFilter implements Filter {
 
         //企业资料审批状态校验
         LoginEntInfo loginEntInfo = JSON.parseObject(enterpriseInfo, LoginEntInfo.class);
-        int approval = loginEntInfo.getApproval();
-        if (approval == ApprovalEnum.NO.getCode() || approval == ApprovalEnum.PROCESS.getCode() || approval == ApprovalEnum.PASS.getCode()) {
+        if (loginEntInfo.getValid()) {
             LoginUserHolder.remove();
             throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
         }
-
-        List<EntCertificateInfo> certificateInfoList = loginEntInfo.getCertificateInfo();
-        if (CollectionUtils.isEmpty(certificateInfoList)) {
-            LoginUserHolder.remove();
-            throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
-        }
-
-        //有效期检验
-        for (EntCertificateInfo entCertificateInfo : certificateInfoList){
-            Date expireTime = entCertificateInfo.getExpireTime();
-            if (DateUtil.compare(new Date(), expireTime) > 0) {
-                LoginUserHolder.remove();
-                throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
-            }
-        }
+//        int approval = loginEntInfo.getApproval();
+//        if (approval == ApprovalEnum.NO.getCode() || approval == ApprovalEnum.PROCESS.getCode() || approval == ApprovalEnum.PASS.getCode()) {
+//            LoginUserHolder.remove();
+//            throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
+//        }
+//
+//        List<EntCertificateInfo> certificateInfoList = loginEntInfo.getCertificateInfo();
+//        if (CollectionUtils.isEmpty(certificateInfoList)) {
+//            LoginUserHolder.remove();
+//            throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
+//        }
+//
+//        //有效期检验
+//        for (EntCertificateInfo entCertificateInfo : certificateInfoList){
+//            Date expireTime = entCertificateInfo.getExpireTime();
+//            if (DateUtil.compare(new Date(), expireTime) > 0) {
+//                LoginUserHolder.remove();
+//                throw new SystemException(HttpStatus.AUTHORITY_NO_CODE, HttpStatus.ACCESS_FIAL);
+//            }
+//        }
     }
 
     /**

+ 5 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/model/LoginEntInfo.java

@@ -51,6 +51,11 @@ public class LoginEntInfo {
      */
     private Date regTime;
 
+    /**
+     * 是否有效
+     */
+    private Boolean valid;
+
     /**
      * 资质
      */

+ 10 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteUserService.java

@@ -118,4 +118,14 @@ public interface RemoteUserService {
      * @date: 2023/6/29
      */
     List<EntCertificateResDto> queryCertificateByEntId(Long entId);
+
+    /**
+     * @param entId 企业id
+     * @return EntCheckTrackResDto
+     * @desc: 查企业审批记录
+     * @author: czh
+     * @date: 2023/6/29
+     */
+    List<EntCheckTrackResDto> checkTrackByEntId(Long entId);
+
 }

+ 0 - 12
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/feign/RemoteUserFService.java

@@ -1,12 +0,0 @@
-package com.sckw.system.api.feign;
-
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@FeignClient(name = "sckw-system-czh")
-public interface RemoteUserFService {
-
-    @GetMapping(value = "/get")
-    public String getUserInfo(@RequestParam("account") String account);
-}

+ 1 - 1
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/EntCertificateResDto.java

@@ -30,7 +30,7 @@ public class EntCertificateResDto implements Serializable {
     /**
      * 状态:0正常/1锁定
      */
-    private Integer status=0;
+    private Integer status;
 
     /**
      * 创建人

+ 60 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/EntCheckTrackResDto.java

@@ -0,0 +1,60 @@
+package com.sckw.system.api.model.dto.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class EntCheckTrackResDto implements Serializable {
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态:0正常/1锁定
+     */
+    private Integer status = 0;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 删除标识(0正常/-1删除)
+     */
+    private Integer delFlag = 0;
+
+}

+ 0 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/SystemApplication.java

@@ -1,7 +1,6 @@
 package com.sckw.system;
 
 import com.sckw.remote.annotation.SckwRemoteApplication;
-import com.sckw.startup.annotation.SckwCloudApplication;
 import org.springframework.boot.SpringApplication;
 
 /**
@@ -10,7 +9,6 @@ import org.springframework.boot.SpringApplication;
  * @date: 22023-05-26 11:46
  */
 @SckwRemoteApplication
-@SckwCloudApplication
 public class SystemApplication {
 
     public static void main(String[] args) {

+ 9 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteUserServiceImpl.java

@@ -22,7 +22,6 @@ import jakarta.annotation.Resource;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
@@ -148,6 +147,15 @@ public class RemoteUserServiceImpl implements RemoteUserService {
         return BeanUtils.copyToList(certificate, EntCertificateResDto.class);
     }
 
+    @Override
+    public List<EntCheckTrackResDto> checkTrackByEntId(Long entId) {
+        List<KwsEntCheckTrack> kwsEntCheckTracks = kwsEnterpriseService.entCheck(entId);
+        if (CollectionUtils.isEmpty(kwsEntCheckTracks)) {
+            return Collections.emptyList();
+        }
+        return BeanUtils.copyToList(kwsEntCheckTracks, EntCheckTrackResDto.class);
+    }
+
     @Override
     public void register(RegisterReqDto reqDto) throws SystemException {
         kwsUserService.register(reqDto);

+ 5 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -355,9 +355,8 @@ public class KwsEnterpriseService {
             if (Objects.isNull(kwsEntCertificate)) {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
             }
-            kwsEntCertificate.setStatus(ApprovalEnum.OK.getCode() == status ? Global.NO : Global.YES);
-            kwsEntCertificateDao.update(kwsEntCertificate);
 
+            //先把旧的作废
             List<KwsEntCertificate> previous = kwsEntCertificateDao.findByEntType(kwsEntCertificate.getEntId(), kwsEntCertificate.getType());
             previous = previous.stream().filter(item -> item.getId() != Long.parseLong(id)).toList();
             if (!CollectionUtils.isEmpty(previous)) {
@@ -367,6 +366,10 @@ public class KwsEnterpriseService {
                 }
             }
 
+
+            kwsEntCertificate.setStatus(ApprovalEnum.OK.getCode() == status ? Global.NO : Global.YES);
+            kwsEntCertificateDao.update(kwsEntCertificate);
+
             entId = kwsEntCertificate.getEntId();
             kwsEntCertificates.add(kwsEntCertificate);
         }

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -131,7 +131,7 @@ public class KwsUserService {
             Integer systemType = SystemTypeEnum.COMPANY.getCode();
             long deptId = new IdWorker(1L).nextId();
             kwsDept.setEntId(entId);
-            kwsDept.setName(Global.MANAGE_DEPT_NAME);
+            kwsDept.setName(reqDto.getEntName());
             kwsDept.setSystemType(systemType);
             kwsDept.setCompany(Global.NO);
             kwsDept.setId(deptId);

+ 2 - 2
sckw-modules/sckw-system/src/main/resources/mapper/KwsEntCertificateDao.xml

@@ -31,11 +31,11 @@
   </select>
 
   <select id="selectByEntId" resultType="com.sckw.system.model.KwsEntCertificate">
-    select a.* from kws_ent_certificate a where a.ent_id = #{id} and a.del_flag = 0
+    select a.* from kws_ent_certificate a where a.ent_id = #{id} and a.del_flag = 0 and a.status = 0
   </select>
 
   <select id="findByEntType" resultType="com.sckw.system.model.KwsEntCertificate">
-    select a.* from kws_ent_certificate a where a.ent_id = #{id} and a.type = #{type} and a.del_flag = 0
+    select a.* from kws_ent_certificate a where a.ent_id = #{id} and a.type = #{type} and a.del_flag = 0 and a.status = 0
   </select>
 
   <insert id="insert" parameterType="com.sckw.system.model.KwsEntCertificate">