|
@@ -27,11 +27,11 @@ class Plantask extends Controller
|
|
|
$map = [
|
|
|
'gh_id' => ['gt',0],
|
|
|
];
|
|
|
- $ghuser = Db::name('user')->where($map)->orderRaw('rand()')->value('id');
|
|
|
+ $ghuser = Db::name('user')->where($map)->orderRaw('rand()')->limit(5)->column('id');
|
|
|
//dump($ghuser);
|
|
|
|
|
|
//随机取出一句话
|
|
|
- $oneword = Db::name('plantask_accost')->orderRaw('rand()')->value('title');
|
|
|
+ $oneword = Db::name('plantask_accost')->orderRaw('rand()')->limit(5)->column('title');
|
|
|
//dump($oneword);
|
|
|
|
|
|
//发送出去
|
|
@@ -42,9 +42,14 @@ class Plantask extends Controller
|
|
|
if($times === false){
|
|
|
$times = 0;
|
|
|
}
|
|
|
+
|
|
|
if($times < 5){
|
|
|
- $this->sendMessageToUser($ghuser,$oneuser,$oneword);
|
|
|
- $cache->set('plantask_first_word_'.$oneuser, $times + 1);
|
|
|
+ for($i = 0;$i < 5;$i++){
|
|
|
+ $ghuser_one = isset($ghuser[$i]) ? $ghuser[$i] : $ghuser[array_rand($ghuser)];
|
|
|
+ $oneword_one = isset($oneword[$i]) ? $oneword[$i] : $oneword[array_rand($oneword)];
|
|
|
+ $this->sendMessageToUser($ghuser_one,$oneuser,$oneword_one);
|
|
|
+ }
|
|
|
+ $cache->set('plantask_first_word_'.$oneuser, 5);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -109,6 +114,12 @@ class Plantask extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //清空redis
|
|
|
+ public function clear_redis(){
|
|
|
+ $val = input('uid');
|
|
|
+ $cache = Cache::connect(['type'=>'Redis']);
|
|
|
+ $cache->rm('plantask_first_word_'.$val);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|