public function handle_request() { $this->__logFile = sprintf('/home/www/logs/User_ImportUserInfo-%s.log', date('Ymd')); if (file_exists($this->__idFile) && is_readable($this->__idFile)) { $this->startId = intval(file_get_contents($this->__idFile)); } $index = 1; $pageSize = 1000; while (true) { echo "开始导入第{$index}批经纪人信息, 起始BrokerId={$this->startId}\n"; $brokerList = Model_Broker_AjkBrokerExtend::scanBroker($this->startId, $pageSize); if (empty($brokerList)) { break; } foreach ($brokerList as $broker) { $this->startId = $broker['brokerId']; file_put_contents($this->__idFile, $this->startId); file_put_contents($this->__logFile, "{$index}: 导入经纪人: {$broker['trueName']}\tBrokerId: {$broker['brokerId']}\tUserId: {$broker['userId']}\n", FILE_APPEND); /** $aid,$user_id,$broker_id,$city_id,$user_name,$gender,$phone,$properties,$origin_properties,$grade_score,$grade_level */ Bll_Cms_ActivityUserProperty::add_broker(1, $broker['userId'], $broker['brokerId'], $broker['cityId'], $broker['trueName'], $broker['gender'] == 1 ? 0 : 1, $broker['userMobile'], $broker['gradeScore'], $broker['gradeScore'], $broker['gradeScore'], $broker['gradeLevel']); } $index++; } echo "导入经纪人信息完成,结束BrokerId={$this->startId}\n"; }
private function getAjkBrokerExtendList($limit = 1000) { return Model_Broker_AjkBrokerExtend::scanBroker($this->brokerId, $limit); }
public function handle_request() { $brokerList = Model_Broker_AjkBrokerExtend::scanBroker($this->_startId, self::BATCH_LIMIT); if (empty($brokerList)) { file_put_contents($this->_doneFile, 'YES'); } foreach ($brokerList as $broker) { $brokerId = $broker['brokerId']; $cityId = $broker['cityId']; $this->setCursor($brokerId); /** 套餐城市的不予以处理 */ if (Bll_City::isComboCity($broker['cityId'])) { $this->logMsg(sprintf('经纪人[%d] 城市[%d] 是套餐城市,不予处理。', $brokerId, $cityId)); continue; } /** 判断经纪人所在城市是否已经开启多档封顶 */ if (false == Bll_Broker_Manage_AjkPropList::checkSelectLimitTempAvailable($cityId)) { $this->logMsg(sprintf('经纪人[%d] 城市[%d] 没有开启多档封顶,不予处理。', $brokerId, $cityId)); continue; } /** 获取经纪人城市封顶限额 */ $ppcLimitInfo = Bll_Ppc_ServiceAPI::getPpcBrokerLimitInfo($brokerId); if (empty($ppcLimitInfo)) { $this->logMsg(sprintf('经纪人[%d] 城市[%d] 获取封顶限额失败。', $brokerId, $cityId)); file_put_contents($this->_errorBroker, $brokerId, FILE_APPEND); continue; } $ppcFixHouseCountLimit = $ppcLimitInfo['promotionLimit']; /** 获取经纪人所有的定价计划 */ $fixPlanList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList($broker); $fixSpreadHouseList = array(); foreach ($fixPlanList as $fixPlan) { $planId = $fixPlan['id']; /** 获取经纪人指定定价计划下房源计划关系 */ $fixSpreadHouseList = $fixSpreadHouseList + Bll_Plan_Fix_AjkPlan::getPropFixedPlanRelation($brokerId, $cityId, $planId); } $fixSpreadHouseCount = count($fixSpreadHouseList); if ($fixSpreadHouseCount <= $ppcFixHouseCountLimit) { $this->logMsg(sprintf('经纪人[%d] 城市[%d] 可以推广[%d]套房源,实际推广了[%d]套房源,没有多余房源。', $brokerId, $cityId, $ppcFixHouseCountLimit, $fixSpreadHouseCount)); continue; } $this->logMsg(sprintf('经纪人[%d] 城市[%d] 可以推广[%d]套房源,实际推广了[%d]套房源,多余[%d]房源下架。', $brokerId, $cityId, $ppcFixHouseCountLimit, $fixSpreadHouseCount, $fixSpreadHouseCount - $ppcFixHouseCountLimit)); /** 测试,不予以处理 */ file_put_contents('/data1/logs/Repair_Bug46849.test', $brokerId, FILE_APPEND); continue; $updateTime2IdMapping = array(); $updateTime = array(); foreach ($fixSpreadHouseList as $fixSpreadHouse) { $intUpdateTime = strtotime($fixSpreadHouse['updatedDatetime']); $updateTime[] = $intUpdateTime; if (!isset($updateTime2IdMapping[$intUpdateTime])) { $updateTime2IdMapping[$intUpdateTime] = array(); } $updateTime2IdMapping[$intUpdateTime][] = $fixSpreadHouse; } $updateTime = array_unique($updateTime, SORT_NUMERIC); rsort($updateTime, SORT_NUMERIC); $relationList = array(); foreach ($updateTime as $key) { $relationList = array_merge($relationList, $updateTime2IdMapping[$key]); } /** 需要下架的推广房源 */ $houseList = array_slice($relationList, 0, $fixSpreadHouseCount - $ppcFixHouseCountLimit); foreach ($houseList as $house) { if (Bll_Ppc_ServiceAPI::deleteHouseFromFixPlan($brokerId, $house['planId'], $house['propId'], 46849)) { $this->logMsg(sprintf('经纪人[%d] 城市[%d] 房源[%d]从计划[%d]下架成功。', $brokerId, $cityId, $house['propId'], $house['planId'])); continue; } $this->logMsg(sprintf('经纪人[%d] 城市[%d] 房源[%d]从计划[%d]下架失败。', $brokerId, $cityId, $house['propId'], $house['planId'])); } } if (count($brokerList) < self::BATCH_LIMIT) { $this->logMsg(sprintf('startId: %d 处理结束。', $this->_startId)); file_put_contents($this->_doneFile, 'YES'); return; } }