public function pullDailyRecommendThreads($spaceId) {/*{{{*/ $space = DAL::get()->find('space', $spaceId); if($space->isNull()) { $this->setErrorCode(328); return 0; } $firstLoginTime = ''; $spaceexp= DAL::get()->find_by_userid('spaceexp', $space->user->id); if(false == $spaceexp->isNull()) { $firstLoginTime = $spaceexp->firstLoginTime; } if(empty($firstLoginTime) || false == empty($firstLoginTime) && (XDateTime::hourDiff(XDateTime::valueOf($firstLoginTime),XDateTime::now()) > 24)) { $proposalIds = ProposalClient::getInstance()->autoPullRecommends($space); error_log("[".XDateTime::now()."] ".$space->user->name."\n", 3, "/tmp/mobile_autopull.log"); if (false == empty($proposalIds)) { SpaceExpClient::getInstance()->createSpaceExp($space->user->id, XDateTime::now()); } } }/*}}}*/
public function ajaxGetNextRecommendThread($request, $response) {/*{{{*/ header('Content-Type: application/json; charset=UTF-8'); //判断是否推送的判断变量 $isCanAutoPull = (false === empty($_COOKIE["userinfo"]["hosttype"]) && 'Doctor' == $_COOKIE["userinfo"]['hosttype']) ; $cookie = new HdfCookie(); $isSuccess = 0; if($isCanAutoPull && (false === isset($_COOKIE['firstlogintime']) || (false == empty($_COOKIE['firstlogintime']) && (XDateTime::hourDiff(XDateTime::valueOf($_COOKIE['firstlogintime']), XDateTime::now()) > 24)))) { $auto = ThreadClient::getInstance()->autoPullRecommendThreads($this->_newUser); if ($auto) { $cookie->set("firstlogintime", XDateTime::now(), 7*24*3600); SpaceExpClient::getInstance()->createSpaceExp($this->_newUser->id, XDateTime::now()); $isSuccess = 1; } } $unUnreadCaseCount = FlowClient::getInstance()->getUnReadCount($this->_newSpace->id); $callback = $request->callback; echo "\n".$callback.'('; echo Json::encode($unUnreadCaseCount); echo ');'; //方便测试 echo "\nisCanAuto:".$isCanAutoPull; echo "\nisSuccess:".$isSuccess; exit; }/*}}}*/
public function ajaxGetNextRecommendThread($request, $response) { /*{{{*/ $response->setHeader('Content-Type: application/json; charset=UTF-8'); $this->getLogger(); $canRecommend = $this->canRecommend(); $this->log->addDebug('canRecommend:' . (int) $canRecommend); if ($canRecommend) { $proposalIds = ProposalClient::getInstance()->autoPullRecommends($this->space); $this->log->addDebug('autoPullRecommends:', $proposalIds); if (false == empty($proposalIds)) { $cookie = new HdfCookie(); $cookie->set('firstlogintime', XDateTime::now(), 7 * 24 * 3600); $this->log->addDebug('firstlogintime:' . XDateTime::now() . '7*24*3600'); SpaceExpClient::getInstance()->createSpaceExp($this->user->id, XDateTime::now()); } } $unReadCount = FlowClient::getInstance()->getUnReadCount($this->space->id); echo "\n" . $request->callback . '(' . Json::encode($unReadCount) . ');'; return parent::DIRECT_OUTPUT; }