Пример #1
0
 /**
  * 小区合并修改计划信息
  *
  * @param $queue
  * @return bool
  */
 public function communityMerge($queue)
 {
     if ($queue['planId'] == 0 || $queue['proId'] == 0) {
         $this->setMsg('房源Id、计划Id不能为空');
         return false;
     }
     /** 判断计划状态 */
     $planInfo = Model_Plan_EsfAjkPropSpread::getPlanInfoByIdEx($queue['planId']);
     if ($planInfo['tradetype'] != 1 || $planInfo['bidVersion'] != 2) {
         $this->setMsg(sprintf('计划[%d]信息错误[%d - %d]', $queue['planId'], $planInfo['tradetype'], $planInfo['bidVersion']));
         return false;
     }
     if ($planInfo['status'] != Model_Plan_EsfAjkPropSpread::ONLINE && $planInfo['status'] != Model_Plan_EsfAjkPropSpread::ONQUEUE) {
         $this->setMsg(sprintf('计划[%d]不在推广、排队中[%d]', $queue['planId'], $planInfo['status']));
         return true;
     }
     if ($planInfo['propId'] != $queue['proId']) {
         $this->setMsg(sprintf('房源Id[%d - %d]不一致', $queue['proId'], $planInfo['propId']));
         return true;
     }
     $houseInfo = Bll_House_EsfHouse::getHouseBaseInfoEx($queue['proId'], $planInfo['cityId']);
     if (empty($houseInfo)) {
         $this->setMsg(sprintf('房源[%d]信息没有获取到', $queue['proId']));
         return true;
     }
     $housePrice = intval($houseInfo['proPrice'] * 10000);
     $priceIntervalInfo = Model_House_EsfPrice::get_price($planInfo['cityId'], $housePrice);
     if (empty($priceIntervalInfo)) {
         $this->setMsg(sprintf('房源[%d]没有获取到价格段信息[%d]', $queue['proId'], $housePrice));
         return true;
     }
     $priceId = $priceIntervalInfo['id'];
     $communityId = $houseInfo['commId'];
     $data = array('commId' => $communityId);
     if (!Model_Plan_EsfAjkPropSpread::updatePlan($queue['planId'], $data)) {
         $this->setMsg(sprintf('更新计划[%d]信息[%s]失败', $queue['planId'], json_encode($data)));
         return false;
     }
     $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($communityId, $priceId);
     if (empty($bucketInfo)) {
         Model_Choice_EsfBidBucket::init_bucket_info($communityId, $priceId, $planInfo['cityId']);
     }
     Model_Choice_EsfBidBucket::increment_used_num_ex($communityId, $priceId);
     $this->setMsg(sprintf('更新计划[%d]信息[%s]成功', $queue['planId'], json_encode($data)));
     $planInfo['proPriceInt'] = $planInfo['propriceint'];
     //todo 添加房源日志 type 小区合并,区域板块变更
     Model_Log_HouseLogNew::create(array('houseId' => $queue['propId'], 'planId' => $queue['planId'], 'brokerId' => $queue['brokerId'], 'cityId' => $planInfo['cityId'], 'type' => Const_ProLogType::LOG_COMMUNITY_MERGE_PROP_CHANGE, 'changeType' => Const_ProPlanChangeType::COMM_MERGE_PROP_CHANGE, 'remark' => '小区合并,精选房源信息变更', 'operatorId' => $this->qInfo['operationId'], 'siteType' => 1), date('Ymd'))->save();
     return $this->choiceComputeRank(array_merge($planInfo, $data));
 }