コード例 #1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     //经纪人信息
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $communityList = array();
     $cityId = $brokerInfo->cityId;
     $hzBrokerId = Model_Broker_HzMapping::get_hz_broker_id($brokerId);
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         /** 租房 */
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1);
         //套餐列表
         $propIds = array();
         foreach ($comboList as $combo) {
             $propIds[] = $combo['houseId'];
         }
         if ($propIds && $hzBrokerId) {
             $hzPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $cityId);
             //房源信息
             foreach ($hzPropList as $list) {
                 //过滤无效房源
                 if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
                     continue;
                 }
                 $row = array();
                 $row['commId'] = $list['commid'];
                 $row['commName'] = $list['commname'];
                 $communityList[$list['commid']] = $row;
             }
         }
         /** 二手房 */
         $comboSpreadHouseList = Bll_Broker_Combo_ManageAjk::getComboSpreadHouseList($brokerId, $cityId);
         if ($comboSpreadHouseList) {
             //获取房源信息
             $propIds = array_keys($comboSpreadHouseList);
             $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
             foreach ($propsInfo as $prop) {
                 $row = array();
                 $row['commId'] = $prop->commId;
                 $row['commName'] = $prop->commName;
                 $communityList[$prop->commId] = $row;
             }
         }
     } else {
         //定价的情况
         $brokerProps = Bll_Broker_HzBroker::getBrokerProps($brokerId, $cityId);
         // 获取房源关系列表
         if ($brokerProps['status']) {
             /** 租房*/
             $brokerProps = $brokerProps['msg'];
             $plans = $brokerProps['plans'][0];
             //定价计划
             $plannings = $brokerProps['plannings'];
             //计划房源关系
             $propsTemp = $brokerProps['props'];
             //定价房源
             if (empty($plans)) {
                 $hzPropList = array();
             } else {
                 $hzPropList = array();
                 foreach ($propsTemp as $prop) {
                     $hzPropList[$prop['proId']] = $prop;
                 }
                 foreach ($plannings as $key => $planning) {
                     // 非有效 过滤掉
                     if (!Bll_HzFixPlan::isValidPlanning($planning['isValid'])) {
                         unset($hzPropList[$planning['proId']]);
                     }
                 }
             }
             foreach ($hzPropList as $prop) {
                 $row = array();
                 $row['commId'] = $prop['commId'];
                 $row['commName'] = $prop['commName'];
                 $communityList[$prop['commId']] = $row;
             }
         }
         /** 二手房*/
         //获取经纪人有效定价计划  计划表
         $fixSpreadPlanList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList($brokerId);
         $fixPlanId = $fixSpreadPlanList[0]['id'];
         //关系表中获取房源;
         if ($fixPlanId) {
             $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($fixPlanId, $cityId);
             $propIds = array();
             foreach ($relations as $relation) {
                 $propIds[] = $relation['proId'];
             }
             if ($propIds) {
                 $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
                 foreach ($propsInfo as $prop) {
                     $row = array();
                     $row['commId'] = $prop->commId;
                     $row['commName'] = $prop->commName;
                     $communityList[$prop->commId] = $row;
                 }
             }
         }
     }
     //对小区按首字母排序
     $communityList = $this->communitySortByCommCode($communityList);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('communityList' => array_values($communityList)));
 }
コード例 #2
0
ファイル: HzPropList.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 组装定价列表
  * @param $out
  * @return array
  * @throws Exception
  */
 private static function prepareFixList(&$out)
 {
     $fixList = array();
     $out['planId'] = 0;
     $out['props'] = array();
     $out['fixPropIds'] = array();
     // 获取房源关系列表
     $brokerProps = Bll_Broker_HzBroker::getBrokerProps($out['ajkBrokerId'], $out['cityId']);
     if (!$brokerProps['status']) {
         throw new Exception($brokerProps['msg']);
     }
     $brokerProps = $brokerProps['msg'];
     $plans = $brokerProps['plans'];
     $plannings = $brokerProps['plannings'];
     $propsTemp = $brokerProps['props'];
     if (empty($plans)) {
         // 没有有效计划 初始化一个
         Bll_Plan_Fix_HzFix::createPlan($out['ajkBrokerId'], $out['cityId'], '定价推广组');
         return $fixList;
     }
     $planIds = array();
     foreach ($plans as $plan) {
         $planIds[] = $plan['planId'];
     }
     // 转换成proid下标方便索引
     if (count($propsTemp) > 0) {
         foreach ($propsTemp as $prop) {
             $out['props'][$prop['proId']] = $prop;
         }
     }
     // 获取计划的消费 点击信息
     $responseConsumClickInfos = Bll_Plan_Fix_HzFix::getPlanConsumClickInfo($planIds, $out['cityId'], $out['ajkBrokerId']);
     if (!$responseConsumClickInfos['status']) {
         throw new Exception($responseConsumClickInfos['msg']);
     }
     $responseConsumClickInfos = $responseConsumClickInfos['msg'];
     // 分组
     $temProps = array();
     foreach ($plans as $plan) {
         $planId = $plan['planId'];
         $fixList[$planId] = $plan;
         // 组装计划的消费 点击量信息
         foreach ($responseConsumClickInfos[$planId] as $field => $value) {
             $fixList[$planId][$field] = $value;
         }
         // 非在线 获取停止信息
         if ($plan['status'] != 1) {
             $fixList[$planId]['stopInfo'] = Bll_Plan_Fix_HzFix::getStopInfoByStatus($plan['status'], $out['isPassVerify']);
         }
         if (empty($plannings)) {
             $fixList[$planId]['plannings'] = array();
             continue;
         }
         // 关系需要按照推广时间最新排在前面
         usort($plannings, function ($a, $b) {
             return strtotime($a['lastUpdated']) > strtotime($b['lastUpdated']) ? -1 : 1;
         });
         foreach ($plannings as $k => $planning) {
             $proId = $planning['proId'];
             // 非有效 过滤掉
             if (!Bll_HzFixPlan::isValidPlanning($planning['isValid'])) {
                 unset($out['props'][$proId]);
                 continue;
             }
             if ($planning['planId'] != $planId) {
                 continue;
             }
             // 组装关系
             $fixList[$planId]['plannings'][$k] = $planning;
             // 组装房子
             $fixList[$planId]['plannings'][$k]['prop'] = isset($out['props'][$proId]) ? $out['props'][$proId] : array();
             // 获取剩余时间
             $fixList[$planId]['plannings'][$k]['prop']['leftDays'] = Bll_House_HzHouse::getLeftDays($out['props'][$proId]['created']);
             $out['fixPropIds'][$proId] = $proId;
             $temProps[] = $fixList[$planId]['plannings'][$k]['prop'];
         }
         $out['planId'] = $planId;
     }
     // 获取定价房子可否精选状态
     if ($out['isChoiceCity']) {
         $out['propChoiceStatus'] = Bll_HzProp::getPropChoiceStatus($temProps, $out['cityId']);
     }
     return $fixList;
 }