Ver código fonte

Merge remote-tracking branch 'origin/develop-test' into develop-test

shenjingwei 1 semana atrás
pai
commit
4edfc7c9e2

+ 5 - 3
src/custom/restcontroller/webmanage/sale/contracttask/EsignContractTaskMX.java

@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Map;
 
+import static restcontroller.webmanage.sale.contracttask.WeChatConfig.ProxyOrganizationName;
+
 /**
  * 电子签合同任务明细
  */
@@ -102,7 +104,7 @@ public class EsignContractTaskMX extends Controller {
             querySQL.setWhere("t4.accountno='02'");
         }
         if (usertype == 2) {
-            querySQL.setWhere("t1.sys_enterpriseid in (SELECT t1.sys_enterpriseid FROM sys_enterprise_tradefield t1 INNER JOIN sa_salearea_hr t2 ON t2.sa_saleareaid=t1.sa_saleareaid WHERE t2.hrid="+hrid+")");
+            querySQL.setWhere("t1.sys_enterpriseid in (SELECT t1.sys_enterpriseid FROM sys_enterprise_tradefield t1 INNER JOIN sa_salearea_hr t2 ON t2.sa_saleareaid=t1.sa_saleareaid WHERE t2.hrid=" + hrid + ")");
         }
         querySQL.setWhere("t1.status=1");
         querySQL.setWhere("NOT EXISTS (SELECT 1 from sa_esign_contract_taskmx WHERE sa_agentsid=t1.sa_agentsid and sa_esign_contract_taskid='" + sa_esign_contract_taskid + "' )");
