/** * Job执行逻辑 */ public function handle_request() { // check if (!($this->checkParams() && $this->isActionNotDone() && $this->isPreFinished())) { return false; } $actionId = $this->actionId; // 获取该actionid的Nocomms $nocomms = Bll_Cms_BlockChange::getNocommsByAction(Bll_Cms_BlockChange::getActionWithCommunity($this->actionId)); if (empty($nocomms)) { $this->setLog('nocomms is empty'); Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); return false; } $commsValus = array_values($nocomms); $cityId = $commsValus[0]['city_id']; // 取游标 $flag = $this->getFlag(); if (isset($flag['id']) && is_numeric($flag['id'])) { $this->cursor = $flag['id']; } else { $this->cursor = 0; } // 标记处理状态 Bll_Cms_BlockChange::updateDoList($actionId, 5, 1, 'action:' . $actionId . ' list_id:5 处理中..房子:' . $this->cursor); //更新租房房源信息 $result = $this->dealPropCommidZero($this->cursor, $nocomms, $cityId); // 如果返回空 重置游标 if (!$result['status'] && $result['msg'] == 'empty') { //游标置为0 $this->cursor = 0; foreach ($nocomms as $nocomm) { // 更新状态 Dao_Cms_BlockChange::updateNocommByCode($nocomm['old_code'], $nocomm['new_code'], 1); } // 更新dolist Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); } // 记录log if ($result['msg'] && is_array($result['msg'])) { foreach ($result['msg'] as $msg) { $this->setLog($msg); } } //记录游标 $this->setFlag(array('id' => $this->cursor)); }
/** * Job执行逻辑 */ public function handle_request() { // check if (!($this->checkParams() && $this->isActionNotDone() && $this->isPreFinished())) { return false; } $actionId = $this->actionId; // 获取该actionid的Nocomms $nocomms = Bll_Cms_BlockChange::getNocommsByAction(Bll_Cms_BlockChange::getActionWithCommunity($this->actionId)); if (empty($nocomms)) { $this->writeLog('nocomms is empty'); Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); return false; } $commsValus = array_values($nocomms); $cityId = $commsValus[0]['city_id']; // 取游标 $beginId = @(int) file_get_contents($this->idFile); // 标记处理状态 Bll_Cms_BlockChange::updateDoList($actionId, 5, 1, 'action:' . $actionId . ' list_id:5 处理中..房子:' . $beginId); //更新租房房源信息并重新定竞价 $result = Bll_HzProp::dealPropCommidZero($beginId, $nocomms, $cityId, $this->idFile); // 如果返回空 重置游标 if (!$result['status'] && $result['msg'] == 'empty') { $result['msg'] = array(); $result['msg'][] = "action: " . $actionId . ",is finished"; file_put_contents($this->idFile, 'END'); foreach ($nocomms as $nocomm) { // 更新状态 Bll_Cms_BlockChange::updateNocomm($nocomm['id'], 1); } // 更新dolist Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); } // 记录log if ($result['msg'] && is_array($result['msg'])) { foreach ($result['msg'] as $msg) { $this->writeLog($msg); } } }
/** * Job执行逻辑 */ public function handle_request() { // 获取操作信息 $action = Bll_Cms_BlockChange::getActionWithCommunity($this->actionId); if (empty($action) || empty($action['comms'])) { $this->writeLog('all action is finished'); return false; } $isFinish = false; // 判断之前动作是否处理完 if ($doListData = Bll_Cms_BlockChange::getDoList($action['id'], 3)) { if ($doListData['status'] == 2) { $isFinish = true; } } else { $this->writeLog('获取actionid=' . $action['id'] . '的dolist为空或者失败'); return false; } if (!$isFinish) { $this->writeLog('action:' . $action['id'] . ' 正在' . $doListData['list_id'] . '处理阶段'); return false; } // 标记处理状态 Bll_Cms_BlockChange::updateDoList($action['id'], 4, 1, 'action:' . $action['id'] . ' list_id:4 处理中'); // 处理comms $result = Bll_Cms_BlockChange::dealActionComms($action); // 更新dolist表 if ($result && $result['status']) { Bll_Cms_BlockChange::updateDoList($action['id'], 4, 2); // 记录本次actionid file_put_contents($this->logDir . 'hzblock_change_actionid.log', $action['id']); } else { $errMsg = $result['msg']; Bll_Cms_BlockChange::updateDoList($action['id'], 4, 3, is_string($errMsg) ? $errMsg : implode(',', $errMsg)); } // 记录log if ($result['msg'] && is_array($result['msg'])) { foreach ($result['msg'] as $msg) { $this->writeLog($msg); } } }