Example #1
0
 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;
     }
 }