| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | 
							- <?php
 
- namespace app\common\model;
 
- use think\Model;
 
- /**
 
-  * 期望对象模型
 
-  */
 
- class Expect Extends Model
 
- {
 
-     // 表名
 
-     protected $name = 'expect';
 
-     // 开启自动写入时间戳字段
 
-     protected $autoWriteTimestamp = 'int';
 
-     /**
 
-      * 获取用户期望对象对应标签列表
 
-      * $expect 格式 1,2,3
 
-      * return $user_ids;用户ID集合
 
-      */
 
-     public static function getTagsByExpect($expect) {
 
-         if(!$expect) return false;
 
-         $user_ids = [];
 
-         $where = [];
 
-         $where['id'] = ["in",$expect];
 
-         $list = self::where($where)->select();
 
-         $tag_ids = [];
 
-         if($list) foreach($list as $k => $v) {
 
-             $ids = explode(',',$v['tag_ids']);
 
-             if($ids) foreach($ids as $m => $n) {
 
-                 $tag_ids[] = $n;
 
-             }
 
-         }
 
-         $tag_ids = array_unique($tag_ids);
 
-         if($tag_ids) {
 
-             $tag_ids_str = implode(",",$tag_ids);
 
-             $tagCanbeSearch = config('site.tagCanbeSearch');
 
-             // 获取对应用户ID
 
-             $where = [];
 
-             $where['tag_id'] = ['in',$tag_ids_str];
 
-             $where['number'] = ['gt',$tagCanbeSearch];
 
-             $user_ids = \app\common\model\TagUser::where($where)->column("user_id");
 
-             $user_ids = array_unique($user_ids);
 
-         }
 
-         return $user_ids;
 
-     }
 
-     public static function getExpectNames($expect_ids) {
 
-         if($expect_ids) {
 
-             $expect_ids = explode(',',$expect_ids);
 
-             $expect_names = self::where(['id'=>['in',$expect_ids]])->column('name');
 
-         } else {
 
-             $expect_names = [];
 
-         }
 
-         return $expect_names;
 
-     }
 
- }
 
 
  |