Sfoglia il codice sorgente

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

wu 1 settimana fa
parent
commit
4ac921eef1

+ 5 - 0
src/custom/restcontroller/R.java

@@ -7742,6 +7742,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2026042113202402 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 102 - 0
src/custom/restcontroller/webmanage/sale/contracttask/ContractTaskUtil.java

@@ -0,0 +1,102 @@
+package restcontroller.webmanage.sale.contracttask;
+
+import com.alibaba.fastjson2.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.data.Row;
+import common.data.Rows;
+import org.apache.commons.lang.StringUtils;
+
+import java.math.BigDecimal;
+
+public class ContractTaskUtil {
+
+    public static void check(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow) throws YosException {
+        JSONObject content = controller.content;
+        verifyValue(content.getStringValue("license_name"), "营业执照名称");
+        verifyValue(content.getStringValue("legal_rep"), "法人");
+        verifyValue(content.getStringValue("mobile"), "电话");
+        verifyValue(content.getStringValue("phonenumber"), "手机号");
+        verifyValue(content.getStringValue("taxno"), "税号");
+        verifyValue(content.getStringValue("license_address"), "营业执照地址");
+        verifyValue(content.getStringValue("presalesphonenumber"), "售前电话");
+        verifyValue(content.getStringValue("aftersalesphonenumber"), "售后电话");
+        verifyValue(content.getStringValue("paymans"), "备案汇款人");
+        verifyValue(content.getStringValue("idcard"), "身份证");
+        verifyValue(enterpriseRow.getString("province"), "省");
+        verifyValue(enterpriseRow.getString("city"), "市");
+        verifyValue(enterpriseRow.getString("county"), "县");
+        verifyValue(agentRow.getString("salearea"), "营销区域");
+        verifyValue(agentRow.getString("agentnum"), "经销商编码");
+        verifyValue(taskmxRow.getString("begindate"), "开始期限");
+        verifyValue(taskmxRow.getString("enddate"), "结束期限");
+    }
+
+    public static CompanyInfo getCompanyInfo(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow, Long year, BigDecimal securitydeposit) throws YosException {
+        JSONObject content = controller.content;
+        CompanyInfo companyInfo = new CompanyInfo();
+        companyInfo.setBillno(year + agentRow.getString("agentnum"));
+        companyInfo.setLicensename(content.getStringValue("license_name"));
+        companyInfo.setTaxno(content.getStringValue("taxno"));
+        companyInfo.setLicenseaddress(content.getStringValue("license_address"));
+        companyInfo.setLegalrep(content.getStringValue("legal_rep"));
+        companyInfo.setMobile(content.getStringValue("mobile"));
+        companyInfo.setPhonenumber(content.getStringValue("phonenumber"));
+        companyInfo.setPresalesphonenumber(content.getStringValue("presalesphonenumber"));
+        companyInfo.setAftersalesphonenumber(content.getStringValue("aftersalesphonenumber"));
+        companyInfo.setPaymans(content.getStringValue("paymans"));
+        companyInfo.setIdcard(content.getStringValue("idcard"));
+        companyInfo.setProvince(enterpriseRow.getString("province"));
+        companyInfo.setCity(enterpriseRow.getString("city"));
+        companyInfo.setCounty(enterpriseRow.getString("county"));
+        companyInfo.setBegindate(taskmxRow.getString("begindate"));
+        companyInfo.setEnddate(taskmxRow.getString("enddate"));
+        companyInfo.setAreaname(agentRow.getString("salearea"));
+        companyInfo.setSecuritydeposit(securitydeposit.toPlainString());
+        companyInfo.setTaskmoney(getTaskMoney(taskmxRow).toPlainString());
+        return companyInfo;
+    }
+
+
+    public static void verifyValue(String value, String info) throws YosException {
+        if (StringUtils.isBlank(value)) {
+            throw new YosException(false, info + "不能为空");
+        }
+    }
+
+    public static Row getEnterpriseRow(Controller controller, Long sys_enterpriseid) throws YosException {
+        Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sys_enterprise WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid='" + controller.siteid + "'");
+        if (rows.isEmpty()) {
+            throw new YosException(false, "企业不存在");
+        }
+        return rows.getRow(0);
+    }
+
+    public static Row getAgentRow(Controller controller, Long sa_agentsid) throws YosException {
+        Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sa_agents WHERE sa_agentsid =" + sa_agentsid + " and siteid='" + controller.siteid + "'");
+        if (rows.isEmpty()) {
+            throw new YosException(false, "经销商不存在");
+        }
+        return rows.getRow(0);
+    }
+
+    //查询保证金
+    public static BigDecimal getSecurityDeposit(Controller controller, Long sys_enterpriseid) throws YosException {
+        Rows rows = controller.dbConnect.runSqlQuery("select t1.balance from sa_accountbalance t1 " +
+                "INNER JOIN sa_accountclass t2 ON t2.sa_accountclassid=t1.sa_accountclassid " +
+                "WHERE t2.accountno='02' and t1.sys_enterpriseid=" + sys_enterpriseid);
+        if (rows.isEmpty()) {
+            throw new YosException(false, "保证金不存在");
+        }
+        return rows.getRow(0).getBigDecimal("balance");
+    }
+
+    public static BigDecimal getTaskMoney(Row taskmxRow) throws YosException {
+        BigDecimal y1 = taskmxRow.getBigDecimal("y1");
+        if (y1.compareTo(BigDecimal.ZERO) == 0) {
+            throw new YosException(false, "请设置季度任务金额");
+        }
+        return y1;
+    }
+
+}

