public function actionFakeLike() { $this->_log->setLogFile('like.log'); if ($this->_isFake(self::LIKE_NUM_MIN, self::LIKE_NUM_MAX)) { $likeApp = $this->_getRandomApp(); if (!$likeApp) { return; } $date = date('Y-m-d H:i:s'); $likedFakeUser = $this->_getLikedFakeUser($likeApp->Id); $userId = $this->_getRandomUserId($likedFakeUser); $user = User::model()->findByPk($userId); try { $result = AppInfoList::up($likeApp, $user, true); if ($result) { $this->_log->log('userId#' . $userId . '#于#' . $date . '#赞了App Id#' . $likeApp->Id . '#'); } } catch (Exception $e) { echo $e->getMessage(); } } }
public function actionDislike() { $appID = Yii::app()->request->getParam('id'); if (empty($appID)) { throw new THttpException('操作失败'); } $app = AppInfoList::model()->findByPk($appID); if (empty($app) || $app->Status > 0) { throw new THttpException('操作失败'); } $userID = Yii::app()->user->id; $user = User::model()->findByPk($userID); if (empty($user)) { throw new THttpException('操作失败'); } try { if (AppInfoList::up($app, $user, false)) { echo new ReturnInfo(RET_SUC, 'success'); } } catch (Exception $e) { throw new THttpException($e->getMessage()); } }
public function actionDislike() { $appID = Yii::app()->getRequest()->getQuery('appid'); if (empty($appID)) { echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.'); Yii::app()->end(); } $app = AppInfoList::model()->findByPk($appID); if (empty($app)) { echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.'); Yii::app()->end(); } try { AppInfoList::up($app, $this->apiUser, false); echo new ReturnInfo(RET_SUC, 1); } catch (Exception $e) { echo new ReturnInfo(RET_ERROR, $e->getMessage()); } }