|
|
@@ -0,0 +1,156 @@
|
|
|
+package restcontroller.webmanage.sale.contracttask;
|
|
|
+
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
+import com.tencentcloudapi.essbasic.v20210526.models.DescribeTemplatesResponse;
|
|
|
+import com.tencentcloudapi.essbasic.v20210526.models.TemplateInfo;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import static restcontroller.webmanage.sale.contracttask.WeChatConfig.SuperProxyOperatorOpenId;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 电子签合同模板
|
|
|
+ */
|
|
|
+public class ESignContractTemplate extends Controller {
|
|
|
+
|
|
|
+
|
|
|
+ public ESignContractTemplate(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-新增", apiversion = R.ID2026041113372302.v1.class)
|
|
|
+ public String insert() throws YosException, TencentCloudSDKException {
|
|
|
+
|
|
|
+ Long sa_esign_contract_templateid = createTableID("sa_esign_contract_template");
|
|
|
+ Boolean isenable = content.getBooleanValue("isenable");
|
|
|
+
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_esign_contract_template");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sa_esign_contract_templateid);
|
|
|
+ insertSQL.setValue("name", content.getStringValue("name"));
|
|
|
+ insertSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ insertSQL.setValue("isenable", isenable);
|
|
|
+ if (isenable) {
|
|
|
+ insertSQL.setValue("enableby", username);
|
|
|
+ insertSQL.setValue("enabledate", getDateTime_Str());
|
|
|
+ } else {
|
|
|
+ insertSQL.setValue("enableby", "null");
|
|
|
+ insertSQL.setValue("enabledate", "null");
|
|
|
+ }
|
|
|
+ insertSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ insertSQL.setValue("templateid", content.getStringValue("templateid"));
|
|
|
+ insertSQL.setValue("is_deposit_required", content.getBooleanValue("is_deposit_required"));
|
|
|
+ insertSQL.insert();
|
|
|
+
|
|
|
+ DataContrlLog.createLog(this, "sa_esign_contract_template", sa_esign_contract_templateid, "新增", "新增合同模板");
|
|
|
+
|
|
|
+ content.put("sa_esign_contract_templateid", sa_esign_contract_templateid);
|
|
|
+
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-编辑", apiversion = R.ID2026041113403102.v1.class)
|
|
|
+ public String update() throws YosException, TencentCloudSDKException {
|
|
|
+
|
|
|
+ Long sa_esign_contract_templateid = content.getLong("sa_esign_contract_templateid");
|
|
|
+ boolean isenable = content.getBooleanValue("isenable");
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_esign_contract_template");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_esign_contract_templateid);
|
|
|
+ updateSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ if (isenable) {
|
|
|
+ updateSQL.setValue("isenable", 1);
|
|
|
+ updateSQL.setValue("enableby", username);
|
|
|
+ updateSQL.setValue("enabledate", getDateTime_Str());
|
|
|
+ } else {
|
|
|
+ updateSQL.setValue("isenable", 0);
|
|
|
+ updateSQL.setValue("enableby", "null");
|
|
|
+ updateSQL.setValue("enabledate", "null");
|
|
|
+ }
|
|
|
+ updateSQL.update();
|
|
|
+ DataContrlLog.createLog(this, "sa_esign_contract_template", sa_esign_contract_templateid, "编辑", "是否启用:" + isenable + ";备注:" + content.getStringValue("remarks"));
|
|
|
+
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-删除", apiversion = R.ID2026041113380802.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+ Long sa_esign_contract_templateid = content.getLong("sa_esign_contract_templateid");
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sa_esign_contract_template");
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setUniqueid(sa_esign_contract_templateid);
|
|
|
+ deleteSQL.delete();
|
|
|
+
|
|
|
+ DataContrlLog.createLog(this, "sa_esign_contract_template", sa_esign_contract_templateid, "删除", "删除成功");
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-详情", apiversion = R.ID2026041113384202.v1.class)
|
|
|
+ public String detail() throws YosException, TencentCloudSDKException {
|
|
|
+ Long sa_esign_contract_templateid = content.getLong("sa_esign_contract_templateid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_esign_contract_template", "*").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("t1.sa_esign_contract_templateid", sa_esign_contract_templateid);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ Row row = rows.isNotEmpty() ? rows.getRow(0) : new Row();
|
|
|
+
|
|
|
+ //获取电子签模板详情
|
|
|
+ WeChatContractUtil wccUtil = new WeChatContractUtil();
|
|
|
+ if (!row.getString("templateid").isEmpty()) {
|
|
|
+ DescribeTemplatesResponse resp = wccUtil.getTemplateDetail(SuperProxyOperatorOpenId, row.getString("templateid"));
|
|
|
+ row.put("templateDetail", resp.getTemplates()[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-列表", apiversion = R.ID2026041113390502.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_esign_contract_template", "*").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "电子签合同模板-选择电子签合同模板列表", apiversion = R.ID2026041113410602.v1.class)
|
|
|
+ public String chooseTemplates() throws YosException, TencentCloudSDKException {
|
|
|
+
|
|
|
+ WeChatContractUtil wccUtil = new WeChatContractUtil();
|
|
|
+ DescribeTemplatesResponse resp = wccUtil.getTemplateList(SuperProxyOperatorOpenId);
|
|
|
+ Rows rows = new Rows();
|
|
|
+ for (TemplateInfo templateInfo : resp.getTemplates()) {
|
|
|
+ Row row = new Row();
|
|
|
+ row.put("templateId", templateInfo.getTemplateId());
|
|
|
+ row.put("templateName", templateInfo.getTemplateName());
|
|
|
+ row.put("description", templateInfo.getDescription());
|
|
|
+ row.put("templateType", templateInfo.getTemplateType());
|
|
|
+ row.put("isPromoter", templateInfo.getIsPromoter());
|
|
|
+ row.put("creator", templateInfo.getCreator());
|
|
|
+ row.put("createdOn", templateInfo.getCreatedOn());
|
|
|
+ row.put("previewUrl", templateInfo.getPreviewUrl());
|
|
|
+ row.put("pdfUrl", templateInfo.getPdfUrl());
|
|
|
+ row.put("channelTemplateId", templateInfo.getChannelTemplateId());
|
|
|
+ row.put("channelTemplateName", templateInfo.getChannelTemplateName());
|
|
|
+ row.put("channelAutoSave", templateInfo.getChannelAutoSave());
|
|
|
+ row.put("templateVersion", templateInfo.getTemplateVersion());
|
|
|
+ row.put("available", templateInfo.getAvailable());
|
|
|
+ row.put("userFlowType", templateInfo.getUserFlowType());
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|