yonge 3 years ago
parent
commit
2961903b06

+ 1 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/ContractService.java

@@ -2,10 +2,8 @@ package com.ym.mec.biz.service;
 
 import java.math.BigDecimal;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
-import com.ym.mec.biz.dal.dto.CirculationUser;
 import com.ym.mec.biz.dal.dto.OAFinancialDto;
 import com.ym.mec.biz.dal.entity.SysUserTsign;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
@@ -25,7 +23,7 @@ public interface ContractService {
 	SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo);
 
     void addTsign(Integer userId,String organCode, String orgName,Integer tenantId);
-
+    
 	/**
 	 * 传递注册协议至第三方公证平台
 	 * @param userId

+ 37 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -191,25 +191,47 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
      * 校验企业营业信息,不存在则添加一个
      */
     @Override
-    public void addTsign(Integer userId, String organCode, String orgName, Integer tenantId) {
-        Optional.ofNullable(organCode).orElseThrow(() -> new BizException("营业执照编号不能为空!"));
-        Optional.ofNullable(orgName).orElseThrow(() -> new BizException("营业名称不能为空"));
+	public void addTsign(Integer userId, String organCode, String orgName, Integer tenantId) {
+		Optional.ofNullable(organCode).orElseThrow(() -> new BizException("营业执照编号不能为空!"));
+		Optional.ofNullable(orgName).orElseThrow(() -> new BizException("营业名称不能为空"));
 
-        String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
-        if (StringUtils.isBlank(accountId)) {
-            throw new BizException("创建企业电子存证账户失败");
-        }
+		SysUserTsign sysUserTsign = null;
 
-        String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
-        if (StringUtils.isBlank(sealData)) {
-            throw new BizException("创建电子存证印章失败");
-        }
+		SysUserTsign orignSysUserTsign = sysUserTsignService.get(-userId);
 
-        SysUserTsign sysUserTsign = new SysUserTsign(-userId, accountId, sealData, orgName, organCode, tenantId);
-        sysUserTsignService.insert(sysUserTsign);
-    }
+		if (orignSysUserTsign == null || !StringUtils.equals(orignSysUserTsign.getCardNo(), organCode)) {
 
-    @Override
+			String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
+			if (StringUtils.isBlank(accountId)) {
+				throw new BizException("创建企业电子存证账户失败");
+			}
+
+			String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
+			if (StringUtils.isBlank(sealData)) {
+				throw new BizException("创建电子存证印章失败");
+			}
+
+			sysUserTsign = new SysUserTsign(-userId, accountId, sealData, orgName, organCode, tenantId);
+
+			if (orignSysUserTsign == null) {
+				sysUserTsignService.insert(sysUserTsign);
+			} else {
+				orignSysUserTsign.setAccountId(accountId);
+				orignSysUserTsign.setSealData(sealData);
+				orignSysUserTsign.setCardNo(organCode);
+				sysUserTsignService.update(orignSysUserTsign);
+			}
+
+		} else if (!StringUtils.equals(orignSysUserTsign.getName(), orgName)) {
+			if (eSealPlugin.updateOrganAccount(orignSysUserTsign.getAccountId(), orgName, organCode)) {
+				orignSysUserTsign.setName(orgName);
+				sysUserTsignService.update(orignSysUserTsign);
+			}
+		}
+
+	}
+
+	@Override
     public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
 
         if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -218,7 +218,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         		tenantContractTemplateDao.update(tenantContractTemplate);
         	}
             //添加签章信息
-            contractService.addTsign(tenantInfo.getUserId(), tenantInfo.getTsignCode(), tenantInfo.getTsignName(), tenantId);
+            contractService.addTsign(tenantInfo.getUserId(), dto.getTsignCode(), dto.getTsignName(), tenantId);
         }
 
         //机构状态 1已缴费,并且 机构注册的手机号与本次修改后的手机号不同,就证明本次修改了手机号 则需要修改机构的账号信息

+ 20 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/eseal/ESealPlugin.java

