Browse Source

生成随机营业执照号

guq 7 years ago
parent
commit
ec642afca2

+ 9 - 0
framework/core/src/main/java/com/usoftchina/saas/utils/DateUtils.java

@@ -231,6 +231,15 @@ public class DateUtils {
         return format(new Date(), null);
     }
 
+    /**
+     * 当前时间
+     *
+     * @return <h3>String</h3>
+     */
+    public static String getCurrentDate(String format) {
+        return format(new Date(), format);
+    }
+
     /**
      * 截取指定日期的年月
      *

+ 14 - 0
framework/core/src/main/java/com/usoftchina/saas/utils/StringUtils.java

@@ -1,10 +1,14 @@
 package com.usoftchina.saas.utils;
 
+import java.util.Date;
+
 /**
  * @author yingp
  * @date 2018/10/10
  */
 public abstract class StringUtils extends org.springframework.util.StringUtils{
+
+    private final static String BUSINESSCODE_PREFIX = "SAASTRADE";
     /**
      * 为空取值
      *
@@ -25,4 +29,14 @@ public abstract class StringUtils extends org.springframework.util.StringUtils{
     public static String nullIf(String target) {
         return nullIf(target, "");
     }
+    /**
+    * @Description 随机生成企业执照号
+    * @Param: []
+    * @return: java.lang.String
+    * @Author: guq
+    * @Date: 2018/11/22
+    */
+    public static String createBusinessCode() {
+        return BUSINESSCODE_PREFIX + DateUtils.getCurrentDate("yyyyMMdd") + (int)(Math.random()*1000 + 1000);
+    }
 }