12
This commit is contained in:
+41
-8
@@ -13,6 +13,7 @@ class OpenIm extends Command
|
||||
{
|
||||
protected static $defaultName = 'openim';
|
||||
protected static $defaultDescription = 'OpenIm';
|
||||
public $sdk= null;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@@ -37,23 +38,18 @@ class OpenIm extends Command
|
||||
if(method_exists($this, $action)){
|
||||
return $this->$action($input, $output);
|
||||
}
|
||||
$output->writeln($action.'不存在');
|
||||
return self::FAILURE;
|
||||
}
|
||||
private function change_user(InputInterface $input, OutputInterface $output):int{
|
||||
|
||||
$im = new \support\OpenImSdk\Client([
|
||||
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||
]);
|
||||
$im = $this->getSdk();
|
||||
$data = $im->user->updateUserInfo(idEncode('100006'),['userInfo'=>['userId'=>'wx100001']]);
|
||||
cp($data);
|
||||
return self::SUCCESS;
|
||||
}
|
||||
private function sync_users(InputInterface $input, OutputInterface $output):int{
|
||||
$im = new \support\OpenImSdk\Client([
|
||||
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||
]);
|
||||
$im = $this->getSdk();
|
||||
$data = $im->user->getAllUsersUid(1,1000);
|
||||
cp($data);
|
||||
return self::SUCCESS;
|
||||
@@ -82,4 +78,41 @@ class OpenIm extends Command
|
||||
}
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
function sync_cache(){
|
||||
$res = \app\model\Openim\Group::field('group_id,creator_user_id')->select();
|
||||
|
||||
$group_create = [];
|
||||
foreach($res as $v){
|
||||
if(!isset($group_create[$v['creator_user_id']])){
|
||||
$group_create[$v['creator_user_id']] = 0;
|
||||
}
|
||||
if($v['status'] != 2){
|
||||
$group_create[$v['creator_user_id']]+=1;
|
||||
}
|
||||
cache('group_owner_'.$v['group_id'],$v['creator_user_id']);
|
||||
$group_user_count = \app\model\Openim\GroupMember::field('group_id,count(*) as count')
|
||||
->where('group_id',$v['group_id'])
|
||||
->count('user_id');
|
||||
cp('群组数量',$v['group_id'],'成员数量:',$group_user_count);
|
||||
cache('group_'.$v['group_id'].'_user_count',$group_user_count);
|
||||
|
||||
}
|
||||
//cp($group_create);
|
||||
foreach($group_create as $userId =>$count){
|
||||
cp('用户:',$userId,'创建群组数量:',$count);
|
||||
cache('user_'.$userId.'_create_group_count',$count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function getSdk(){
|
||||
if($this->sdk){
|
||||
return $this->sdk;
|
||||
}
|
||||
$this->sdk = new \support\OpenImSdk\Client([
|
||||
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||
]);
|
||||
return $this->sdk;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user