@@ -11,6 +11,16 @@ public interface ESealPlugin {
      * @return 账户唯一标识
      */
     public String createUserAccount(String realName, String idcard, String mobile);
+    
+    /**
+     * 更新用户账户(个人)
+     * @param accountId 账户唯一标识
+     * @param realName 姓名
+     * @param idcard 身份证号码
+     * @param mobile 手机号码
+     * @return
+     */
+    public boolean updateUserAccount(String accountId, String realName, String idcard, String mobile);
 
     /**
      * 创建用户账户(企业)
@@ -22,6 +32,16 @@ public interface ESealPlugin {
     public String createOrganAccount(String orgName, String organCode);
 
     /**
+     * 修改用户账户(企业)
+     *
+     * @param accountId   账户唯一标识
+     * @param orgName   机构名称
+     * @param organCode 统一社会信用代码
+     * @return
+     */
+    public boolean updateOrganAccount(String accountId, String orgName, String organCode);
+
+    /**
      * 创建个人印章
      *
      * @param accountId 账户唯一标识

+ 38 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/eseal/provider/TsignPlugin.java

@@ -10,6 +10,8 @@ import com.timevale.esign.sdk.tech.bean.OrganizeBean;
 import com.timevale.esign.sdk.tech.bean.PersonBean;
 import com.timevale.esign.sdk.tech.bean.PosBean;
 import com.timevale.esign.sdk.tech.bean.SignPDFFileBean;
+import com.timevale.esign.sdk.tech.bean.UpdateOrganizeBean;
+import com.timevale.esign.sdk.tech.bean.UpdatePersonBean;
 import com.timevale.esign.sdk.tech.bean.result.AddAccountResult;
 import com.timevale.esign.sdk.tech.bean.result.AddSealResult;
 import com.timevale.esign.sdk.tech.bean.result.FileDigestSignResult;
@@ -32,6 +34,9 @@ import com.timevale.tech.sdk.bean.ProjectConfig;
 import com.ym.mec.thirdparty.eseal.ESealPlugin;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 
+/**
+ * 接口文档地址  https://open.esign.cn/doc/detail?id=opendoc%2Fpaas_sdk%2Fbzu9e8&namespace=opendoc%2Fpaas_sdk&searchText=
+ */
 @Service
 public class TsignPlugin implements ESealPlugin, InitializingBean, DisposableBean {
 
@@ -97,7 +102,23 @@ public class TsignPlugin implements ESealPlugin, InitializingBean, DisposableBea
         throw new ThirdpartyException(result.getMsg());
     }
 
-    /**
+    @Override
+	public boolean updateUserAccount(String accountId, String realName, String idcard, String mobile) {
+    	
+    	UpdatePersonBean updatePersonBean = new UpdatePersonBean();
+        updatePersonBean.setMobile(mobile);// 手机号码,可空
+        updatePersonBean.setName(realName);// 姓名,可空
+        
+        AccountService service = serviceClient.accountService();
+        Result result = service.updateAccount(accountId, updatePersonBean, null);
+        
+        if (result.getErrCode() == 0) {
+            return true;
+        }
+        throw new ThirdpartyException(result.getMsg());
+	}
+
+	/**
      * 创建用户账户(企业)
      *
      * @param orgName   机构名称
@@ -119,6 +140,22 @@ public class TsignPlugin implements ESealPlugin, InitializingBean, DisposableBea
         throw new ThirdpartyException("创建企业账户接口调用失败code=" + result.getErrCode() + "msg=" + result.getMsg());
     }
 
+	@Override
+	public boolean updateOrganAccount(String accountId, String orgName, String organCode) {
+		
+		UpdateOrganizeBean updateOrganizeBean = new UpdateOrganizeBean();
+        updateOrganizeBean.setName(orgName);//机构名称,可空
+
+        AccountService service = serviceClient.accountService();
+        Result result = service.updateAccount(accountId, updateOrganizeBean, null);
+        
+        if (result.getErrCode() == 0) {
+            return true;
+        }
+        throw new ThirdpartyException(result.getMsg());
+		
+	}
+
     /**
      * 创建印章
      *