作者 lyh

gx

... ... @@ -72,16 +72,13 @@ class InitKeyword extends Command
public function bind($notice_id)
{
$notice = NoticeLog::where(['id' => $notice_id])->first();
if (empty($notice) || $notice->type != NoticeLog::TYPE_INIT_KEYWORD || $notice->status != NoticeLog::STATUS_PENDING)
if (empty($notice) || $notice->type != NoticeLog::TYPE_INIT_KEYWORD || $notice->status != NoticeLog::STATUS_PENDING){
return true;
}
ProjectServer::useProject($notice['data']['project_id']);
$keyword = Keyword::whereNull('route')->get();
foreach ($keyword as $val) {
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title);
try {
$route = RouteMap::setRoute($val['title'],RouteMap::SOURCE_PRODUCT_KEYWORD, $val->id, $notice['data']['project_id']);
$val->route = $route;
... ... @@ -93,7 +90,6 @@ class InitKeyword extends Command
$notice->status = NoticeLog::STATUS_SUCCESS;
$notice->save();
DB::disconnect('custom_mysql');
return true;
}
... ... @@ -106,8 +102,9 @@ class InitKeyword extends Command
{
$key = 'notice_log_type_keyword';
$notice_id = Redis::rpop($key);
if ($notice_id)
if ($notice_id){
return $notice_id;
}
$ids = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD)->where('status', NoticeLog::STATUS_PENDING)->limit(100)->pluck('id');
foreach ($ids as $id) {
Redis::lpush($key, $id);
... ...