Exemple #1
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     //根据安居客经纪人ID获取好租经纪人ID
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId);
     //获取租房定价信息
     $fixPlansInfo = Bll_HzFixPlan::get_broker_fixplans($hzBrokerId);
     //获取竞价计划状态
     $fixPlanStatus = $fixPlansInfo[0]['status'] == 1 ? V1_Zufang_Fix_SummaryController::RETURN_CODE_NUM_1 : V1_Zufang_Fix_SummaryController::RETURN_CODE_NUM_0;
     //获取计划ID
     $fixPlanId = $fixPlansInfo[0]['id'];
     $cityId = $fixPlansInfo[0]['city_id'];
     //获取租房点击和花费信息
     $promotion = Dao_Broker_HzPlan::get_plan_fee($hzBrokerId, $fixPlanId, date('Ymd'), 1);
     // 获取租房今日点击
     $fixPropIds = Model_Plan_HzPlanning::getFixPropIdsByPlanId($fixPlanId);
     $clicks = Model_Stats_PropClick::getPropBidClick($fixPropIds, $hzBrokerId, $cityId);
     $fixClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($clicks, 'fix');
     $todayClicks = 0;
     foreach ($fixClickSums as $clickSum) {
         $todayClicks += $clickSum;
     }
     //租房某计划的房源总量
     $totalProps = Model_Plan_HzPlanning::getFixPlanPropNum($fixPlanId);
     //查询经纪人新封顶模式信息
     //todo 等多档封顶合并了方法迁移到多档封顶
     $ppcLimitInfo = $this->getPpcBrokerLimitInfo($ajkBrokerId, V1_Zufang_Fix_SummaryController::PPC_BROKER_LIMIT_HZ_SITE);
     if (!$ppcLimitInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => '封顶数据未能取到!');
     }
     $todayConsume = $promotion[$fixPlanId]['total_cost'] ? $promotion[$fixPlanId]['total_cost'] : 0;
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('planId' => $fixPlanId, 'todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume), 'todayConsumeUnit' => '元', 'totalProps' => $totalProps, 'planStatus' => $fixPlanStatus, 'budget' => $ppcLimitInfo['amountLimit'] / 100, 'budgetUnit' => '元'));
 }
Exemple #2
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     // 判断经纪人是否存在
     $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId);
     if (!$hzBrokerId || !$broker) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $broker['cityId'];
     if (!Bll_City::isBidCity($cityId)) {
         throw new Exception_City_NotBidCity('CityId: ' . $cityId);
     }
     // 获取竞价房源
     $finalProps = array();
     $bidProps = Bll_HzBidPlan::get_broker_bidprop($hzBrokerId, $cityId);
     foreach ($bidProps as $bidProp) {
         $row = array();
         $row['propId'] = $bidProp['proid'];
         $row['title'] = $bidProp['prop']['content_basic']['title'];
         $row['imgUrl'] = '';
         $row['commId'] = $bidProp['prop']['content_basic']['commid'];
         $row['commName'] = $bidProp['prop']['content_basic']['commname'];
         $row['roomNum'] = $bidProp['prop']['content_basic']['roomnum'];
         $row['hallNum'] = $bidProp['prop']['content_basic']['hallnum'];
         $row['toiletNum'] = $bidProp['prop']['content_basic']['toilnetnum'];
         $row['area'] = round($bidProp['prop']['content_basic']['areanum']);
         $row['price'] = round($bidProp['prop']['content_basic']['pricenum']);
         $row['priceUnit'] = "元/月";
         $row['totalClicks'] = 0;
         $row['isBid'] = 1;
         $row['isChoice'] = 0;
         $row['isVisible'] = (int) ($bidProp['content_basic']['status'] != 6);
         $row['isMoreImg'] = (int) $bidProp['content_basic']['quality'];
         $row['isPhonePub'] = (int) (isset($bidProp['content_basic']['from']) && $bidProp['content_basic']['from'] == 'mobile-ajk-broker');
         // TODO 批量判定 增加委托房源标签
         $isEntrust = Bll_Zufang_Choice::isCommissionHouse($bidProp['proid'], $brokerId, Model_House_Commission::TYPE_RENT);
         if ($isEntrust) {
             $row['isEntrust'] = 1;
         } else {
             $row['isEntrust'] = 0;
         }
         // 确认房源分组
         // TODO 基于Rank获取分组可能对页面速度有一定影响
         $row['rank'] = $bidProp['rank'];
         if ($row['rank'] === '已暂停') {
             $row['group'] = 'offline';
         } elseif ($row['rank'] === '排队中') {
             $row['group'] = 'queued';
         } else {
             $row['group'] = 'online';
         }
         $finalProps[$row['propId']] = $row;
     }
     if ($finalProps) {
         $propIds = array_keys($finalProps);
         // 批量获取房源的默认图片
         $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
         foreach ($defaultImages as $defaultImage) {
             $finalProps[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
         // 批量获取房源的竞价总点击
         $bidClicks = Model_Stats_PropClick::getPropAllClicks($propIds, $brokerId, $cityId);
         $bidClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($bidClicks, 'bid');
         foreach ($bidClickSums as $propId => $bidClickSum) {
             $finalProps[$propId]['totalClicks'] = $bidClickSum;
         }
     }
     // 排序 • 按ID倒序
     ksort($finalProps);
     // 分组
     $props = array('onlinePropertyList' => array(), 'queuedPropertyList' => array(), 'offlinePropertyList' => array());
     foreach ($finalProps as $finalProp) {
         switch ($finalProp['group']) {
             case 'online':
                 $props['onlinePropertyList'][] = $finalProp;
                 break;
             case 'queued':
                 $props['queuedPropertyList'][] = $finalProp;
                 break;
             case 'offline':
                 $props['offlinePropertyList'][] = $finalProp;
                 break;
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $props);
 }