rabin 1 day ago
parent
commit
246e7d24c4
3 changed files with 10 additions and 9 deletions
  1. 5 4
      lib/Relation.php
  2. 1 1
      table/code.php
  3. 4 4
      table/relation.php

+ 5 - 4
lib/Relation.php

@@ -13,8 +13,8 @@ class Relation
         }
     }
 
-    # 只记录3级关系
-    private $total = 3;
+    # 只记录级关系
+    private $total = 10;
 
     # 通用的邀请方法:
     # uid 当前用户的上级,需要通过code邀请码来得到
@@ -76,7 +76,7 @@ class Relation
     # 清理邀请关系
     public function dropParent($uid, $parent)
     {
-        return Dever::db($this->table)->delete(['to_uid' => $uid, 'uid' => $parent]);
+        return Dever::db($this->table)->delete(['uid' => $parent, 'to_uid' => $uid]);
     }
 
     # 获取某个用户的上级数据
@@ -122,9 +122,10 @@ class Relation
         if ($end) {
             $where['cdate##'] = ['<=', strtotime($end)];
         }
-        $method = 'select';
         if ($method == 'count') {
             $method = 'count';
+        } else {
+            $method = 'select';
         }
         return Dever::db($this->table)->$method($where);
     }

+ 1 - 1
table/code.php

@@ -1,7 +1,7 @@
 <?php
 return [
     'name' => '邀请码',
-    'partition' => 'Dever::call("manage/common.system")',
+    'partition' => 'Dever::call("manage/util.system")',
     # 数据结构
     'struct' => [
         'uid'       => [

+ 4 - 4
table/relation.php

@@ -1,7 +1,7 @@
 <?php
 return [
     'name' => '邀请关系',
-    'partition' => 'Dever::call("manage/common.system")',
+    'partition' => 'Dever::call("manage/util.system")',
     # 数据结构
     'struct' => [
         'uid'       => [
@@ -20,9 +20,9 @@ return [
         ],
     ],
 
-    /*
     'index' => [
-        'search' => 'uid,value',
+        'search' => 'uid,to_uid',
+        'uid' => 'uid,level',
+        'to_uid' => 'to_uid,level',
     ],
-    */
 ];