@@ -380,7 +382,7 @@ public class EsignContractTaskMX extends Controller {
         // 获取模板里面的参与方RecipientId
         Recipient[] recipients = WeChatByTemplate.GetRecipients(templateId);
         if (recipients == null) {
-            throw new NullPointerException("签署人不能为空");
+            throw new NullPointerException("获取模板签署人失败,请检查模板ID[" + templateId + "]是否有效或是否配置了签署方");
         }
         //构造签署人信息
         FlowApproverInfo[] flowApproverInfos = WeChatByTemplate.BuildApprovers(Arrays.asList(recipients), license_name, legal_rep, phonenumber);
@@ -399,7 +401,7 @@ public class EsignContractTaskMX extends Controller {
 
         // 发起合同 样例为BtoC
         Map<String, String[]> resp = wccUtil.createFlowByTemplateDirectly(flowName
-                , templateId, flowApproverInfos, WeChatConfig.SuperProxyOperatorOpenId, companyInfo, fileBase64List);
+                , templateId, flowApproverInfos, companyInfo, fileBase64List);
         int count = WeChatConfig.COUNT;
         for (int i = 0; i < count; i++) {
 //            // 返回合同Id

+ 11 - 2
src/custom/restcontroller/webmanage/sale/contracttask/WeChatByTemplate.java

@@ -104,8 +104,17 @@ public class WeChatByTemplate {
         DescribeTemplatesResponse templatesResponse = WeChatContractUtil.describeTemplates(WeChatContractUtil.setAgent(WeChatConfig.SuperProxyOperatorOpenId),
                 templateId);
 
-        return Optional.ofNullable(templatesResponse).filter(template -> template.getTemplates().length > 0).
-                map(DescribeTemplatesResponse::getTemplates).map(rec -> rec[0].getRecipients()).orElse(null);
+        if (templatesResponse == null) {
+            throw new NullPointerException("查询电子签模板[" + templateId + "]返回为空");
+        }
+        if (templatesResponse.getTemplates() == null || templatesResponse.getTemplates().length == 0) {
+            throw new NullPointerException("电子签模板[" + templateId + "]不存在,请检查模板ID是否正确");
+        }
+        Recipient[] recipients = templatesResponse.getTemplates()[0].getRecipients();
+        if (recipients == null || recipients.length == 0) {
+            throw new NullPointerException("电子签模板[" + templateId + "]未配置签署方,请在腾讯电子签控制台配置签署参与方");
+        }
+        return recipients;
     }
 
     public static FormField BuildFormField(String componentName, String componentValue) {

+ 21 - 10
src/custom/restcontroller/webmanage/sale/contracttask/WeChatConfig.java

@@ -8,12 +8,20 @@ import org.apache.commons.codec.digest.DigestUtils;
 public class WeChatConfig {
     // SecretId SecretKey 调用云API需要使用的密钥对,是平台企业的密钥对(子客企业无需准备此参数)。
     // 联调/生产环境都是可以由平台企业电子签控制台应用集成模块自主获取。
-    public static final String SecretId = "AKyD3g9UUckpm7xfldUESaMt9uTigZZ4ym";
-    public static final String SecretKey = "SKLNHCCdOwpGEyobK19Vnntwh5DtnKA6ak";
+    //测试
+//    public static final String SecretId = "AKyD3g9UUckpm7xfldUESaMt9uTigZZ4ym";
+//    public static final String SecretKey = "SKLNHCCdOwpGEyobK19Vnntwh5DtnKA6ak";
+
+    //正式
+    public static final String SecretId = "AKIDZr0ymPs9E63tZ3NXcVBgy5ziHhw1udAR";
+    public static final String SecretKey = "A9vjUcdBlDbw9C4rUvNjW8Zv6D9ayHPL";
 
     // 应用的唯一标识,对应通用参数AppId。不同的业务系统可以采用不同的AppId,
     // 不同AppId下的数据是隔离的。联调/生产环境都是可以由控制台开发者中心-应用集成自主生成。
-    public static final String AppId = "yD3g9UUckpm7fg9aUE66BdtzqsVl3kQL";
+    //测试
+//    public static final String AppId = "yD3g9UUckpm7fg9aUE66BdtzqsVl3kQL";
+    //正式
+    public static final String AppId = "yD3PxUU1mewvnwUx3tsXdxP7ndvLPevd";
 
     // 非必需
     // 在子客企业开通电子签后,会生成唯一的子客应用Id(ProxyAppId)用于代理调用时的鉴权
@@ -26,12 +34,12 @@ public class WeChatConfig {
     //(比如,可以使用企业名称的hash值,或者社会统一信用代码的hash值,或者随机hash值,需要平台企业保存)
     // 最大64位字符串
     // 固定为DigestUtils.sha256Hex("浙江美大实业股份有限公司");
-    // public static final String ProxyOrganizationName = "浙江美大实业股份有限公司";
-    //public static final String ProxyOrganizationOpenId = "3049ce2a73196fd18389510e1256d690a11ef0a58e0504f8df06b3dee34596b1";
-
-    public static final String ProxyOrganizationName = "嘉兴市云链信息技术有限公司测试";
+    public static final String ProxyOrganizationName = "浙江美大节能电器销售有限公司";
     public static final String ProxyOrganizationOpenId = DigestUtils.sha256Hex(ProxyOrganizationName);
 
+//    public static final String ProxyOrganizationName = "嘉兴市云链信息技术有限公司测试";
+//    public static final String ProxyOrganizationOpenId = DigestUtils.sha256Hex(ProxyOrganizationName);
+
 
     // 子客企业员工/经办人OpenId(OperatorOpenId):简称员工/经办人OpenId。对应通用ProxyOperator中的参数OpenId。
     // 是平台企业自定义,对子客企业员的唯一标识。
@@ -39,7 +47,10 @@ public class WeChatConfig {
     // (比如,可以使用经办人企业名+员工身份证的hash值,需要平台企业保存)
     // 最大64位字符串
     //固定为DigestUtils.sha256Hex("吴志根15669363739"); 超级管理员的openid
-    public static final String SuperProxyOperatorOpenId = "9b5a5bf63b08ca186d47dadb2b04180bf917cee4e4b2d539704ae8e85b5933c7";
+    public static final String SuperProxyOperatorOpenId = DigestUtils.sha256Hex(ProxyOrganizationName + "吴志根" + "15669363739");
+
+    //经办人
+    public static final String organizationOpenId = DigestUtils.sha256Hex(ProxyOrganizationName + "顾曙佳" + "13511382195");
 
     // ServerSignSealId 企业方静默签用的印章Id,电子签控制台印章模块获取
     public static String ServerSignSealId = "****************";
@@ -48,11 +59,11 @@ public class WeChatConfig {
     public static String ServerSignOrgName = "****************";
 
     // EndPoint API域名,现网使用 essbasic.tencentcloudapi.com
-    public static String EndPoint = "essbasic.test.ess.tencent.cn";
+    public static String EndPoint = "essbasic.tencentcloudapi.com";
 
     // FileServiceEndPoint 文件服务域名,现网使用 file.ess.tencent.cn
     // UploadFiles 接口使用此域名进行调用
-    public static String FileServiceEndPoint = "file.test.ess.tencent.cn";
+    public static String FileServiceEndPoint = "file.ess.tencent.cn";
 
     // TemplateId 模板ID,电子签控制台模板模块获取,仅在通过模板发起时使用
     public static final String TemplateId = "****************";

+ 5 - 5
src/custom/restcontroller/webmanage/sale/contracttask/WeChatContractUtil.java

@@ -77,7 +77,7 @@ public class WeChatContractUtil extends BaseClass {
     public static String getUserConsoleUrl(String name, String phonenumber) throws TencentCloudSDKException {
         EssbasicClient client = initClient();
         //根据姓名和手机号生成唯一的经办人OpenId(SHA256哈希)
-        String proxyOperatorOpenId = DigestUtils.sha256Hex(name + phonenumber);
+        String proxyOperatorOpenId = DigestUtils.sha256Hex(ProxyOrganizationName + name + phonenumber);
 
         //构建Agent对象,设置应用ID、子企业OpenId和经办人信息
         Agent agent = new Agent();
@@ -145,9 +145,8 @@ public class WeChatContractUtil extends BaseClass {
             // 返回的resp是一个DescribeTemplatesResponse的实例,与请求对象对应
             return client.DescribeTemplates(req);
         } catch (TencentCloudSDKException e) {
-            System.out.println(e.toString());
+            throw new RuntimeException("查询电子签模板失败[" + TemplateId + "]:" + e.getMessage());
         }
-        return null;
     }
 
     /**
@@ -283,7 +282,8 @@ public class WeChatContractUtil extends BaseClass {
      */
     public static Map<String, String[]> createFlowByTemplateDirectly(String flowName,
                                                                      String templateId,
-                                                                     FlowApproverInfo[] flowApproverInfos, String organizationOpenId, CompanyInfo companyInfo, ArrayList<String> fileBase64List) throws YosException {
+                                                                     FlowApproverInfo[] flowApproverInfos, CompanyInfo companyInfo, ArrayList<String> fileBase64List) throws YosException {
+
         Map<String, String[]> resp = new HashMap<>();
         // 设置agent参数
         Agent agent = setAgent(organizationOpenId);
@@ -532,7 +532,7 @@ public class WeChatContractUtil extends BaseClass {
     }
 
     public static void main(String[] args) {
-        String[] flowIds = {"yD3g7UUckpmzhmhtU1UyFt71fypQygwg"};
+//        String[] flowIds = {"yD3g7UUckpmzhmhtU1UyFt71fypQygwg"};
 
 
         try {

+ 3 - 3
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -2625,6 +2625,9 @@ public class Order extends Controller {
             }
         }
         dbConnect.runSqlUpdate(sqllist);
+        //通过版本更新订单表头数据
+        beans.order.Order.updateOrderWithVersion(this);
+
         //付款账户信息
         JSONArray accountclassinfos = row.getJSONArray("sa_accountclassinfos");
         //扣款的金额
@@ -2765,9 +2768,6 @@ public class Order extends Controller {
             }
         }
 
-        //通过版本更新订单表头数据
-        beans.order.Order.updateOrderWithVersion(this);
-
 //        String type = row.getString("type");
         //提交
         String status = "提交";