public function handle_request()
 {
     $dealStatus = array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED);
     $condition = array(array('proid', '>', $this->_startId), array('updated', '>=', strtotime($this->_startTime)), array('updated', '<=', strtotime($this->_endTime)));
     $houseList = Model_House_HzPropSearch::getPropLists($this->_cityId, $condition, self::BATCH_LIMIT);
     foreach ($houseList as $houseInfo) {
         $houseId = $houseInfo['proid'];
         $this->setFlag(array('id' => $houseId, 'time' => date('Y-m-d H:i:s')));
         if (!in_array($houseInfo['status'], $dealStatus)) {
             $this->setLog(sprintf('房源[%d]房源状态[%d]不在[%s]不处理', $houseId, $houseInfo['status'], implode(',', $dealStatus)));
             continue;
         }
         $houseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         if (empty($houseRelation)) {
             $this->setLog(sprintf('房源[%d - %d],没有获取到套餐关系', $houseId, $houseInfo['status']));
             continue;
         }
         /** 如果房源关系已经不是在线的,就不修复 */
         if (false == Bll_Combo_HouseRelation::isRelationOnline($houseRelation['state'])) {
             $this->setLog(sprintf('房源[%d - %d],已经不在线,不处理', $houseId, $houseRelation['state']));
             continue;
         }
         switch ($houseInfo['status']) {
             case Const_HzStatus::VERIFY:
                 $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_ILLEGAL;
                 break;
             case Const_HzStatus::REMOVE:
                 $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_DELETE;
                 break;
             case Const_HzStatus::EXPIRED:
                 $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_EXPIRE;
                 break;
             default:
                 $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_DELETE;
                 continue;
         }
         /** 修正房源套餐推广关系 */
         if (1 == Bll_Combo_HouseRelation::updateComboStatusById($houseRelation['id'], $relationState, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             $this->setLog(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复成功', $houseId, $houseInfo['status'], $houseRelation['id'], $houseRelation['state']));
         } else {
             $this->setLog(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复失败', $houseId, $houseInfo['status'], $houseRelation['id'], $houseRelation['state']));
         }
         $this->noticeComboSolr($houseInfo['cityid'], $houseInfo['userid'], $houseId);
     }
     if (count($houseList) < self::BATCH_LIMIT) {
         $this->setLog(sprintf('[%d - %d]已经处理完成...', $this->_cityId, $this->_startId));
         $this->setShStopFlag();
         $this->removeFlag();
     } else {
         $this->setShCommonSleepTime(1);
     }
 }
예제 #2
0
 public function handle_request()
 {
     $condition = array(array('proid', '>', $this->_startId), array('cityid', '=', $this->_cityId), array('created', '<', $this->_expireTime), array('status', '<>', Const_HzStatus::EXPIRED), array('status', '<>', Const_HzStatus::REMOVE));
     $houseList = Model_House_HzPropSearch::getPropLists($this->_cityId, $condition, self::BATCH_LIMIT);
     if (empty($houseList)) {
         $this->setShStopFlag();
         $this->setLog('处理完成');
         return;
     }
     foreach ($houseList as $house) {
         $houseId = $house['proid'];
         $this->setLog(sprintf('开始处理房源[%d], 房源发布时间[%s]: %s', $houseId, date('Y-m-d H:i:s', $house['created']), json_encode($house)));
         $this->setFlag(array('id' => $houseId), $this->_cursorFile);
         if (1 != Model_House_HzPropSearch::updatePropStatus($this->_cityId, $houseId, Const_HzStatus::EXPIRED)) {
             $this->setLog(sprintf('房源[%d]更新房源状态失败', $houseId));
             continue;
         }
         $comboHouseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, false);
         if (empty($comboHouseRelation)) {
             $this->setLog(sprintf('房源[%d]没有获取到套餐推广关系', $houseId));
             continue;
         }
         $this->setLog(sprintf('房源[%d]套餐推广关系: %s', $houseId, json_encode($comboHouseRelation)));
         if (!Bll_Combo_HouseRelation::isRelationOnline($comboHouseRelation['state'])) {
             $this->setLog(sprintf('房源[%d]套餐推广状态不在线[%d]', $houseId, $comboHouseRelation['state']));
             continue;
         }
         $this->setLog(sprintf('房源[%d]套餐推广状态在线[%d]', $houseId, $comboHouseRelation['state']));
         if (1 != Bll_Combo_HouseRelation::updateComboStatusById($comboHouseRelation['id'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             $this->setLog(sprintf('更新房源[%d]套餐关系[%d : %d -> %d]失败', $houseId, $comboHouseRelation['id'], $comboHouseRelation['state'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE));
             continue;
         }
         $this->setLog(sprintf('更新房源[%d]套餐关系[%d : %d -> %d]成功', $houseId, $comboHouseRelation['id'], $comboHouseRelation['state'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE));
         $this->noticeComboSolr($this->_cityId, $house['userid'], $houseId, $comboHouseRelation['brokerId']);
     }
     if (count($houseList) < self::BATCH_LIMIT) {
         $this->setShStopFlag();
     }
 }
 private function moveJpPPCFixPlanRelation($cityId, $jpBrokerId, $fixPlan)
 {
     try {
         $ajkBrokerId = Bll_Broker_User::getAjkBrokerIdByJpBrokerId($jpBrokerId);
     } catch (Exception $e) {
         $this->logMsg($e->getMessage());
         return;
     }
     if ($ajkBrokerId == 0) {
         $this->logMsg(sprintf('经纪人[%d - %d]没有获取到二手房经纪人ID。', $cityId, $jpBrokerId));
         return;
     }
     $fixPlanId = $fixPlan['id'];
     $fixPlanHouseRelationList = Model_House_JpHouseIdx::getHouseInfoByFixPlanIdEx($fixPlanId);
     if (empty($fixPlanHouseRelationList)) {
         $this->logMsg(sprintf('经纪人[%d - %d - %d - %d]没有获取到金铺定价计划房源。', $cityId, $ajkBrokerId, $jpBrokerId, $fixPlanId));
         return;
     }
     foreach ($fixPlanHouseRelationList as $fixPlanHouseRelation) {
         $comboHouseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($fixPlanHouseRelation['id'], Model_Combo_HouseRelation::SITE_TYPE_JP);
         if (!empty($comboHouseRelation)) {
             if ($comboHouseRelation['state'] == Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE) {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],且state==205', $fixPlanHouseRelation['id'], $comboHouseRelation['id']));
                 continue;
             }
             if (1 == Bll_Combo_HouseRelation::updateComboStatusById($comboHouseRelation['id'], Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, Model_Combo_HouseRelation::SITE_TYPE_JP)) {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],更新成功', $fixPlanHouseRelation['id'], $comboHouseRelation['id']));
             } else {
                 $this->logMsg(sprintf('房源[%d]的套餐关系存在id[%d],更新失败', $fixPlanHouseRelation['id'], $comboHouseRelation['id']));
             }
             continue;
         }
         $data = array('houseId' => $fixPlanHouseRelation['id'], 'brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'state' => Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE, 'created' => $fixPlanHouseRelation['createTime']);
         if (1 == Model_Combo_HouseRelation::create($data, Model_Combo_HouseRelation::SITE_TYPE_JP)->save()) {
             $this->logMsg(sprintf('房源[%d]转移成功', $fixPlanHouseRelation['id']));
         } else {
             $this->logMsg(sprintf('房源[%d]转移失败', $fixPlanHouseRelation['id']));
         }
     }
 }
예제 #4
0
 /**
  * 把经纪人因为套餐到期停止推广的房源(套餐规定的可推广房源数)重新上线,(按房源发布时间 倒序排列)
  * @return string
  */
 private function reUpExpireHouse()
 {
     $currentCombo = Bll_Combo_Broker_BrokerComboInfo::getBrokerCurrentCombo($this->params['ajk_broker_id'], Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ);
     if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
         return $this->allReturn[] = '打通套餐,好租不处理';
     }
     // 当前在线房源数
     $onLineSpreadHouseCount = Bll_Combo_HouseRelation::getOnLineSpreadHouseCount($this->params['ajk_broker_id'], Bll_Combo_HouseRelation::SITE_TYPE_HZ);
     $comboProNum = Bll_Combo_Broker_BrokerComboInfo::getTotalCombosProNum($this->params['ajk_broker_id']);
     // 套餐可以推广的房源数
     $comboProNum = isset($comboProNum['totalRentPropNum']) ? $comboProNum['totalRentPropNum'] : 0;
     if (!$comboProNum) {
         return $this->allReturn[] = "套餐可以推广的房源数0";
     }
     if ($onLineSpreadHouseCount >= $comboProNum) {
         return $this->allReturn[] = "在线推广房源数{$onLineSpreadHouseCount}, 套餐可推广房源数{$comboProNum},不需要上线套餐到期的房子";
     }
     $shouldUpNum = $comboProNum - $onLineSpreadHouseCount;
     $allExpireRelations = Bll_Combo_HouseRelation::getHouseRelations($this->params['ajk_broker_id'], Bll_Combo_HouseRelation::SITE_TYPE_HZ, Model_Combo_HouseRelation::ENUM_COMBO_EXPIRE);
     if (empty($allExpireRelations)) {
         return $this->allReturn[] = "没有需要上线的推广房子";
     }
     // 房子有效性判断
     $num = 0;
     $shouldUpRelations = array();
     foreach ($allExpireRelations as $relation) {
         $proId = $relation['houseId'];
         if (!($propInfo = Bll_House_HzHouse::getPropInfo($proId, $relation['cityId'], 2))) {
             continue;
         }
         if (!$propInfo['status'] || in_array($propInfo['msg']['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             continue;
         }
         if ($num < $shouldUpNum) {
             $shouldUpRelations[] = $relation;
         }
         $num++;
     }
     foreach ($shouldUpRelations as $comboRelation) {
         $this->params['pro_id'] = $comboRelation['houseId'];
         // 更新关系
         Bll_Combo_HouseRelation::updateComboStatusById($comboRelation['id'], Model_Combo_HouseRelation::ENUM_HOUSE_ONLINE, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         // 维护房子状态
         Bll_HzPropBll::bulidHzProStatu($this->params['pro_id']);
         // 写入房源取消套餐推广日志
         $this->writePropLog(Const_ProLogType::LOG_ADD_INTO_COMBO, '开始套餐推广');
     }
 }
예제 #5
0
 /**
  * 105 删除房源
  *
  * <ol>
  * <li>
  * 查询房源信息是否存在<br>
  *      如果不存在,返回结束<br>
  *      如果存在,记录房源删除日志<br>
  * </li>
  *
  * <li>
  * 查询房源计划关系<br>
  *      如果不存在,返回结束<br>
  *      如果存在,更新关系状态为手动删除,记录房源移除计划日志<br>
  * </li>
  *
  * <li>
  * 查询计划信息<br>
  * (补充,计划状态直接从推列信息中获取,而不是直接从数据库中获取)
  *      如果计划不在推广,返回结束<br>
  *      如果计划正在推广, 记录房源取消推广日志,并停止竞价(暂未处理)<br>
  *      如果计划第二天推广, 记录房源取消第二天推广日志,并停止竞价(暂未处理)<br>
  * </li>
  * </ol>
  */
 public static function delete_prop($params)
 {
     $returnLog = array();
     array_push($returnLog, "队列(" . json_encode($params['id']) . ")开始处理");
     if (empty($params['pro_id'])) {
         array_push($returnLog, "房源ID为空");
         return self::build_return(1, $returnLog);
     }
     if (empty($params['city_id'])) {
         array_push($returnLog, "城市ID为空");
         return self::build_return(1, $returnLog);
     }
     //获取房源信息
     $propBll = new BLL_Property_Property();
     $propInfo = $propBll->getPropBaseInfoById($params['pro_id']);
     if (isset($propInfo[-9999])) {
         array_push($returnLog, "获取数据库中房源信息失败");
         return self::build_return(0, $returnLog);
     }
     if (empty($propInfo)) {
         array_push($returnLog, "房源信息为空");
         return self::build_return(1, $returnLog);
     }
     //房源信息存在写入房源删除信息
     $data = self::build_prop_log($params, 3, "房源删除" . ";队列表id为" . $params['id'], $params['broker_id']);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         array_push($returnLog, "房源删除日志写入失败");
         return self::build_return(0, $returnLog);
     }
     array_push($returnLog, "房源删除日志写入");
     /** 新端口经纪人判断 */
     if (Bll_City::isComboCity($params['city_id'])) {
         $houseRelationList = Bll_Combo_HouseRelation::getHouseRelation($params['broker_id'], $params['city_id'], array($params['pro_id']), Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         if (empty($houseRelationList)) {
             $returnLog[] = '房源套餐关系为空';
             return self::build_return(1, $returnLog);
         }
         /** 更新房源套餐推广关系 */
         foreach ($houseRelationList as $houseRelation) {
             if (1 != Bll_Combo_HouseRelation::updateComboStatusById($houseRelation['id'], Model_Combo_HouseRelation::ENUM_HOUSE_DELETE, Bll_Combo_HouseRelation::SITE_TYPE_AJK)) {
                 $returnLog[] = sprintf('更新房源的套餐推广关系失败[%d]', $houseRelation['id']);
                 continue;
             }
             $returnLog[] = sprintf('更新房源的套餐推广关系成功[%d]', $houseRelation['id']);
             if (Bll_Combo_HouseRelation::isRelationOnline($houseRelation['state'])) {
                 $data = self::build_prop_log($params, 21, '房源停止套餐推广;队列表id为' . $params['id'], $params['broker_id']);
                 if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                     $returnLog[] = '房源停止套餐推广日志写入失败';
                     return self::build_return(0, $returnLog);
                 }
                 $returnLog[] = '房源停止套餐推广日志写入';
             }
         }
         return self::build_return(1, $returnLog);
     }
     //查询房源计划关系
     $relationBll = new Bll_FixedSpread_PropFixedPlanRelation();
     $relationInfo = $relationBll->getProSpreadRelationByProId($params['pro_id'], $params['city_id']);
     if (empty($relationInfo)) {
         array_push($returnLog, "房源计划关系为空");
         return self::build_return(1, $returnLog);
     }
     /**
      * 修正房源的计划id
      */
     if (empty($params['plan_id'])) {
         $params['plan_id'] = $relationInfo['PlanId'];
     }
     if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) {
         //更新关系状态为删除房源
         if ($relationBll->updateFixedPlanStatu($params['pro_id'], $params['city_id'], 5)) {
             array_push($returnLog, "更新房源计划关系为删除房源");
         } else {
             array_push($returnLog, "更新房源计划关系为删除房源失败");
             return $returnLog;
         }
     }
     //写房源移出计划日志
     $data = self::build_prop_log($params, 11, "房源移出计划" . ";队列表id为" . $params['id'], $params['broker_id']);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         array_push($returnLog, "房源移出计划日志写入失败");
         return self::build_return(0, $returnLog);
     }
     array_push($returnLog, "房源移出计划日志写入");
     //获取计划信息
     $planBll = new Bll_Fixedspread_AjkFixedSpread();
     $planInfo = $planBll->getStaticPlanById($params['plan_id']);
     if (empty($planInfo)) {
         array_push($returnLog, "计划信息为空");
         return self::build_return(1, $returnLog);
     }
     $planStatus = $planBll->getFixedPlanStatus($planInfo['Status'], $planInfo['ViewTime']);
     //1. 刪除 2.推广中 3.第二天推广 4.账户没钱停止 5.手动停止
     switch ($planStatus) {
         case 1:
             array_push($returnLog, "计划状态已被置为删除");
             break;
         case 2:
             //todo 停止竞价
             //房源取消推广日志
             $data = self::build_prop_log($params, 6, "房源取消推广" . ";队列表id为" . $params['id'], $params['broker_id']);
             if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                 array_push($returnLog, "房源取消推广日志写入失败");
                 return self::build_return(0, $returnLog);
             }
             array_push($returnLog, "房源取消推广日志写入");
             break;
         case 3:
             //todo 停止竞价
             //房源取消第二天推广日志
             $data = self::build_prop_log($params, 12, "房源取消第二天推广" . ";队列表id为" . $params['id'], $params['broker_id']);
             if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                 array_push($returnLog, "房源取消第二天推广日志写入失败");
                 return self::build_return(0, $returnLog);
             }
             array_push($returnLog, "房源取消第二天推广日志写入");
             break;
         case 4:
             array_push($returnLog, "计划状态为账户没钱停止");
             break;
         case 5:
             array_push($returnLog, "计划状态为手动停止");
             break;
         default:
             break;
     }
     return self::build_return(1, $returnLog);
 }
예제 #6
0
 /**
  * 105 删除房源
  * 查询房源信息是否存在
  *   如果不存在 返回结束
  *   如果存在 记录房源删除日志 type=3
  * 查询房源计划关系
  *   如果不存在 返回结束
  *   如果存在 更新关系为手动删除6, 记录房源移除计划日志 type=11
  * 如有竞价 下竞价 更新房子
  */
 private function delete_prop()
 {
     $this->writePropLog(3, '手动删除');
     if ($this->params['isComboCity']) {
         if (!($comboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($this->params['pro_id'], Bll_Combo_HouseRelation::SITE_TYPE_HZ, true))) {
             return $this->allReturn[] = "房源{$this->params['pro_id']}套餐关系为空";
         }
         // 更新关系
         Bll_Combo_HouseRelation::updateComboStatusById($comboRelation['id'], Model_Combo_HouseRelation::ENUM_HOUSE_DELETE, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         // 写入房源取消套餐推广日志
         $this->writePropLog(Const_ProLogType::LOG_REMOVE_FROM_COMBO, '取消套餐推广');
     } else {
         // 查询定价关系
         if (!($fixPlanning = Model_Plan_HzPlanning::getPropFixPlan($this->params['pro_id'], true, true))) {
             return $this->allReturn[] = "房源{$this->params['pro_id']}定价关系为空";
         }
         // 如果is_valid=1 记录房源取消推广日志 type=6
         if ($fixPlanning['is_valid'] == 1) {
             $this->writePropLog(6, '取消推广');
         }
         if ($fixPlanning['is_valid'] == 2) {
             $this->writePropLog(12, '取消第二天推广');
         }
         // 更新关系状态为删除6,记录房源移除计划日志 type=11
         if (Model_Plan_HzPlanning::updatePropPlan($fixPlanning['id'], array('is_valid' => Const_HzPlan::DELETE))) {
             $this->writePropLog(11, '移除计划');
         }
     }
     $this->tempDoBid();
 }
 private function repairComboSpreadRelation($memberId, $houseId, $houseState, $houseType)
 {
     $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_DELETE;
     switch ($houseState) {
         case self::HOUSE_STATE_EXPIRED:
             $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_EXPIRE;
             break;
         case self::HOUSE_STATE_ILLEGAL:
             $relationState = Model_Combo_HouseRelation::ENUM_HOUSE_ILLEGAL;
             break;
     }
     $houseRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_JP);
     if (empty($houseRelation)) {
         $this->logMsg(sprintf('房源[%d - %d],没有获取到套餐关系', $houseId, $houseState));
         return;
     }
     /** 如果房源关系已经不是在线的,就不修复 */
     if (false == Bll_Combo_HouseRelation::isRelationOnline($houseRelation['state'])) {
         $this->logMsg(sprintf('房源[%d - %d]关系已经是不在线,不修复', $houseId, $houseRelation['state']));
         return;
     }
     /** 记录到文件里,方便发送邮件 */
     $emailContent = sprintf('房源[%d - %d],套餐推广关系[%d-%d]不一致' . PHP_EOL, $houseId, $houseState, $houseRelation['id'], $houseRelation['state']);
     file_put_contents($this->_email, $emailContent, FILE_APPEND);
     /** 修正房源套餐推广关系 */
     if (1 == Bll_Combo_HouseRelation::updateComboStatusById($houseRelation['id'], $relationState, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
         $this->logMsg(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复成功', $houseId, $houseState, $houseRelation['id'], $houseRelation['state']));
     } else {
         $this->logMsg(sprintf('房源[%d - %d],套餐推广关系[%d-%d]修复失败', $houseId, $houseState, $houseRelation['id'], $houseRelation['state']));
     }
     $this->noticeComboSolr($memberId, $houseId, $houseType);
 }