From 107e63ea3d1dd252841e934d6f483b0032e68493 Mon Sep 17 00:00:00 2001
From: 杜洪波 <1074825718@qq.com>
Date: 星期五, 20 三月 2026 16:34:30 +0800
Subject: [PATCH] 系统租户申请代码提交
---
src/main/java/com/product/saas/controller/TenantApplyController.java | 23 --
src/main/java/com/product/saas/config/SaasCode.java | 64 +++++++++
src/main/java/com/product/saas/service/TenantApplyService.java | 273 ++++++++++++++++++++++++++++++++------
src/main/java/com/product/saas/service/idel/ITenantApplyService.java | 11 +
src/main/java/com/product/saas/config/SaasConst.java | 4
5 files changed, 310 insertions(+), 65 deletions(-)
diff --git a/src/main/java/com/product/saas/config/SaasCode.java b/src/main/java/com/product/saas/config/SaasCode.java
new file mode 100644
index 0000000..10665a3
--- /dev/null
+++ b/src/main/java/com/product/saas/config/SaasCode.java
@@ -0,0 +1,64 @@
+package com.product.saas.config;
+
+import java.text.DecimalFormat;
+import java.text.Format;
+
+import com.product.common.enums.IEnum;
+import com.product.common.enums.ModuleEnum;
+import com.product.core.config.Global;
+import com.product.util.BaseUtil;
+
+public enum SaasCode implements IEnum{
+
+ // 绉熸埛鐢宠
+ TENANT_APPLY_VALID_UNIT_HAS_APPLY("绉熸埛鍗曚綅宸茬粡鐢ㄤ簬鐢宠", 1),
+ TENANT_APPLY_VALID_PHONE_HAS_APPLY("绉熸埛鎵嬫満鍙峰凡缁忕敤浜庣敵璇�", 2),
+ TENANT_APPLY_VALID_UNIT_AND_PHONE_HAS_APPLY("绉熸埛鍗曚綅鍜屾墜鏈哄彿宸茬粡鐢ㄤ簬鐢宠", 3),
+ TENANT_APPLY_VALID_INFO_FAIL("绉熸埛鐢宠淇℃伅楠岃瘉澶辫触锛�", 4),
+ TENANT_AAPLY_INFO_GET_FAIL("绉熸埛鐢宠淇℃伅璇锋眰澶辫触锛�", 5),
+ TENANT_AAPLY_INFO_SUBMIT_FAIL("绉熸埛鐢宠淇℃伅鎻愪氦澶辫触锛�", 6),
+ TENANT_AAPLY_INFO_FLOW_TASK_ERROR("绉熸埛鐢宠淇℃伅娴佺▼鏁版嵁涓嶅瓨鍦�", 7),
+ TENANT_AAPLY_INFO_CANCEL_FAIL("绉熸埛鐢宠淇℃伅鎾ゆ秷澶辫触锛�", 8),
+ TENANT_APPLY_LICENSE_DATA_NO_EXIST("绉熸埛鐢宠License鏁版嵁涓嶅瓨鍦�", 9),
+ TENANT_APPLY_LICENSE_FILE_NO_EXIST("绉熸埛鐢宠License鏂囦欢涓嶅瓨鍦�", 10),
+ TENANT_APPLY_LICENSE_FILE_COPY_FAIL("绉熸埛鐢宠License鏂囦欢COPY澶辫触", 11),
+
+ // 绉熸埛淇℃伅
+ TENANT_INFO_GET_LIST_FAIL("绉熸埛淇℃伅鍒楄〃鏌ヨ澶辫触", 12),
+ ;
+
+ private String text;
+ private int value;
+
+ private SaasCode(String text, int value) {
+ this.text = text;
+ this.value = value;
+ }
+
+ public String getText() {
+ try {
+ //浣跨敤姝e垯鍖归厤text涓殑鐗规畩琛ㄨ揪寮忎互{&寮�澶达紝&}缁撳熬锛岃幏鍙栧埌鍏朵腑鐨勫唴瀹�
+ String regex = "\\{&(.+?)&\\}";
+ String result = this.text;
+ if (this.text.matches(regex)) {
+ result = this.text.replaceAll(regex, "$1");
+ }
+ String defaultValue = null;
+ //鎴彇result涓互(寮�澶达紝)缁撳熬鐨勫唴瀹�
+ if (result.contains("(") && result.contains(")")) {
+ defaultValue = result.substring(0, result.indexOf("("));
+ }
+ //鍘绘帀result涓� (寮�澶达紝)缁撳熬鐨勫唴瀹� 鍖呭惈鎷彿
+ result = result.replaceAll("\\(.*?\\)", "");
+ //鑾峰彇绯荤粺閰嶇疆涓殑鍊�
+ return BaseUtil.ifNull(Global.getSystemConfig(result, defaultValue), text);
+ } catch (Exception e) {
+ return text;
+ }
+ }
+
+ public String getValue() {
+ Format format = new DecimalFormat("000");
+ return ModuleEnum.SAAS.getValue() + format.format(this.value);
+ }
+}
diff --git a/src/main/java/com/product/saas/config/SaasConst.java b/src/main/java/com/product/saas/config/SaasConst.java
index 812356c..67fe569 100644
--- a/src/main/java/com/product/saas/config/SaasConst.java
+++ b/src/main/java/com/product/saas/config/SaasConst.java
@@ -1,6 +1,8 @@
package com.product.saas.config;
-public class SaasConst {
+import com.product.admin.config.CmnConst;
+
+public class SaasConst extends CmnConst{
// 鐗规畩甯搁噺
public static final String FLOW_TENANT_APPLY = "77af46c9-91cf-44ee-924c-1d0df8c324f2"; //绉熸埛鐢宠娴佺▼鍞竴鍊�
diff --git a/src/main/java/com/product/saas/controller/TenantApplyController.java b/src/main/java/com/product/saas/controller/TenantApplyController.java
index 352ae7f..b49fb36 100644
--- a/src/main/java/com/product/saas/controller/TenantApplyController.java
+++ b/src/main/java/com/product/saas/controller/TenantApplyController.java
@@ -7,7 +7,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
-import com.product.admin.config.SystemCode;
+import com.product.saas.config.SaasCode;
import com.product.saas.service.TenantApplyService;
import com.product.saas.service.idel.ITenantApplyService;
import com.product.core.config.CoreConst;
@@ -15,7 +15,6 @@
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
-import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.file.service.FileManagerService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
@@ -47,13 +46,10 @@
return OK();
} catch (BaseException e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
return this.error(e.getCode(), e.getMessageInfo());
} catch (Exception e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(SystemCode.DELETE_ADMINISTRATIVE_DIVISION_FAIL);
+ return error(SaasCode.TENANT_APPLY_VALID_INFO_FAIL.getValue(), SaasCode.TENANT_APPLY_VALID_INFO_FAIL.getText() + e.getMessage());
}
}
@@ -70,13 +66,10 @@
return OK_List(tenantApplyService.getTenantApplyByPhone(fse.getString("applicant_phone")));
} catch (BaseException e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
return this.error(e.getCode(), e.getMessageInfo());
} catch (Exception e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(SystemCode.DELETE_ADMINISTRATIVE_DIVISION_FAIL);
+ return error(SaasCode.TENANT_AAPLY_INFO_GET_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_GET_FAIL.getText() + e.getMessage());
}
}
@@ -107,13 +100,10 @@
return OK();
} catch (BaseException e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
return this.error(e.getCode(), e.getMessageInfo());
} catch (Exception e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(SystemCode.DELETE_ADMINISTRATIVE_DIVISION_FAIL);
+ return error(SaasCode.TENANT_AAPLY_INFO_SUBMIT_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_SUBMIT_FAIL.getText() + e.getMessage());
}
}
@@ -133,13 +123,10 @@
return OK();
} catch (BaseException e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
return this.error(e.getCode(), e.getMessageInfo());
} catch (Exception e) {
e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(SystemCode.DELETE_ADMINISTRATIVE_DIVISION_FAIL);
+ return error(SaasCode.TENANT_AAPLY_INFO_CANCEL_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_CANCEL_FAIL.getText() + e.getMessage());
}
}
}
diff --git a/src/main/java/com/product/saas/service/TenantApplyService.java b/src/main/java/com/product/saas/service/TenantApplyService.java
index 00a424e..3fa25e7 100644
--- a/src/main/java/com/product/saas/service/TenantApplyService.java
+++ b/src/main/java/com/product/saas/service/TenantApplyService.java
@@ -1,25 +1,45 @@
package com.product.saas.service;
+import java.io.File;
+import java.util.Date;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.product.admin.config.CmnConst;
+import com.product.admin.service.CodeService;
import com.product.admin.service.LoginAuthService;
+import com.product.core.config.Global;
import com.product.core.dao.BaseDao;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.transfer.Transactional;
import com.product.file.service.FileManagerService;
+import com.product.module.sys.service.UserService;
+import com.product.saas.config.SaasCode;
import com.product.saas.config.SaasConst;
import com.product.saas.service.idel.ITenantApplyService;
import com.product.tool.flow.service.FlowService;
import com.product.util.BaseUtil;
+import cn.hutool.core.io.FileUtil;
+
+/**
+ * 绉熸埛鐢宠
+ *
+ */
@Component
public class TenantApplyService extends AbstractBaseService implements ITenantApplyService{
@Autowired
BaseDao baseDao;
+
+ @Autowired
+ CodeService codeService;
+
+ @Autowired
+ UserService userService;
@Autowired
FlowService flowService;
@@ -45,25 +65,24 @@
// 楠岃瘉淇℃伅鏄惁鍖归厤
FieldSetEntity fseTenantByPhone = baseDao.getFieldSetEntityByFilter(SaasConst.PRODUCT_SYS_TENANT_APPLY, "applicant_phone = ?", new Object[] {phone}, false);
FieldSetEntity fseTenantByName = baseDao.getFieldSetEntityByFilter(SaasConst.PRODUCT_SYS_TENANT_APPLY, "unit_name = ?", new Object[] {unitName}, false);
- if (fseTenantByPhone == null) {
- if(fseTenantByName == null) {
- // 閮戒笉瀛樺湪锛岄獙璇侀�氳繃
- return true;
- } else {
- throw new BaseException("鍗曚綅宸茬粡琚娇鐢�", "鍗曚綅宸茬粡琚娇鐢�");
- }
- } else {
- if(fseTenantByName == null) {
- throw new BaseException("鎵嬫満鍙峰凡缁忚浣跨敤", "鎵嬫満鍙峰凡缁忚浣跨敤");
- } else {
- if (fseTenantByName.getUUID().equals(fseTenantByPhone.getUUID())) {
- // 閮藉瓨鍦ㄤ簬鍚屼竴鏉℃暟鎹紝楠岃瘉閫氳繃
- return true;
- } else {
- throw new BaseException("鎵嬫満鍙峰拰鍗曚綅宸茬粡琚娇鐢�", "鎵嬫満鍙峰拰鍗曚綅宸茬粡琚娇鐢�");
- }
- }
- }
+ // 鎯呭喌1锛氭墜鏈哄彿鍜屽崟浣嶅悕閮戒笉瀛樺湪 -> 閫氳繃
+ if (fseTenantByPhone == null && fseTenantByName == null) {
+ return true;
+ }
+ // 鎯呭喌2锛氬彧瀛樺湪鎵嬫満鍙� -> 鎵嬫満鍙峰凡鐢宠
+ if (fseTenantByPhone != null && fseTenantByName == null) {
+ throw new BaseException(SaasCode.TENANT_APPLY_VALID_UNIT_HAS_APPLY.getValue(), SaasCode.TENANT_APPLY_VALID_UNIT_HAS_APPLY.getText());
+ }
+ // 鎯呭喌3锛氬彧瀛樺湪鍗曚綅鍚� -> 鍗曚綅宸茬敵璇�
+ if (fseTenantByPhone == null && fseTenantByName != null) {
+ throw new BaseException(SaasCode.TENANT_APPLY_VALID_PHONE_HAS_APPLY.getValue(), SaasCode.TENANT_APPLY_VALID_PHONE_HAS_APPLY.getText());
+ }
+ // 鎯呭喌4锛氶兘瀛樺湪 -> 妫�鏌ユ槸鍚︽槸鍚屼竴鏉¤褰�
+ if (fseTenantByPhone.getUUID().equals(fseTenantByName.getUUID())) {
+ return true;
+ }
+ // 鎯呭喌5锛氶兘瀛樺湪浣嗕笉鏄悓涓�鏉¤褰� -> 鎵嬫満鍙峰拰鍗曚綅鍚嶉兘宸茬敵璇�
+ throw new BaseException(SaasCode.TENANT_APPLY_VALID_UNIT_AND_PHONE_HAS_APPLY.getValue(), SaasCode.TENANT_APPLY_VALID_UNIT_AND_PHONE_HAS_APPLY.getText());
}
/**
@@ -83,6 +102,7 @@
/**
* 淇濆瓨绉熸埛鐢宠
+ * approval_sign锛氶�佸鏍囪瘑锛�0锛氫繚瀛橈紱1锛氶�佸鎴栨縺娲伙級
* @param fse
* @return
*/
@@ -92,42 +112,203 @@
// 鑾峰彇閫佸鏍囧織
String flowSign = fse.getString("approval_sign");
if (!BaseUtil.strIsNull(flowSign) || "1".equals(flowSign)) {
+ // 淇濆瓨绉熸埛淇℃伅
fse.setValue("apply_status", 2);
+ fse.setValue("is_passed", 0);
baseDao.saveFieldSetEntity(fse);
- // 鑾峰彇閫佸寮�濮嬬殑鍚庝竴涓妭鐐逛俊鎭�
- StringBuilder sql = new StringBuilder();
- sql.append("SELECT * FROM product_sys_flow_node \n");
- sql.append("WHERE uuid IN ( \n");
- sql.append(" SELECT target_uuid FROM product_sys_flow_link \n");
- sql.append(" WHERE source_uuid IN ( \n");
- sql.append(" SELECT uuid FROM product_sys_flow_node \n");
- sql.append(" WHERE module_type = 1 AND flow_uuid IN ( \n");
- sql.append(" SELECT uuid FROM product_sys_flow_model \n");
- sql.append(" WHERE type_code = ? \n");
- sql.append(" ) \n");
- sql.append(" ) \n");
- sql.append(") \n");
- FieldSetEntity fseFlowNode = baseDao.getFieldSetEntityBySQL(sql.toString(), new Object[] {SaasConst.FLOW_TENANT_APPLY}, false);
- if (fseFlowNode == null || BaseUtil.strIsNull(fseFlowNode.getString("default_users"))) {
- throw new BaseException("绉熸埛鐢宠娴佺▼鏈夎", "绉熸埛鐢宠娴佺▼鏈夎");
+
+ // 鏌ヨ閫佸璁板綍
+ FieldSetEntity fseTask = baseDao.getFieldSetEntityByFilter("product_sys_flow_task", "table_name = 'product_sys_tenant_apply' AND record_uuid = ?", new Object[] {fse.getUUID()}, false);
+ if (fseTask == null) {
+ // 鑾峰彇閫佸寮�濮嬬殑鍚庝竴涓妭鐐逛俊鎭�
+ StringBuilder sql = new StringBuilder();
+ sql.append("SELECT * FROM product_sys_flow_node \n");
+ sql.append("WHERE uuid IN ( \n");
+ sql.append(" SELECT target_uuid FROM product_sys_flow_link \n");
+ sql.append(" WHERE source_uuid IN ( \n");
+ sql.append(" SELECT uuid FROM product_sys_flow_node \n");
+ sql.append(" WHERE module_type = 1 AND flow_uuid IN ( \n");
+ sql.append(" SELECT uuid FROM product_sys_flow_model \n");
+ sql.append(" WHERE type_code = ? \n");
+ sql.append(" ) \n");
+ sql.append(" ) \n");
+ sql.append(") \n");
+ FieldSetEntity fseFlowNode = baseDao.getFieldSetEntityBySQL(sql.toString(), new Object[] {SaasConst.FLOW_TENANT_APPLY}, false);
+ if (fseFlowNode == null || BaseUtil.strIsNull(fseFlowNode.getString("default_users"))) {
+ throw new BaseException("绉熸埛鐢宠娴佺▼鏈夎", "绉熸埛鐢宠娴佺▼鏈夎");
+ }
+ // 灏佽閫佸鍙傛暟
+ FieldSetEntity fseFlowTask = new FieldSetEntity(SaasConst.PRODUCT_SYS_TENANT_APPLY);
+ fseFlowTask.setValue("uuid", fse.getUUID());
+ fseFlowTask.setValue("type_code", SaasConst.FLOW_TENANT_APPLY);
+ fseFlowTask.setValue("accepters", fseFlowNode.getString("default_users"));
+ fseFlowTask.setValue("flow_title", "绉熸埛鐢宠-" + fse.getString("unit_name"));
+ // 鎵ц閫佸
+ flowService.autoSendFlow(fseFlowTask);
+ } else {
+ // 婵�娲婚�佸浠诲姟
+ FieldSetEntity fseTaskDetail = new FieldSetEntity("product_sys_flow_detail");
+ fseTaskDetail.setValue("task_uuid", fseTask.getUUID());
+ fseTaskDetail.setValue("is_sub_flow", "0");
+ fseTaskDetail.setValue("opinion", "绉熸埛鎾ゅ洖鍚庨噸鏂版彁浜�");
+ flowService.activate(fseTaskDetail);
}
- // 灏佽閫佸鍙傛暟
- FieldSetEntity fseFlowTask = new FieldSetEntity(SaasConst.PRODUCT_SYS_TENANT_APPLY);
- fseFlowTask.setValue("uuid", fse.getUUID());
- fseFlowTask.setValue("type_code", SaasConst.FLOW_TENANT_APPLY);
- fseFlowTask.setValue("accepters", fseFlowNode.getString("default_users"));
- fseFlowTask.setValue("flow_title", "绉熸埛鐢宠-" + fse.getString("unit_name"));
- // 鎵ц閫佸
- flowService.autoSendFlow(fseFlowTask);
return true;
} else {
fse.setValue("apply_status", 1);
- // 淇濆瓨璁板綍
+ fse.setValue("is_passed", 0);
+ // 淇濆瓨绉熸埛淇℃伅
return baseDao.saveFieldSetEntity(fse);
}
}
-
+
+ /**
+ * 鎾ら攢绉熸埛鐢宠
+ * @param fse
+ * @return
+ */
+ @Override
+ @Transactional
public boolean cancelTenantApply(FieldSetEntity fse){
- return true;
+ // 鑾峰彇瀵瑰簲娴佺▼浠诲姟
+ FieldSetEntity fseTask = baseDao.getFieldSetEntityByFilter("product_sys_flow_task", "table_name = 'product_sys_tenant_apply' AND record_uuid = ?", new Object[] {fse.getUUID()}, false);
+ if (fseTask == null) {
+ throw new BaseException(SaasCode.TENANT_AAPLY_INFO_FLOW_TASK_ERROR.getValue(), SaasCode.TENANT_AAPLY_INFO_FLOW_TASK_ERROR.getText());
+ }
+ // 缁堟娴佺▼
+ flowService.stop(fseTask);
+ // 鏍囪鐢宠鏁版嵁涓烘湭閫佸
+ return baseDao.executeUpdate("UPDATE product_sys_tenant_apply SET apply_status = 1 WHERE applicant_phone = ? AND unit_name = ? ",
+ new Object[] {fse.getString("applicant_phone"), fse.getString("unit_name")});
+ }
+
+ /**
+ * 鍒锋柊鐢宠鍗曠姸鎬�(娴佺▼澶勭悊鍣ㄨ皟鐢�)
+ * @param fseApply
+ */
+ public void refreshApplyStatus(FieldSetEntity fseApply) {
+ if ("1".equals(fseApply.getString("is_passed"))) {
+ // 瀹℃牳閫氳繃
+ baseDao.executeUpdate("UPDATE product_sys_tenant_apply SET apply_status = 3 WHERE uuid = ?", new Object[] {fseApply.getUUID()});
+ } else {
+ // 瀹℃牳澶辫触
+ baseDao.executeUpdate("UPDATE product_sys_tenant_apply SET apply_status = 4 WHERE uuid = ?", new Object[] {fseApply.getUUID()});
+ }
+ }
+
+ /**
+ * 鐢宠瀹屾垚
+ * @param fseApply
+ */
+ @Transactional
+ public void applyFinish(FieldSetEntity fseApply) {
+ // 鍒涘缓瀹㈡埛淇℃伅
+ FieldSetEntity fseClient = new FieldSetEntity(SaasConst.PRODUCT_SYS_CLIENTS);
+ fseClient.setValue("client_name", fseApply.getString("unit_name"));
+ fseClient.setValue("client_tel", fseApply.getString("applicant_phone"));
+ fseClient.setValue("client_code", codeService.createCode(SaasConst.PRODUCT_SYS_CLIENTS, "client_code", ""));
+ fseClient.setValue("attachment_capacity", "2130000000");
+ fseClient.setValue("platform_admin", fseApply.getString("platform_admin"));
+ fseClient.setValue("expiration_date", fseApply.getString("expiration_date"));
+ fseClient.setValue("client_unit_type", fseApply.getString("unit_type"));
+ fseClient.setValue("client_address_province_id", fseApply.getString("area_province"));
+ fseClient.setValue("client_address_city_id", fseApply.getString("area_city"));
+ fseClient.setValue("client_address_county_id", fseApply.getString("area_county"));
+ fseClient.setValue("client_address_line_one", fseApply.getString("address"));
+ fseClient.setValue(CmnConst.CREATED_BY, "1");
+ fseClient.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ baseDao.add(fseClient);
+ // 澶嶅埗license鍒皐eb妯″潡
+ copyLicense(fseApply.getString("license"), fseClient.getString("client_code"));
+
+ // 鍒涘缓缁勭粐鏈烘瀯鍗曚綅
+ FieldSetEntity fseOrgUnit = new FieldSetEntity(CmnConst.PRODUCT_SYS_ORG_LEVELS);
+ fseOrgUnit.setValue("client_uuid", fseClient.getUUID());
+ fseOrgUnit.setValue("org_level_name", fseApply.getString("unit_name"));
+ fseOrgUnit.setValue("org_level_all", fseApply.getString("unit_name"));
+ fseOrgUnit.setValue("org_level_code", codeService.createCode("product_sys_org_levels", "org_level_code", null));
+ fseOrgUnit.setValue("org_level_type", 0);
+ fseOrgUnit.setValue("sequence", 1);
+ fseOrgUnit.setValue(CmnConst.CREATED_BY, "1");
+ fseOrgUnit.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ baseDao.add(fseOrgUnit);
+ // 鍒涘缓绉熸埛绠$悊鍛樼敤鎴蜂俊鎭�
+ FieldSetEntity fseUser = new FieldSetEntity(CmnConst.PRODUCT_SYS_USERS);
+ fseUser.setValue(CmnConst.USER_NAME, fseApply.getString("applicant_name"));
+ fseUser.setValue(CmnConst.USER_ACCOUNT, fseApply.getString("applicant_phone"));
+ fseUser.setValue(CmnConst.USER_PRIMARY_EMAIL, fseApply.getString("applicant_email"));
+ fseUser.setValue(CmnConst.USER_MOBILE_NUMBER, fseApply.getString("applicant_phone"));
+ fseUser.setValue(CmnConst.USER_PWD, userService.createPassWord(fseApply.getString("applicant_phone"), fseApply.getString("applicant_pwd")));
+ fseUser.setValue(CmnConst.IS_MANAGER, 1);
+ fseUser.setValue(CmnConst.STATUS, 1);
+ fseUser.setValue(CmnConst.CREATED_BY, "1");
+ fseUser.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ baseDao.add(fseUser);
+ FieldSetEntity fseUserInfo = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_USERS, fseUser.getUUID(), false);
+ // 鍒涘缓绉熸埛绠$悊鍛樹俊鎭�
+ FieldSetEntity fseManager = new FieldSetEntity(CmnConst.PRODUCT_SYS_ORG_MANAGER);
+ fseManager.setValue(CmnConst.USER_ID, fseUserInfo.getString(CmnConst.USER_ID));
+ fseManager.setValue(CmnConst.ORG_LEVEL_UUID, fseOrgUnit.getUUID());
+ fseManager.setValue(CmnConst.MANAGER_TYPE, 2);
+ fseManager.setValue(CmnConst.ROLE_UUIDS, "eabb00f3-2118-4165-967b-a7d88f472f67-notchange");
+ fseManager.setValue(CmnConst.IS_USED, 1);
+ fseManager.setValue(CmnConst.CLIENT_UUID, fseClient.getUUID());
+ fseManager.setValue(CmnConst.CREATED_BY, "1");
+ fseManager.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ baseDao.add(fseManager);
+ }
+
+ /**
+ * 澶嶅埗license鍒版寚瀹氱洰褰�
+ * @param fileUUID 闄勪欢UUID
+ * @param clientCode 瀹㈡埛缂栫爜
+ */
+ public void copyLicense(String fileUUID, String clientCode) {
+
+ // 鑾峰彇鏂囦欢淇℃伅
+ FieldSetEntity fse = baseDao.getFieldSetEntity(SaasConst.PRODUCT_SYS_ATTACHMENTS, fileUUID, false);
+ if (fse == null) {
+ throw new BaseException(SaasCode.TENANT_APPLY_LICENSE_DATA_NO_EXIST.getValue(), SaasCode.TENANT_APPLY_LICENSE_DATA_NO_EXIST.getText());
+ }
+
+ // 鏋勫缓婧愭枃浠惰矾寰�
+ String baseDir = System.getProperty("user.dir");
+ String localDir = Global.getSystemConfig("local.dir", "");
+ String attachmentUrl = fse.getString("attachment_url");
+ String attachmentTitle = fse.getString("attachment_title");
+
+ String filePath = baseDir + File.separator + localDir + File.separator + attachmentUrl + File.separator + attachmentTitle;
+
+ // 妫�鏌ユ簮鏂囦欢鏄惁瀛樺湪
+ if (!FileUtil.exist(filePath)) {
+ throw new BaseException(SaasCode.TENANT_APPLY_LICENSE_FILE_NO_EXIST.getValue(), SaasCode.TENANT_APPLY_LICENSE_FILE_NO_EXIST.getText());
+ }
+
+ // 鏋勫缓鐩爣鐩綍
+ String targetDir = baseDir + File.separator + "resources" + File.separator;
+ FileUtil.mkdir(targetDir);
+
+ // 鏋勫缓鐩爣鏂囦欢鍚嶏細license + clientCode + .dat
+ // 鏃犺鍘熸枃浠舵槸鍚︽湁鎵╁睍鍚嶏紝閮戒娇鐢�.dat鎵╁睍鍚�
+ String targetFileName = "license" + clientCode + ".dat";
+ String targetPath = targetDir + targetFileName;
+
+ // 澶嶅埗鏂囦欢
+ try {
+ // 浣跨敤Hutool澶嶅埗锛岀涓変釜鍙傛暟true琛ㄧず瑕嗙洊宸插瓨鍦ㄧ殑鏂囦欢
+ FileUtil.copy(filePath, targetPath, true);
+ // 楠岃瘉澶嶅埗缁撴灉
+ if (FileUtil.exist(targetPath)) {
+ long sourceSize = FileUtil.size(new File(filePath));
+ long targetSize = FileUtil.size(new File(targetPath));
+ if (sourceSize != targetSize) {
+ throw new BaseException(SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue(), SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue() + "鐩爣鏂囦欢涓嶅畬鏁�");
+ }
+ } else {
+ throw new BaseException(SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue(), SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue() + "鐩爣鏂囦欢涓嶅瓨鍦�");
+ }
+ } catch (Exception e) {
+ throw new BaseException(SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue(), SaasCode.TENANT_APPLY_LICENSE_FILE_COPY_FAIL.getValue() + e.getMessage());
+ }
}
}
diff --git a/src/main/java/com/product/saas/service/idel/ITenantApplyService.java b/src/main/java/com/product/saas/service/idel/ITenantApplyService.java
index 7bef626..6ed12bd 100644
--- a/src/main/java/com/product/saas/service/idel/ITenantApplyService.java
+++ b/src/main/java/com/product/saas/service/idel/ITenantApplyService.java
@@ -11,5 +11,16 @@
*/
boolean saveTenantApply(FieldSetEntity fse);
+ /**
+ * 绉熸埛娉ㄥ唽鎾ら攢
+ * @param fse
+ * @return
+ */
boolean cancelTenantApply(FieldSetEntity fse);
+
+ /**
+ * 绉熸埛娉ㄥ唽瀹屾暣
+ * @param fse
+ */
+ void applyFinish(FieldSetEntity fse);
}
--
Gitblit v1.9.2