浏览代码

feat(app): 优化个人认证流程并添加合同模板功能

-重写个人认证流程,使用 GetPsnAuthUrlDTO 作为参数
- 添加上传合同底稿、发起签署、获取签署链接等功能- 新增制作合同模板和编辑合同功能
- 更新相关 DTO 和服务接口
SheepHy 4 天之前
父节点
当前提交
d02867481c

+ 32 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/ESignApi.java

@@ -29,7 +29,7 @@ public class ESignApi {
      * @return boolean
      **/
     @GetMapping("/getUserIdentityInfo")
-    @Operation(summary = "查询用户授权状态")
+    @Operation(summary = "查询用户授权状态-APP")
     public Result<Boolean> getUserIdentityInfo(@RequestParam("phoneNumber") @Schema(description="联系人手机号")String phoneNumber) throws EsignDemoException{
         return Result.OK(iESignService.getUserIdentityInfo(phoneNumber));
     }
@@ -42,9 +42,9 @@ public class ESignApi {
      * @return
      **/
     @GetMapping("/getAuthUrl")
-    @Operation(summary = "用户获取授权链接")
-    public Result<String> getAuthUrl(@RequestParam("phoneNumber") @Schema(description="联系人手机号")String phoneNumber) throws EsignDemoException{
-        return Result.OK(iESignService.getAuthUrl(phoneNumber));
+    @Operation(summary = "用户获取授权链接-APP")
+    public Result<String> getAuthUrl() throws EsignDemoException{
+        return Result.OK(iESignService.getAuthUrl());
     }
 
 
@@ -56,7 +56,7 @@ public class ESignApi {
      * @return
      **/
     @GetMapping("/getOrgIdentityInfos")
-    @Operation(summary = "查询企业授权状态")
+    @Operation(summary = "查询企业授权状态-PC")
     public Result<Boolean> getOrgIdentityInfos(@RequestParam("orgName") @Schema(description="企业名称")String orgName) throws EsignDemoException{
         return Result.OK(iESignService.getOrgIdentityInfos(orgName));
     }
@@ -69,9 +69,35 @@ public class ESignApi {
      * @return
      **/
     @GetMapping("/getOrgAuthUrls")
-    @Operation(summary = "企业获取授权链接")
+    @Operation(summary = "企业获取授权链接-PC")
     public Result<String> getOrgAuthUrls(@RequestParam("orgName") @Schema(description="企业名称")String orgName,
                                          @RequestParam("phoneNumber") @Schema(description="联系人手机号")String phoneNumber) throws EsignDemoException{
         return Result.OK(iESignService.getOrgAuthUrls(orgName,phoneNumber));
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 上传合同底稿
+     * @Date 9:54 2025/7/21
+     * @Param
+     * @return
+     **/
+    @GetMapping("/uploadContractTemplate")
+    @Operation(summary = "上传合同底稿-PC")
+    public Result<Boolean> uploadContractTemplate(@RequestParam("filePath") @Schema(description="上传文件路径")String filePath) throws EsignDemoException{
+        return Result.OK(iESignService.uploadContractTemplate(filePath));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 获取签署链接
+     * @Date 14:02 2025/7/21
+     * @Param
+     * @return
+     **/
+    @GetMapping("/getSignUrl")
+    @Operation(summary = "获取签署链接-APP")
+    public Result<String> getSignUrl(@RequestParam("signFlowId") @Schema(description="文件标识")String signFlowId) throws EsignDemoException{
+        return Result.OK(iESignService.getSignUrl(signFlowId));
+    }
 }

+ 213 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/dto/CreateSignFlowDTO.java

@@ -0,0 +1,213 @@
+package org.jeecg.modules.app.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="创建签署流程参数DTO")
+public class CreateSignFlowDTO {
+    @Schema(description = "文档列表")
+    private List<Doc> docs;
+    @Schema(description = "签署流程配置")
+    private SignFlowConfig signFlowConfig;
+    @Schema(description = "签署人列表")
+    private List<Signer> signers;
+    /**
+     * 文档信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "文档信息")
+    public static class Doc {
+        @Schema(description = "文件ID")
+        private String fileId;
+        @Schema(description = "文件名称")
+        private String fileName;
+    }
+    /**
+     * 签署流程配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "签署流程配置")
+    public static class SignFlowConfig {
+        @Schema(description = "流程标题")
+        private String signFlowTitle;
+
+        @Schema(description = "计费配置")
+        private ChargeConfig chargeConfig;
+    }
+    /**
+     * 计费配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "计费配置")
+    public static class ChargeConfig {
+        @Schema(description = "计费模式(0-按合同计费)")
+        private Integer chargeMode;
+    }
+    /**
+     * 签署人信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "签署人信息")
+    public static class Signer {
+        @Schema(description = "通知配置")
+        private NoticeConfig noticeConfig;
+        @Schema(description = "组织签署人信息")
+        private OrgSignerInfo orgSignerInfo;
+        @Schema(description = "签署配置")
+        private SignConfig signConfig;
+        @Schema(description = "签署区列表")
+        private List<SignField> signFields;
+        @Schema(description = "签署人类型(1-组织)")
+        private Integer signerType;
+    }
+    /**
+     * 通知配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "通知配置")
+    public static class NoticeConfig {
+        @Schema(description = "通知类型集合")
+        private String noticeTypes;
+    }
+    /**
+     * 组织签署人信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "组织签署人信息")
+    public static class OrgSignerInfo {
+        @Schema(description = "组织ID")
+        private String orgId;
+        @Schema(description = "组织信息")
+        private OrgInfo orgInfo;
+        @Schema(description = "组织名称")
+        private String orgName;
+        @Schema(description = "经办人信息")
+        private TransactorInfo transactorInfo;
+    }
+    /**
+     * 组织基本信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "组织基本信息")
+    public static class OrgInfo {
+        @Schema(description = "法人身份证号码")
+        private String legalRepIDCardNum;
+        @Schema(description = "法人身份证类型")
+        private String legalRepIDCardType;
+        @Schema(description = "法人姓名")
+        private String legalRepName;
+        @Schema(description = "组织证件号码")
+        private String orgIDCardNum;
+        @Schema(description = "组织证件类型")
+        private String orgIDCardType;
+    }
+    /**
+     * 经办人信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "经办人信息")
+    public static class TransactorInfo {
+        @Schema(description = "经办人账号")
+        private String psnAccount;
+        @Schema(description = "经办人ID")
+        private String psnId;
+        @Schema(description = "经办人详情")
+        private PsnInfo psnInfo;
+    }
+    /**
+     * 人员信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "人员信息")
+    public static class PsnInfo {
+        @Schema(description = "银行卡号")
+        private String bankCardNum;
+        @Schema(description = "身份证号码")
+        private String psnIDCardNum;
+        @Schema(description = "身份证类型")
+        private String psnIDCardType;
+        @Schema(description = "人员姓名")
+        private String psnName;
+    }
+    /**
+     * 签署配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "签署配置")
+    public static class SignConfig {
+        @Schema(description = "签署顺序")
+        private Integer signOrder;
+    }
+    /**
+     * 签署区信息
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "签署区信息")
+    public static class SignField {
+        @Schema(description = "业务编号")
+        private String customBizNum;
+        @Schema(description = "文件ID")
+        private String fileId;
+        @Schema(description = "普通签署区配置")
+        private NormalSignFieldConfig normalSignFieldConfig;
+        @Schema(description = "签署区类型(0-普通签署区)")
+        private Integer signFieldType;
+    }
+    /**
+     * 普通签署区配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "普通签署区配置")
+    public static class NormalSignFieldConfig {
+        @Schema(description = "指定印章ID")
+        private String assignedSealId;
+        @Schema(description = "自动签署标志")
+        private Boolean autoSign;
+        @Schema(description = "自由模式标志")
+        private Boolean freeMode;
+        @Schema(description = "可移动签署区标志")
+        private Boolean movableSignField;
+        @Schema(description = "组织印章业务类型")
+        private String orgSealBizTypes;
+        @Schema(description = "人员印章样式")
+        private String psnSealStyles;
+        @Schema(description = "签署区位置")
+        private SignFieldPosition signFieldPosition;
+        @Schema(description = "签署区样式")
+        private Integer signFieldStyle;
+    }
+
+    /**
+     * 签署区位置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "签署区位置")
+    public static class SignFieldPosition {
+        @Schema(description = "位置页面")
+        private String positionPage;
+        @Schema(description = "X坐标")
+        private Integer positionX;
+        @Schema(description = "Y坐标")
+        private Integer positionY;
+    }
+}

+ 79 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/dto/GetPsnAuthUrlDTO.java

@@ -0,0 +1,79 @@
+package org.jeecg.modules.app.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "个人认证授权参数DTO")
+public class GetPsnAuthUrlDTO {
+    @Schema(description = "个人认证配置")
+    private PsnAuthConfig psnAuthConfig;
+
+    @Schema(description = "授权配置")
+    private AuthorizeConfig authorizeConfig;
+
+    @Schema(description = "通知回调地址")
+    private String notifyUrl;
+
+    @Schema(description = "客户端类型")
+    private String clientType = "ALL";
+
+    @Schema(description = "重定向配置")
+    private RedirectConfig redirectConfig;
+
+    /**
+     * 个人认证配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "个人认证配置")
+    public static class PsnAuthConfig {
+        @Schema(description = "用户账号")
+        private String psnAccount;
+
+        @Schema(description = "个人认证页面配置")
+        private PsnAuthPageConfig psnAuthPageConfig;
+    }
+
+    /**
+     * 个人认证页面配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "个人认证页面配置")
+    public static class PsnAuthPageConfig {
+        @Schema(description = "默认认证方式")
+        private String psnDefaultAuthMode = "PSN_MOBILE3";
+
+        @Schema(description = "可用认证方式列表")
+        private List<String> psnAvailableAuthModes = List.of("PSN_MOBILE3");
+    }
+
+    /**
+     * 授权配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "授权配置")
+    public static class AuthorizeConfig {
+        @Schema(description = "授权范围列表")
+        private List<String> authorizedScopes = List.of("get_psn_identity_info");
+    }
+
+    /**
+     * 重定向配置
+     */
+    @Data
+    @Accessors(chain = true)
+    @Schema(description = "重定向配置")
+    public static class RedirectConfig {
+        @Schema(description = "重定向地址")
+        private String redirectUrl;
+    }
+}

+ 4 - 61
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/auth/AuthDemo.java → national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/auth/ESignAuth.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.app.esign.auth;
 
+import org.jeecg.modules.app.dto.GetPsnAuthUrlDTO;
 import org.jeecg.modules.app.esign.comm.EsignHttpHelper;
 import org.jeecg.modules.app.esign.comm.EsignHttpResponse;
 import org.jeecg.modules.app.esign.constant.EsignDemoConfig;
@@ -10,77 +11,22 @@ import java.util.Map;
 
 /**
  * description 认证与授权服务
- * @author 语冰
  * datetime 2022年8月10日上午09:43:24
  */
-public class AuthDemo extends Exception {
+public class ESignAuth extends Exception {
 
 	private static String eSignHost= EsignDemoConfig.EsignHost;
 	private static String eSignAppId=EsignDemoConfig.EsignAppId;
 	private static String eSignAppSecret=EsignDemoConfig.EsignAppSecret;
-
-//	public static void main(String[] args) throws EsignDemoException {
-//		Gson gson = new Gson();
-//		/* 获取个人认证授权链接*/
-//		EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl();
-//		JsonObject getPsnAuthUrlObject = gson.fromJson(getPsnAuthUrl.getBody(), JsonObject.class);
-//		JsonObject data = getPsnAuthUrlObject.getAsJsonObject("data");
-//		String authUrl = data.get("authUrl").getAsString();
-//		System.err.println("个人授权链接:"+authUrl);
-//		/* 查询个人认证授权状态*/
-//		EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo();
-//		JsonObject getPsnIdentityInfoObject = gson.fromJson(getPsnIdentityInfo.getBody(), JsonObject.class);
-//		String realnameStatus =getPsnIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
-//		System.err.println("个人认证状态:"+realnameStatus);
-//		/* 获取企业认证授权链接*/
-//		EsignHttpResponse getOrgAuthUrl = getOrgAuthUrl();
-//		JsonObject getOrgAuthUrlObject = gson.fromJson(getOrgAuthUrl.getBody(), JsonObject.class);
-//		String orgAuthUrl =	getOrgAuthUrlObject.getAsJsonObject("data").get("authUrl").getAsString();
-//		System.err.println("企业授权链接:"+orgAuthUrl);
-//		/* 查询企业认证授权状态*/
-//		EsignHttpResponse getOrgIdentityInfo = getOrgIdentityInfo();
-//		JsonObject getOrgIdentityInfoObject = gson.fromJson(getOrgIdentityInfo.getBody(), JsonObject.class);
-//		String orgRealnameStatus =	getOrgIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
-//		System.err.println("企业认证状态:"+orgRealnameStatus);
-//
-//	}
-
 	/**
 	 * 获取个人认证链接
 	 * @return
 	 * @throws EsignDemoException
 	 */
-	public static EsignHttpResponse getPsnAuthUrl(String phoneNumber) throws EsignDemoException {
+	public static EsignHttpResponse getPsnAuthUrl(GetPsnAuthUrlDTO getPsnAuthUrlDTO) throws EsignDemoException {
 		String apiaddr="/v3/psn-auth-url";
 		//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
-		String jsonParm="{\n" +
-				"    \"psnAuthConfig\": {\n" +
-				"        \"psnAccount\": \"" + phoneNumber + "\",\n" +
-				"        \"psnAuthPageConfig\": {\n" +
-				"            \"psnEditableFields\": [\n" +
-				"                \"name\",\n" +
-				"                \"IDCardNum\",\n" +
-				"                \"mobile\",\n" +
-				"                \"bankCardNum\"  \n" +
-				"            ]\n" +
-				"        }\n" +
-				"    },\n" +
-				"    \"clientType\": \"ALL\",\n" +
-				"    \"appScheme\":\"esign://demo/realBack\",\n" +
-				"    \"redirectConfig\": {\n" +
-				"        \"redirectDelayTime\": \"3\",\n" +
-				"        \"redirectUrl\": \"esign://demo/realBack\"\n" +
-				"    },\n" +
-				"    \"authorizeConfig\": {\n" +
-				"        \"authorizedScopes\": [\n" +
-				"            \"get_psn_identity_info\",\n" +
-				"            \"psn_initiate_sign\",\n" +
-				"            \"manage_psn_resource\"\n" +
-				"        ]\n" +
-				"    },\n" +
-				"    \"repeatableAuth\": true\n" +
-				"}";
-
+		String jsonParm = getPsnAuthUrlDTO.toString();
 		//请求方法
 		EsignRequestType requestType= EsignRequestType.POST;
 		//生成签名鉴权方式的的header
@@ -94,7 +40,6 @@ public class AuthDemo extends Exception {
 	 */
 	public static EsignHttpResponse getPsnIdentityInfo(String phoneNumber) throws EsignDemoException {
 		String apiaddr="/v3/persons/identity-info?psnAccount="+phoneNumber;
-
 		//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
 		String jsonParm=null;
 		//请求方法
@@ -108,8 +53,6 @@ public class AuthDemo extends Exception {
 	 * 获取企业认证链接
 	 * @return
 	 * @throws EsignDemoException
-	 *
-	 *
 	 */
 	public static EsignHttpResponse getOrgAuthUrl(String orgName,String phoneNumber) throws EsignDemoException {
 		String apiaddr="/v3/org-auth-url";

+ 12 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/constant/EsignDemoConfig.java

@@ -8,6 +8,18 @@ public class EsignDemoConfig {
     public static final String EsignAppSecret = "ce891a865bdd94d0081cae50f13739e4";
     // e签宝接口调用域名(模拟环境)
     public static final String EsignHost = "https://smlopenapi.esign.cn";
+
+    public static final String E_SIGN_NOTIFY_URL = "e_sign_notify_url";
+
+    //系统全局回调地址
+    public static final String NOTIFY_URL = "notify_url";
+
+    //APP重定向
+    public static final String APP_REDIRECT_URL = "app_redirect_url";
+
+    //PC重定向
+    public static final String PC_REDIRECT_URL = "pc_redirect_url";
+
     // e签宝接口调用域名(正式环境)
     // public static final String EsignHost = "https://openapi.esign.cn";
 }

+ 0 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/exception/EsignDemoException.java

@@ -2,7 +2,6 @@ package org.jeecg.modules.app.esign.exception;
 
 /**
  * description 自定义全局异常
- * @author 澄泓
  * datetime 2019年7月1日上午10:43:24
  */
 public class EsignDemoException extends Exception {

+ 8 - 8
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/esign/fileAndTemplate/TemplateDemo.java

@@ -22,14 +22,14 @@ public class TemplateDemo extends Exception {
 
 	public static void main(String[] args) throws EsignDemoException {
 		/* 获取制作合同模板页面*/
-		EsignHttpResponse getTemplateCreateUrl = getTemplateCreateUrl();
+//		EsignHttpResponse getTemplateCreateUrl = getTemplateCreateUrl();
 		Gson gson = new Gson();
-		JsonObject getTemplateCreateUrlObject = gson.fromJson(getTemplateCreateUrl.getBody(), JsonObject.class);
+//		JsonObject getTemplateCreateUrlObject = gson.fromJson(getTemplateCreateUrl.getBody(), JsonObject.class);
 
-		String docTemplateCreateUrl = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateCreateUrl").getAsString();
-		String docTemplateId = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateId").getAsString();
-		System.err.println("制作合同模板的页面链接:"+docTemplateCreateUrl);
-		System.err.println("合同模板id:"+docTemplateId);
+//		String docTemplateCreateUrl = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateCreateUrl").getAsString();
+//		String docTemplateId = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateId").getAsString();
+//		System.err.println("制作合同模板的页面链接:"+docTemplateCreateUrl);
+//		System.err.println("合同模板id:"+docTemplateId);
 
 		/* 获取编辑合同模板页面*/
 		EsignHttpResponse getTemplateEditUrl = getTemplateEditUrl();
@@ -61,7 +61,7 @@ public class TemplateDemo extends Exception {
 	 * @return
 	 * @throws EsignDemoException
 	 */
-	private static EsignHttpResponse getTemplateCreateUrl() throws EsignDemoException {
+	public static EsignHttpResponse getTemplateCreateUrl(String fileId) throws EsignDemoException {
 		String apiaddr="/v3/doc-templates/doc-template-create-url";
 		//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
 		String jsonParm="{\"docTemplateName\":\"测试模板\",\"docTemplateType\":0,\"fileId\":\"b3f01axxxxxx05d320da35\",\"redirectUrl\":\"https://www.esign.cn\"}";
@@ -78,7 +78,7 @@ public class TemplateDemo extends Exception {
 	 * @return
 	 * @throws EsignDemoException
 	 */
-	private static EsignHttpResponse getTemplateEditUrl() throws EsignDemoException {
+	public static EsignHttpResponse getTemplateEditUrl() throws EsignDemoException {
 		String docTemplateId="a6f7e3b4e7xxxxxxxedc6fc89";
 		String apiaddr="/v3/doc-templates/"+docTemplateId+"/doc-template-edit-url";
 		//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null

+ 48 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IESignService.java

@@ -19,7 +19,7 @@ public interface IESignService {
      * @Param
      * @return
      **/
-    String getAuthUrl(String phoneNumber) throws EsignDemoException;
+    String getAuthUrl() throws EsignDemoException;
 
 
     /**
@@ -39,4 +39,51 @@ public interface IESignService {
      * @return
      **/
     String getOrgAuthUrls(String orgName,String phoneNumber) throws EsignDemoException;
+
+    /**
+     * @Author SheepHy
+     * @Description 上传合同底稿
+     * @Date 9:54 2025/7/21
+     * @Param
+     * @return
+     **/
+    boolean uploadContractTemplate(String filePath) throws EsignDemoException;
+
+
+    /**
+     * @Author SheepHy
+     * @Description 发起签署
+     * @Date 10:10 2025/7/21
+     * @Param
+     * @return
+     **/
+    String createSign(String fileId) throws EsignDemoException;
+
+    /**
+     * @Author SheepHy
+     * @Description 获取签署链接
+     * @Date 14:02 2025/7/21
+     * @Param
+     * @return
+     **/
+    String getSignUrl(String signFlowId) throws EsignDemoException;
+
+
+    /**
+     * @Author SheepHy
+     * @Description 制作模板
+     * @Date 14:47 2025/7/21
+     * @Param
+     * @return
+     **/
+    String createTemplate(String fileId) throws EsignDemoException;
+
+    /**
+     * @Author SheepHy
+     * @Description 编辑合同
+     * @Date 15:01 2025/7/21
+     * @Param
+     * @return
+     **/
+    String editContract(String docTemplateId) throws EsignDemoException;
 }

+ 76 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/ESignServiceImpl.java

@@ -1,18 +1,35 @@
 package org.jeecg.modules.app.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import lombok.extern.log4j.Log4j2;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.app.dto.GetPsnAuthUrlDTO;
 import org.jeecg.modules.app.esign.comm.EsignHttpResponse;
 import org.jeecg.modules.app.esign.exception.EsignDemoException;
+import org.jeecg.modules.app.esign.fileAndTemplate.FileDemo;
+import org.jeecg.modules.app.esign.sign.SignDemo;
 import org.jeecg.modules.app.service.IESignService;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.mapper.SysUserMapper;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+
 import static com.alibaba.dashscope.utils.JsonUtils.gson;
-import static org.jeecg.modules.app.esign.auth.AuthDemo.*;
+import static org.jeecg.modules.app.esign.auth.ESignAuth.*;
+import static org.jeecg.modules.app.esign.fileAndTemplate.TemplateDemo.getTemplateCreateUrl;
+import static org.jeecg.modules.app.esign.fileAndTemplate.TemplateDemo.getTemplateEditUrl;
+import static org.jeecg.modules.app.esign.sign.SignDemo.createByFile;
 
 @Service
 @Log4j2
 public class ESignServiceImpl implements IESignService {
+    @Resource
+    private SysUserMapper sysUserMapper;
     @Override
     public boolean getUserIdentityInfo(String phoneNumber) throws EsignDemoException {
         EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo(phoneNumber);
@@ -22,8 +39,14 @@ public class ESignServiceImpl implements IESignService {
     }
 
     @Override
-    public String getAuthUrl(String phoneNumber) throws EsignDemoException {
-        EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl(phoneNumber);
+    public String getAuthUrl() throws EsignDemoException {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        SysUser sysUser = sysUserMapper.selectById(user.getId());
+        if (null == sysUser.getPhone()) throw new JeecgBootException("请先绑定手机号");
+        GetPsnAuthUrlDTO getPsnAuthUrlDTO = new GetPsnAuthUrlDTO();
+        GetPsnAuthUrlDTO.PsnAuthConfig pncAuthConfig = new GetPsnAuthUrlDTO.PsnAuthConfig().setPsnAccount(sysUser.getPhone());
+        getPsnAuthUrlDTO.setPsnAuthConfig(pncAuthConfig);
+        EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl(getPsnAuthUrlDTO);
         JsonObject getPsnAuthUrlObject = gson.fromJson(getPsnAuthUrl.getBody(), JsonObject.class);
         JsonObject data = getPsnAuthUrlObject.getAsJsonObject("data");
         return data.get("authUrl").getAsString();
@@ -44,5 +67,55 @@ public class ESignServiceImpl implements IESignService {
         return getOrgAuthUrlObject.getAsJsonObject("data").get("authUrl").getAsString();
     }
 
+    @Override
+    public boolean uploadContractTemplate(String filePath) throws EsignDemoException {
+        EsignHttpResponse getUploadUrl = FileDemo.getUploadUrl(filePath);
+        JsonObject getUploadUrlJsonObject = gson.fromJson(getUploadUrl.getBody(), JsonObject.class);
+        JsonObject data = getUploadUrlJsonObject.getAsJsonObject("data");
+        String fileUploadUrl =data.get("fileUploadUrl").getAsString();
+        EsignHttpResponse uploadFileResponse = FileDemo.uploadFile(fileUploadUrl,filePath);
+        JsonObject uploadFileResponseJsonObject = gson.fromJson(uploadFileResponse.getBody(), JsonObject.class);
+        int errCode = uploadFileResponseJsonObject.get("errCode").getAsInt();
+        return errCode == 0;
+    }
+
+    @Override
+    public String createSign(String fileId) throws EsignDemoException {
+        EsignHttpResponse createByFile = createByFile();
+        JSONObject createByFileJsonObject = JSONObject.parseObject(createByFile.getBody());
+        String signFlowId = createByFileJsonObject.getJSONObject("data").getString("signFlowId");
+        System.out.println("signFlowId:" + signFlowId);
+        return "";
+    }
+
+    @Override
+    public String getSignUrl(String signFlowId) throws EsignDemoException {
+        JSONObject signUrl = JSONObject.parseObject(SignDemo.signUrl(signFlowId).getBody());
+        return signUrl.getJSONObject("data").getString("url");
+    }
+
+    @Override
+    public String createTemplate(String fileId) throws EsignDemoException {
+        /* 获取制作合同模板页面*/
+        EsignHttpResponse getTemplateCreateUrl = getTemplateCreateUrl(fileId);
+        Gson gson = new Gson();
+        JsonObject getTemplateCreateUrlObject = gson.fromJson(getTemplateCreateUrl.getBody(), JsonObject.class);
+
+        String docTemplateCreateUrl = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateCreateUrl").getAsString();
+        String docTemplateId = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateId").getAsString();
+        System.err.println("制作合同模板的页面链接:"+docTemplateCreateUrl);
+        System.err.println("合同模板id:"+docTemplateId);
+        return "";
+    }
+
+    @Override
+    public String editContract(String docTemplateId) throws EsignDemoException {
+        /* 获取编辑合同模板页面*/
+        EsignHttpResponse getTemplateEditUrl = getTemplateEditUrl();
+        JsonObject getTemplateEditUrlObject = gson.fromJson(getTemplateEditUrl.getBody(), JsonObject.class);
+        String docTemplateEditUrl = getTemplateEditUrlObject.getAsJsonObject("data").get("docTemplateEditUrl").getAsString();
+        System.err.println("编辑合同模板的页面链接:"+docTemplateEditUrl);
+        return "";
+    }
 }
 

+ 4 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/entity/SysUser.java

@@ -82,6 +82,10 @@ public class SysUser implements Serializable {
     @Excel(name = "性别", width = 15,dicCode="sex")
     @Dict(dicCode = "sex")
     private Integer sex;
+    /**
+     * E签宝是否授权
+     */
+    private Integer eSignAuth;
 
     /**
      * 电子邮件