public function run() { //获取精选符合的精选计划 $planInfos = Model_Plan_Jp::getValidChoicePlanByCursor($this->cursor, $this->limit); //无需要处理的数据 if (empty($planInfos)) { $this->setShStopFlag(); $this->setCursor(0); $this->logQuit("无需要处理的数据."); } foreach ($planInfos as $plan) { $cityId = $plan->cityId; $houseType = $plan->houseType; /** 获取房源基本信息 */ $propInfo = Bll_House_JpHouseInfo::getHouseInfoById($plan->houseId); /** 获取价格信息 **/ $arrPrice = Bll_House_JpHouseInfo::getPrice($cityId, $propInfo['base']['houseType'], $propInfo['info']); //获取二手房经纪人id $mainBusiness = Model_Broker_MainBusiness::getMainBusinessByJpBrokerId($plan['memberId'], false); //获取点击单击 $apiParams = array('brokerId' => $mainBusiness['ajkBrokerid'], 'cityId' => $cityId, 'price' => $arrPrice['price'] ?: 0, 'blockId' => $plan->blockId, 'newBlockId' => $plan->newBlockId, 'houseType' => $houseType); $clickPrice = Bll_Service_Choice::jpClickPrice($apiParams); if ($clickPrice['status'] == 'error') { $this->logQuit(sprintf('计划%d获取对应的点击单价失败', $plan->id)); } $spreadPrice = $clickPrice['realTradeAmount']; //更新点击单价 $oldSpreadPrice = $propInfo['info']->spreadPrice; $propInfo['info']->spreadPrice = $spreadPrice; $propInfo['info']->save(); $this->addLogger(sprintf("计划%dspreadPrice修改,%d=>%d", $plan->id, $oldSpreadPrice, $spreadPrice)); //更新游标 $this->setCursor($plan->id); } }