예제 #1
0
 public function handle_request_combo()
 {
     $ajkBrokerId = $this->brokerId;
     $cityId = $this->cityId;
     $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ;
     //首先获取套餐关系房源列表 ---- 那房源到主表去除status 已删除的房源 -----在房源主表获取房源基本信息
     $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, $siteType, 1);
     $surplus = $hasCombo = 0;
     //获取套餐信息-首先判断经纪人有无套餐
     $comboInfos = Bll_Combo_Broker_BrokerComboInfo::getComboListBySite($ajkBrokerId, $siteType);
     if (count($comboInfos) > 0) {
         $index = Bll_Combo_Broker_BrokerComboInfo::getComboIndexBySiteType($siteType);
         $currentTime = time();
         foreach ($comboInfos as $combo) {
             if ($combo[$index] == 0) {
                 continue;
             }
             if (strtotime($combo['endTime']) > $currentTime && strtotime($combo['startTime']) < $currentTime) {
                 $currentCombo = $combo;
             }
         }
         if (!empty($currentCombo)) {
             $surplus = $currentCombo['rentPropNum'];
             if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
                 //商业地产没打通
                 $surplus = $currentCombo['rentPropNum'] + $currentCombo['salePropNum'];
             }
             $hasCombo = 1;
         }
     }
     //获取当前已推广套餐数量
     if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($ajkBrokerId, $siteType, true);
     } else {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($ajkBrokerId, $cityId, $siteType);
     }
     $rstList = array();
     if (empty($comboInfos)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $rstList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboList as $row) {
         $propIds[] = $row['houseId'];
     }
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId);
     $comboPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId);
     foreach ($comboPropList as $key => $list) {
         if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             unset($comboPropList[$key]);
         }
     }
     //fix bug45133
     if (empty($comboPropList)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $rstList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboPropList as $row) {
         $propIds[] = $row['proid'];
     }
     //从主表获取房源信息
     $propertyList = Model_House_HzProp::getPropsByPropIds($propIds);
     //获取是否精选或者竞价
     $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
     if (!empty($relations)) {
         $planPropMap = array();
         foreach ($relations as $relation) {
             $planIds[] = $relation['plan_id'];
             $planPropMap[$relation['plan_id']] = $relation['proid'];
         }
         if (!empty($planIds)) {
             $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
             foreach ($plans as $plan) {
                 if ($plan->flag == 0) {
                     continue;
                 }
                 if ($plan->bid_version == 2) {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isChoice'] = 1;
                     //精选状态
                     if ($plan['status'] == 1) {
                         $propertyList[$propId]['choiceStatus'] = 3;
                         $propertyList[$propId]['choiceStatusName'] = '精选中';
                     } elseif ($plan['status'] == 13) {
                         $propertyList[$propId]['choiceStatus'] = 4;
                         $propertyList[$propId]['choiceStatusName'] = '排队中';
                     }
                 } else {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isBid'] = 1;
                 }
             }
         }
     }
     // 批量获取房源的默认图片
     $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
     if (!empty($defaultImages)) {
         foreach ($defaultImages as $defaultImage) {
             $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
     }
     krsort($propertyList);
     $startDate = $endDate = date('Ymd');
     $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ);
     $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($ajkBrokerId, $propIds, $cityId);
     //城市是否开通精选
     $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::HAOZU);
     foreach ($propertyList as $list) {
         $row = array();
         $row['id'] = $list['propId'];
         $row['propId'] = $list['propId'];
         $row['title'] = $list['title'];
         $row['imgUrl'] = $list['imgUrl'] ?: '';
         $row['commId'] = $list['commid'];
         $row['commName'] = $list['commname'];
         $row['roomNum'] = $list['roomnum'];
         $row['hallNum'] = $list['hallnum'];
         $row['toiletNum'] = $list['toilnetnum'];
         $row['area'] = round($list['areanum']);
         $row['price'] = round($list['pricenum']);
         $row['priceUnit'] = '元/月';
         $row['todayClicks'] = $todayClicks[$list['propId']][$startDate] ?: 0;
         $row['totalClicks'] = $totalClicks[$list['propId']] ?: 0;
         $row['totalClicks'] = $row['totalClicks'] + $row['todayClicks'];
         $row['isBid'] = isset($list['isBid']) ? $list['isBid'] : 0;
         $row['isChoice'] = isset($list['isChoice']) ? $list['isChoice'] : 0;
         $row['isVisible'] = (int) ($list['status'] != 6);
         $row['isMoreImg'] = (int) $list['quality'];
         $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker');
         $row['publishDays'] = floor((time() - $list['created']) / 86400);
         $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布';
         $row['createTime'] = date('Y-m-d H:i:s', $list['created']);
         //是否委托
         $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT);
         $row['isEntrust'] = $isEntrust ? 1 : 0;
         if (isset($list['choiceStatus']) && isset($list['choiceStatusName']) && $cityIsChoice) {
             $row['choiceStatus'] = $list['choiceStatus'];
             $row['choiceStatusName'] = $list['choiceStatusName'];
         } else {
             $choiceStatus = Bll_HzProp::getZuFangChoiceStatus($list, $cityId, $cityIsChoice);
             $row['choiceStatus'] = $choiceStatus['choiceStatus'];
             $row['choiceStatusName'] = $choiceStatus['choiceStatusName'];
         }
         $rstList[] = $row;
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $rstList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
 }
