Browse Source

家族创建

zhangxiaobin 1 year ago
parent
commit
a10a545eb7
2 changed files with 16 additions and 2 deletions
  1. 2 2
      application/api/controller/Guild.php
  2. 14 0
      application/common.php

+ 2 - 2
application/api/controller/Guild.php

@@ -148,8 +148,8 @@ class Guild extends Api
         if (empty($guild_id)) {
             $guildInfo = new \app\common\model\Guild();
             $guildInfo->user_id = $user_id;
-            $ids = Guild::column("g_id");
-            $guildInfo->g_id = $this->getUinqueId(4, [$ids]);
+            $ids = \app\common\model\Guild::column("g_id");
+            $guildInfo->g_id = getUinqueId(4, [$ids]);
             $guildInfo->status = 0;
         } else {
             // 获取公会信息

+ 14 - 0
application/common.php

@@ -2,6 +2,7 @@
 
 // 公共助手函数
 
+use fast\Random;
 use Symfony\Component\VarExporter\VarExporter;
 
 if (!function_exists('__')) {
@@ -630,3 +631,16 @@ function createUniqueNo($prifix = 'P',$id = 0)
 
     return $rt;
 }
+if (!function_exists('getUinqueId')) {
+    /**
+     * 生成不重复的随机数字
+     */
+    function getUinqueId($length = 8, $ids = [])
+    {
+        $newid = Random::build("nozero", $length);
+        if (in_array($newid, $ids)) {
+            $newid = $this->getUinqueId($length, $ids);
+        }
+        return $newid;
+    }
+}