Ejemplo n.º 1
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)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'totalProps' => 0));
     }
     // 获取今日房源点击和消费记录
     $clicksInfo = Model_Stats_PropClick::getClickInfoByBrokerId($hzBrokerId, $cityId);
     // 统计今日竞价点击和消费
     $todayClicks = 0;
     $todayConsume = 0;
     foreach ($clicksInfo as $objClick) {
         $todayClicks += $objClick->bid_cnum;
         $todayConsume += $objClick->bid_cost;
     }
     // 获取竞价房源数
     $bidPropNum = Bll_HzBidPlan::get_broker_bidprop_count($hzBrokerId);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume / 100), 'todayConsumeUnit' => '元', 'totalProps' => $bidPropNum));
 }
Ejemplo n.º 2
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId);
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $cityId = $brokerInfo->cityId;
     if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_NOT_CHOICE_CITY, 'message' => '非精选城市');
     }
     $bllChoice = new Bll_Zufang_Choice();
     $today = date('Ymd');
     $choiceInfo = $bllChoice->get_choice_info($hzBrokerId, $today, $cityId);
     $todayClicks = intval($choiceInfo[0]['bidClicks']);
     $todayConsume = intval($choiceInfo[0]['bidConsume']) / 100;
     // 获取精选推广房源数(精选计划和房源一一对应)
     $plansIds = array();
     $plans = $bllChoice->get_active_choice_plans($hzBrokerId, array(1, 13, 2, 3, 7, 8));
     foreach ($plans as $plan) {
         $plansIds[] = $plan->id;
     }
     $props = array();
     if ($plansIds) {
         $props = $bllChoice->get_prop($plansIds);
     }
     $totalProps = count($props);
     //将精选状态变化数目归零
     $keyData = array('brokerId' => $brokerId, 'bizType' => Model_Mobile_PropRedDot::TYPE_CHOICE_STATUS);
     $data = array('num' => 0);
     Bll_Mobile_PropRedDot::getInstance()->updateData($keyData, $data);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume), 'todayConsumeUnit' => '元', 'totalProps' => $totalProps));
 }
Ejemplo n.º 3
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     // 判断经纪人是否存在
     $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);
     }
     // 获取房源信息
     $prop = Model_House_HzProp::findByPropId($propId);
     /* @var Model_House_HzProp $prop */
     if (!$prop) {
         throw new Exception_Property_NotFound("Zufang propId: {$propId}");
     }
     // TODO 是否需要判断房源是否已删除
     // 判断房源是否属于经纪人
     if ($prop->getContentBasic('userid') != $hzBrokerId) {
         throw new Exception_Property_NotFound("Zufang propId: {$propId} not belog to broker: {$brokerId}");
     }
     // 准备默认返回数据(房源未竞价)
     $data = array('planId' => 0, 'status' => 0, 'rank' => -1, 'rankMsg' => '已暂停', 'todayClicks' => 0, 'totalClicks' => 0, 'clickPrice' => 0, 'clickPriceUnit' => '元', 'minClickPrice' => $prop->getBidMinClickPrice(), 'minClickPriceUnit' => '元', 'budget' => 0, 'budgetUnit' => '元', 'budgetRemain' => 0, 'budgetRemainUnit' => '元');
     // 获取竞价计划
     $bidPlan = $prop->getBidPlan();
     if (!$bidPlan) {
         // 判断房源是否多图房源
         if (!$prop->isMultiImages()) {
             throw new Exception_Property_NotMultiImages("Zufang propId: {$propId}");
         }
         // TODO 判断是否定价推广(也许可以不用,因为只有从定价推广房源列表点进去的房源详情页才会请求该接口)
     } else {
         // 竞价计划ID
         $data['planId'] = $bidPlan['id'];
         // 竞价计划状态
         switch ($bidPlan['status']) {
             case Const_HzPlan::SPREAD:
                 $data['status'] = 1;
                 // 推广中 or 排队中
                 break;
             case Const_HzPlan::MENUOVER:
                 $data['status'] = 2;
                 // 已暂停
                 break;
         }
         // 竞价预算
         $data['budget'] = round($bidPlan['amount'], 2);
         // 竞价预算余额
         $data['budgetRemain'] = round($bidPlan['amount'] - $bidPlan['total_consume'], 2);
         // 竞价排名
         if ($data['status'] == 1) {
             $data['rank'] = Bll_HzBidPlan::get_bid_rank($prop->getContentBasic(), $cityId);
             if ($data['rank'] <= 5) {
                 $data['rankMsg'] = '';
             } else {
                 $data['rankMsg'] = '排队中';
             }
         }
         // 竞价点击单价
         $bidRelation = $prop->getBidRelation();
         $data['clickPrice'] = round($bidRelation['unit_price'], 2);
         // 竞价点击底价
         $data['minClickPrice'] = round($prop->getBidMinClickPrice(), 2);
         // 今日竞价点击量
         $data['todayClicks'] = $prop->getTodayClickSums('bid');
         // 竞价点击总量
         $data['totalClicks'] = $prop->getTotalClickSums('bid');
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
Ejemplo n.º 4
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);
 }