public function actionQueue() { header('Access-Control-Allow-Origin:*'); $url = trim($this->post("url", "")); if (!$url) { return $this->renderJSON([], 'no illage param url ~~', -1); } $ret = EmoticonService::addQueue(['url' => $url]); if (!$ret) { return $this->renderJSON([], EmoticonService::getLastErrorMsg(), -1); } return $this->renderJSON(); }
/** * 定时处理队列数据 * php yii emoticon/scrapy/pic-url */ public function actionPicUrl() { $list = EmoticonQueue::find()->where(['status' => -1])->orderBy(['id' => SORT_ASC])->limit(50)->all(); if (!$list) { return $this->echoLog('no data need to handle'); } $date_now = date("Y-m-d H:i:s"); foreach ($list as $_item) { $this->echoLog("queue_id:{$_item['id']}"); switch ($_item['type']) { case 1: $tmp_ret = EmoticonService::scrapy($_item); break; case 2: $tmp_ret = EmoticonService::parseImages($_item); break; default: $tmp_ret = false; break; } if (!$tmp_ret) { $this->echoLog(EmoticonService::getLastErrorMsg()); } $_item->status = $tmp_ret ? 1 : 0; $_item->updated_time = $date_now; $_item->update(0); } return $this->echoLog("it's over ~~"); }