예제 #2
0
 public function handle_request_combo()
 {
     $brokerId = $this->brokerId;
     $cityId = $this->cityId;
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId);
     //获取所有有效房源
     $props = Bll_House_HzHouse::getValidPropsByBrokerId($hzBrokerId, $cityId);
     $propertyList = array();
     if (!empty($props)) {
         //获取套餐推广房源列表
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1);
         //获取精选房源列表
         $bllChoice = new Bll_Zufang_Choice();
         $choices = $bllChoice->get_active_choice_plans($hzBrokerId, array(1, 13, 2, 3, 7, 8));
         $choicePropIds = array();
         if (!empty($choices)) {
             $keyedPlans = array();
             foreach ($choices as $choice) {
                 $keyedPlans[$choice->id] = $choice;
             }
             // 获取所有的房源和精选的关系
             $choiceRelations = $bllChoice->get_prop(array_keys($keyedPlans));
             foreach ($choiceRelations as $choiceRelation) {
                 $choicePropIds[] = $choiceRelation->proid;
             }
         }
         //所有有效房源-套餐推广房源-精选推广房源 = 待推广房源
         if (!empty($comboList)) {
             foreach ($comboList as $row) {
                 unset($props[$row['houseId']]);
             }
         }
         if (!empty($choicePropIds)) {
             foreach ($choicePropIds as $k => $v) {
                 unset($props[$v]);
             }
         }
         if (!empty($props)) {
             // 批量获取房源的默认图片
             $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds(array_keys($props));
             if (!empty($defaultImages)) {
                 foreach ($defaultImages as $defaultImage) {
                     $props[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
                 }
             }
             //是否是精选城市,城市是否精选分离
             $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::HAOZU);
             $cityIsChoiceIndependent = Bll_City::isChoiceIndependentCity($cityId, Const_Site::HAOZU);
             foreach ($props as $list) {
                 $row = array();
                 $row['id'] = $row['propId'] = $list['propId'];
                 $row['title'] = $list['title'];
                 $row['imgUrl'] = $list['imgUrl'] ?: '';
                 $row['commId'] = $list['commid'];
                 $row['commName'] = $list['commname'];
                 $row['roomNum'] = $list['roomnum'];
                 $row['hallNum'] = $list['hallnum'];
                 $row['toiletNum'] = $list['toilnetnum'];
                 $row['area'] = round($list['areanum']);
                 $row['price'] = round($list['pricenum']);
                 $row['priceUnit'] = '元/月';
                 $row['todayClicks'] = $row['totalClicks'] = $row['isBid'] = $row['isChoice'] = 0;
                 $row['isVisible'] = (int) ($list['status'] != 6);
                 $row['isMoreImg'] = (int) $list['quality'];
                 $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker');
                 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $brokerId, Model_House_Commission::TYPE_RENT);
                 $row['isEntrust'] = $isEntrust ? 1 : 0;
                 $row['createTime'] = date('Y-m-d H:i:s', $list['created']);
                 //精选状态
                 $choiceStatus = Bll_HzProp::getZuFangChoiceStatus($list, $cityId, $cityIsChoice);
                 if (!$cityIsChoiceIndependent && $choiceStatus['choiceStatus']) {
                     //城市未精选分离
                     $choiceStatus['choiceStatus'] = 0;
                     $choiceStatus['choiceStatusName'] = '';
                 }
                 $row['choiceStatus'] = $choiceStatus['choiceStatus'];
                 $row['choiceStatusName'] = $choiceStatus['choiceStatusName'];
                 $propertyList[] = $row;
             }
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => $propertyList));
 }