+ 6 - 8
src/custom/restcontroller/webmanage/sale/contracttask/EsignContractTask.java

@@ -10,6 +10,8 @@ import common.data.*;
 import lombok.experimental.Delegate;
 import restcontroller.R;
 
+import java.math.BigDecimal;
+
 /**
  * 电子签合同任务
  */
@@ -122,14 +124,10 @@ public class EsignContractTask extends Controller {
         if (rows1.isNotEmpty()) {
             return getErrReturnObject().setErrMsg("请完善合同期限").toString();
         }
-        Rows rows2 = dbConnect.runSqlQuery("SELECT * from sa_esign_contract_taskmx WHERE sa_esign_contract_taskid=" + sa_esign_contract_taskid);
-        for (Row row : rows2) {
-            Long sys_enterpriseid = row.getLong("sys_enterpriseid");
-            Long year = rows.get(0).getLong("year");
-            Rows targetRows = dbConnect.runSqlQuery("SELECT * from sa_salestarget WHERE year=" + year + " and sys_enterpriseid='" + sys_enterpriseid + "' and type='季'");
-            if (targetRows.isEmpty()) {
-                return getErrReturnObject().setErrMsg("请完善经销商任务值").toString();
-            }
+
+        Rows rows2 = dbConnect.runSqlQuery("SELECT * from sa_esign_contract_taskmx WHERE sa_esign_contract_taskid=" + sa_esign_contract_taskid + " and y1=0");
+        if (rows2.isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("请完善经销商季度任务金额").toString();
         }
 
 

+ 92 - 76
src/custom/restcontroller/webmanage/sale/contracttask/EsignContractTaskMX.java

@@ -2,6 +2,7 @@ package restcontroller.webmanage.sale.contracttask;
 
 import beans.attachment.Attachment;
 import beans.datacontrllog.DataContrlLog;
+import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.tencentcloudapi.essbasic.v20210526.models.FlowApproverInfo;
@@ -16,6 +17,7 @@ import org.apache.commons.lang.StringUtils;
 import org.camunda.bpm.container.impl.deployment.Attachments;
 import restcontroller.R;
 
+import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -69,6 +71,7 @@ public class EsignContractTaskMX extends Controller {
             insertSQL.setValue("license_address", license_address);
             insertSQL.setValue("legal_rep", enterpriseRow.getString("contact"));
             insertSQL.setValue("mobile", enterpriseRow.getString("telephone"));
+            insertSQL.setValue("idcard", enterpriseRow.getString("idcard"));
             insertSQL.setValue("sa_esign_contract_taskid", sa_esign_contract_taskid);
             sqlList.add(insertSQL.getSQL());
             sqlList.add(DataContrlLog.createLog(this, "sa_esign_contract_task", sa_esign_contract_taskid, "添加", "添加经销商【" + enterprisename + "】成功").getSQL());
@@ -173,19 +176,56 @@ public class EsignContractTaskMX extends Controller {
         return getSucReturnObject().toString();
     }
 
+    @API(title = "电子签合同任务明细-修改季度任务金额", apiversion = R.ID2026042113202402.v1.class)
+    public String changeTaskMoney() throws YosException {
+
+        JSONArray sa_esign_contract_taskmxids = content.getJSONArray("sa_esign_contract_taskmxids");
+        BigDecimal s1 = content.getBigDecimal("s1");
+        BigDecimal s2 = content.getBigDecimal("s2");
+        BigDecimal s3 = content.getBigDecimal("s3");
+        BigDecimal s4 = content.getBigDecimal("s4");
+        BigDecimal y1 = s1.add(s2).add(s3).add(s4);
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_esign_contract_taskmx");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setWhere("sa_esign_contract_taskmxid", sa_esign_contract_taskmxids);
+        updateSQL.setValue("s1", s1);
+        updateSQL.setValue("s2", s2);
+        updateSQL.setValue("s3", s3);
+        updateSQL.setValue("s4", s4);
+        updateSQL.setValue("y1", y1);
+        sqlList.add(updateSQL.getSQL());
+
+        for (Object obj : sa_esign_contract_taskmxids) {
+            Long sa_esign_contract_taskmxid = Long.parseLong(obj.toString());
+            Rows rows = dbConnect.runSqlQuery("SELECT * FROM sa_esign_contract_taskmx WHERE sa_esign_contract_taskmxid=" + sa_esign_contract_taskmxid);
+            if (rows.isNotEmpty()) {
+                Long sa_agentsid = rows.get(0).getLong("sa_agentsid");
+                Long sa_esign_contract_taskid = rows.get(0).getLong("sa_esign_contract_taskid");
+                Rows agentRows = dbConnect.runSqlQuery("SELECT * FROM sv_agents WHERE sa_agentsid=" + sa_agentsid);
+                String enterprisename = agentRows.get(0).getString("enterprisename");
+                sqlList.add(DataContrlLog.createLog(this, "sa_esign_contract_task", sa_esign_contract_taskid, "修改季度任务金额",
+                        "修改经销商【" + enterprisename + "】季度任务金为:第一季度(万元):" + s1 + ",第二季度(万元):" + s2 + ",第三季度(万元):" + s3 + ",第四季度(万元):" + s4).getSQL());
+            }
+        }
+
+        dbConnect.runSqlUpdate(sqlList);
+
+
+        return getSucReturnObject().toString();
+    }
+
 
     @API(title = "电子签合同任务明细-明细列表", apiversion = R.ID2026041315403802.v1.class)
     public String list() throws YosException {
 
         Long sa_esign_contract_taskid = content.getLongValue("sa_esign_contract_taskid");
-        Long year = 0L;
-        Rows taskrows = dbConnect.runSqlQuery("SELECT * FROM sa_esign_contract_task WHERE sa_esign_contract_taskid=" + sa_esign_contract_taskid);
-        if (taskrows.isNotEmpty()) {
-            year = taskrows.get(0).getLong("year");
-        }
 
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_esign_contract_taskmx",
-                "sa_esign_contract_taskmxid", "status", "approvestatus", "license_address", "phonenumber", "legal_rep", "begindate", "enddate", "flowid").setTableAlias("t1");
+                "sa_esign_contract_taskmxid", "status", "approvestatus", "license_address", "phonenumber", "legal_rep", "begindate", "enddate", "flowid",
+                "s1", "s2", "s3", "s4", "y1").setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t2", "t1.siteid = t2.siteid and t1.sa_agentsid=t2.sa_agentsid",
                 "sys_enterpriseid", "agentnum");
         querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t3.siteid = t2.siteid and t3.sys_enterpriseid = t2.sys_enterpriseid",
@@ -197,48 +237,12 @@ public class EsignContractTaskMX extends Controller {
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 
-        QuerySQL targetQuerySQL = SQLFactory.createQuerySQL(this, "sa_salestarget",
-                "sys_enterpriseid", "point", "target_l");
-        targetQuerySQL.setWhere("year", year);
-        targetQuerySQL.setWhere("type='季'");
-        targetQuerySQL.setWhere("sys_enterpriseid", rows.toArrayList("sys_enterpriseid"));
-
-        RowsMap targetRowsMap = targetQuerySQL.query().toRowsMap("sys_enterpriseid");
         for (Row row : rows) {
-            Long sys_enterpriseid = row.getLong("sys_enterpriseid");
-            if (targetRowsMap.containsKey(sys_enterpriseid)) {
-                Rows targetRows = targetRowsMap.get(sys_enterpriseid);
-                BigDecimal y1 = BigDecimal.ZERO;
-                for (Row targetRow : targetRows) {
-                    int point = targetRow.getInteger("point");
-                    y1 = y1.add(targetRow.getBigDecimal("target_l"));
-                    switch (point) {
-                        case 1:
-                            row.put("s1", targetRow.getBigDecimal("target_l"));
-                            break;
-                        case 2:
-                            row.put("s2", targetRow.getBigDecimal("target_l"));
-                            break;
-                        case 3:
-                            row.put("s3", targetRow.getBigDecimal("target_l"));
-                            break;
-                        case 4:
-                            row.put("s4", targetRow.getBigDecimal("target_l"));
-                            break;
-                    }
-                    row.put("y1", y1);
-                }
-            }
             row.putIfAbsent("s1", 0);
             row.putIfAbsent("s2", 0);
             row.putIfAbsent("s3", 0);
             row.putIfAbsent("s4", 0);
             row.putIfAbsent("y1", 0);
-            String flowid = row.getString("flowid");
-            if (!StringUtils.isBlank(flowid)) {
-                row.put("downloadurl", WeChatContractUtil.describeFileUrls(flowid));
-            }
-            row.putIfAbsent("downloadurl", "");
         }
 
         return getSucReturnObject().setData(rows).toString();
@@ -277,55 +281,57 @@ public class EsignContractTaskMX extends Controller {
     public String edit() throws YosException {
 
         Long sa_esign_contract_taskmxid = content.getLongValue("sa_esign_contract_taskmxid");
-        Rows rows = dbConnect.runSqlQuery("SELECT * FROM sa_esign_contract_taskmx WHERE sa_esign_contract_taskmxid=" + sa_esign_contract_taskmxid);
-
-        if (rows.isEmpty()) {
+        Rows taskmxrows = dbConnect.runSqlQuery("SELECT * FROM sa_esign_contract_taskmx WHERE sa_esign_contract_taskmxid=" + sa_esign_contract_taskmxid);
+        if (taskmxrows.isEmpty()) {
             return getErrReturnObject().setErrMsg("合同不存在").toString();
         }
-        String status = rows.get(0).getString("status");
+        Row taskmxrow = taskmxrows.get(0);
+        Long sa_agentsid = taskmxrow.getLong("sa_agentsid");
+        Long sys_enterpriseid = taskmxrow.getLong("sys_enterpriseid");
+        String status = taskmxrow.getString("status");
+        Long sa_esign_contract_taskid = taskmxrow.getLong("sa_esign_contract_taskid");
+
         String[] statuslist = new String[]{"合同创建", "合同签署中", "合同签署完成", "合同即将过期"};
         if (ArrayUtils.contains(statuslist, status)) {
             return getErrReturnObject().setErrMsg("当前状态不支持确认合同内容").toString();
         }
-        Long sa_esign_contract_taskid = rows.get(0).getLong("sa_esign_contract_taskid");
 
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_esign_contract_template", "*").setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_esign_contract_task", "t2", "t1.sa_esign_contract_templateid=t2.sa_esign_contract_templateid");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_esign_contract_task", "t2", "t1.sa_esign_contract_templateid=t2.sa_esign_contract_templateid",
+                "year");
         querySQL.setWhere("t2.sa_esign_contract_taskid", sa_esign_contract_taskid);
         Rows templaterows = querySQL.query();
         if (templaterows.isEmpty()) {
             return getErrReturnObject().setErrMsg("合同模板不存在").toString();
         }
+        Long year = templaterows.get(0).getLong("year");
+        Row agentRow = ContractTaskUtil.getAgentRow(this, sa_agentsid);
+        Row enterpriseRow = ContractTaskUtil.getEnterpriseRow(this, sys_enterpriseid);
+        //校验参数
+        ContractTaskUtil.check(this, agentRow, enterpriseRow, taskmxrow);
+        BigDecimal securitydeposit = ContractTaskUtil.getSecurityDeposit(this, sys_enterpriseid);
 
         String license_name = content.getStringValue("license_name");
         String legal_rep = content.getStringValue("legal_rep");
-        String mobile = content.getStringValue("mobile");
         String phonenumber = content.getStringValue("phonenumber");
-        String taxno =  content.getStringValue("taxno");
-        String license_address = content.getStringValue("license_address");
 
         //构建需要上传的模板传递的数据
-        CompanyInfo companyInfo = new CompanyInfo();
-        companyInfo.setBillno("");
-        companyInfo.setLicensename(license_name);
-        companyInfo.setTaxno(taxno);
-        companyInfo.setLicenseaddress(license_address);
-        companyInfo.setLegalrep(legal_rep);
-        companyInfo.setMobile(mobile);
-        companyInfo.setPhonenumber(phonenumber);
+        CompanyInfo companyInfo = ContractTaskUtil.getCompanyInfo(this, enterpriseRow, agentRow, taskmxrow, year, securitydeposit);
 
         UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_esign_contract_taskmx");
         updateSQL.setSiteid(siteid);
         updateSQL.setUniqueid(sa_esign_contract_taskmxid);
         updateSQL.setValue("license_name", license_name);
-        updateSQL.setValue("taxno", taxno);
-        updateSQL.setValue("license_address", license_address);
-        updateSQL.setValue("legal_rep", license_address);
-        updateSQL.setValue("mobile", mobile);
+        updateSQL.setValue("legal_rep", legal_rep);
         updateSQL.setValue("phonenumber", phonenumber);
+        updateSQL.setValue("taxno", content.getStringValue("taxno"));
+        updateSQL.setValue("license_address", content.getStringValue("license_address"));
+        updateSQL.setValue("mobile", content.getStringValue("mobile"));
         updateSQL.setValue("presalesphonenumber", content.getStringValue("presalesphonenumber"));
         updateSQL.setValue("aftersalesphonenumber", content.getStringValue("aftersalesphonenumber"));
         updateSQL.setValue("paymans", content.getStringValue("paymans"));
+        updateSQL.setValue("idcard", content.getStringValue("idcard"));
+        updateSQL.setValue("companyinfo", JSON.toJSON(companyInfo));
         updateSQL.update();
         DataContrlLog.createLog(this, "sa_esign_contract_task", sa_esign_contract_taskid, "合同确认", "合同内容确认成功").insert();
 
@@ -340,26 +346,36 @@ public class EsignContractTaskMX extends Controller {
             throw new NullPointerException("签署人不能为空");
         }
         //构造签署人信息
-        FlowApproverInfo[] flowApproverInfos = WeChatByTemplate.BuildApprovers(Arrays.asList(recipients), license_name, legal_rep,phonenumber);
+        FlowApproverInfo[] flowApproverInfos = WeChatByTemplate.BuildApprovers(Arrays.asList(recipients), license_name, legal_rep, phonenumber);
 //        String organizationOpenId = DigestUtils.sha256Hex(license_name);
 
+        ArrayList<String> fileBase64List = new ArrayList<>();
+
+        Rows attachmentRows = Attachment.get(this, "sa_esign_contract_taskmx", sa_esign_contract_taskmxid);
+        for (Row attachmentRow : attachmentRows) {
+            Long attachmentid = attachmentRow.getLong("attachmentid");
+            InputStream inputStream = getAttachmentFileInputStream(attachmentid);
+            String fileBase64 = WeChatContractUtil.convertImageFileToBase64(inputStream);
+            fileBase64List.add(fileBase64);
+        }
+
 
         // 发起合同 样例为BtoC
         Map<String, String[]> resp = wccUtil.createFlowByTemplateDirectly(flowName
-                , templateId, flowApproverInfos,WeChatConfig.SuperProxyOperatorOpenId,companyInfo);
+                , templateId, flowApproverInfos, WeChatConfig.SuperProxyOperatorOpenId, companyInfo, fileBase64List);
         int count = WeChatConfig.COUNT;
         for (int i = 0; i < count; i++) {
-            // 返回合同Id
-            System.out.println("您创建的合同id为:");
-            System.out.println(resp.get("FlowIds")[i]);
-            // 返回签署的链接
-            System.out.println("签署链接为:");
-            System.out.println(resp.get("Urls")[i]);
-            // Step 3 下载合同
-            // 返回合同下载链接
-            String url = WeChatContractUtil.describeFileUrls(resp.get("FlowIds")[i]);
-            System.out.println("请访问以下地址下载您的合同:");
-            System.out.println(url);
+//            // 返回合同Id
+//            System.out.println("您创建的合同id为:");
+//            System.out.println(resp.get("FlowIds")[i]);
+//            // 返回签署的链接
+//            System.out.println("签署链接为:");
+//            System.out.println(resp.get("Urls")[i]);
+//            // Step 3 下载合同
+//            // 返回合同下载链接
+//            String url = WeChatContractUtil.describeFileUrls(resp.get("FlowIds")[i]);
+//            System.out.println("请访问以下地址下载您的合同:");
+//            System.out.println(url);
 
             updateSQL = SQLFactory.createUpdateSQL(this, "sa_esign_contract_taskmx");
             updateSQL.setSiteid(siteid);

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

@@ -1,18 +1,17 @@
 package restcontroller.webmanage.sale.contracttask;
 
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
 import com.tencentcloudapi.common.Credential;
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
 import com.tencentcloudapi.essbasic.v20210526.EssbasicClient;
 import com.tencentcloudapi.essbasic.v20210526.models.*;
-import com.tencentcloudapi.tke.v20180525.models.Switch;
-import com.tencentcloudapi.tsf.v20180326.models.TerminateTaskFlowBatchRequest;
-import common.YosException;
 import org.apache.commons.codec.digest.DigestUtils;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -237,6 +236,39 @@ public class WeChatContractUtil {
         return urlResp.getFlowResourceUrlInfos()[0].getResourceUrlInfos()[0].getUrl();
     }
 
+    public static UploadFilesResponse uploadFiles(Agent agent, UploadFile[] uploadFile) {
+        try {
+            // 实例化一个认证对象,入参需要传入腾讯云账户SecretId,SecretKey,此处还需注意密钥对的保密
+            // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
+            Credential cred = new Credential(WeChatConfig.SecretId, WeChatConfig.SecretKey);
+            // 实例化一个http选项,可选的,没有特殊需求可以跳过
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint(FileServiceEndPoint);
+            // 实例化一个client选项,可选的,没有特殊需求可以跳过
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+            // 实例化要请求产品的client对象,clientProfile是可选的
+            EssbasicClient client = new EssbasicClient(cred, "", clientProfile);
+            // 实例化一个请求对象,每个接口都会对应一个request对象
+            UploadFilesRequest req = new UploadFilesRequest();
+
+
+            req.setAgent(agent);
+
+            req.setFileInfos(uploadFile);
+
+            req.setBusinessType("DOCUMENT");
+
+            // 返回的resp是一个UploadFilesResponse的实例,与请求对象对应
+            UploadFilesResponse resp = client.UploadFiles(req);
+            System.err.println(resp);
+            return resp;
+        } catch (TencentCloudSDKException e) {
+            System.out.println(e.toString());
+        }
+        return null;
+    }
+
     /**
      * 通过文件base64直接发起签署流程
      *
@@ -246,10 +278,27 @@ public class WeChatContractUtil {
      */
     public static Map<String, String[]> createFlowByTemplateDirectly(String flowName,
                                                                      String templateId,
-                                                                     FlowApproverInfo[] flowApproverInfos, String organizationOpenId, CompanyInfo companyInfo) {
+                                                                     FlowApproverInfo[] flowApproverInfos, String organizationOpenId, CompanyInfo companyInfo, ArrayList<String> fileBase64List) {
         Map<String, String[]> resp = new HashMap<>();
         // 设置agent参数
         Agent agent = setAgent(organizationOpenId);
+
+        // 设置uploadFile参数,这里可以修改传入数量
+        UploadFile[] uploadFiles = new UploadFile[fileBase64List.size()];
+        for (int i = 0; i < fileBase64List.size(); i++) {
+            UploadFile file = new UploadFile();
+            file.setFileBody(fileBase64List.get(i));
+            uploadFiles[i] = file;
+        }
+        // 上传文件获取fileId
+        UploadFilesResponse uploadRes = uploadFiles(agent, uploadFiles);
+
+        // fileId
+        assert uploadRes != null;
+        String[] fileId = uploadRes.getFileIds();
+
+        String fileIdsStr = String.join(",", fileId);
+
         // 创建签署流程
         // 签署数量
         int count = WeChatConfig.COUNT;
@@ -276,7 +325,7 @@ public class WeChatContractUtil {
                     BuildFormField("paymans", companyInfo.getPaymans()),
                     BuildFormField("province", companyInfo.getProvince()),
                     BuildFormField("city", companyInfo.getCity()),
-                    BuildFormField("county", companyInfo.getCounty())
+                    BuildFormField("attachment", fileIdsStr)
             });
 
         }
@@ -363,6 +412,38 @@ public class WeChatContractUtil {
         return null;
     }
 
+    /**
+     * 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
+     *
+     * @param filePath 文件路径
+     * @return FlowInfo
+     */
+    public static String convertImageFileToBase64(InputStream inputStream) {
+        byte[] buffer = null;
+        try {
+            int count = 0;
+            while (count == 0) {
+                count = inputStream.available();
+            }
+            buffer = new byte[count];
+            inputStream.read(buffer);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (inputStream != null) {
+                try {
+                    // 关闭inputStream流
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        // 对字节数组Base64编码
+        Base64.Encoder encoder = Base64.getEncoder();
+        return encoder.encodeToString(buffer);
+    }
+
     public static String getFlowStatus(String flowStatus) {
 
         switch (flowStatus) {