Пример #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' => '元'));
 }
Пример #2
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     //检查经纪人是否存在
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $brokerInfo->cityId;
     if (!Bll_City::isBidCity($cityId)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'totalProps' => 0));
     }
     $data = array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元');
     $datei = date('Ymd');
     //获取经纪人竞价推广某天的点击和花费信息
     $allClickAndCostInfo = Model_Plan_HpProStatsDay::getBrokerClickAndCostDay($brokerId, $cityId, $datei);
     foreach ($allClickAndCostInfo as $row) {
         $data['todayClicks'] += $row->cnum;
         $data['todayConsume'] += $row->amount / 100;
     }
     $data['todayConsume'] = Util_Formatter::formatTodayConsume($data['todayConsume']);
     //获取计划数
     $data['totalProps'] = Model_Plan_EsfAjkPropSpread::getPlanCountByBroker($brokerId, Model_Plan_EsfAjkPropSpread::DEFAULTVERSION);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
Пример #3
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));
 }
Пример #4
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));
 }
Пример #5
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $plans = Model_Plan_EsfFixedPlan::getValidPlan($brokerId);
     $props = 0;
     $result['status'] = 'ok';
     if (!empty($plans)) {
         $planId = $plans['id'];
         $cityId = $plans['cityid'] ?: 0;
         $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($planId, $cityId);
         if (!empty($relations)) {
             $propIds = array();
             foreach ($relations as $row) {
                 $propIds[] = $row['proId'];
             }
             $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
             $props = count($houseInfo);
         }
         $planBll = new DAO_My_Ppc_PlanOpe();
         $clicks = $planBll->planTodayNewCost($planId);
         $data['planId'] = $planId;
         $data['todayClicks'] = $clicks['allclick'];
         $data['todayConsume'] = Util_Formatter::formatTodayConsume($clicks['allamount']);
         $data['todayConsumeUnit'] = '元';
         $data['totalProps'] = $props;
         //获取计划状态
         $api_url = '/service-ppc/rest/ppc/getPpcPlan/' . $planId . '?resType=1';
         $plan_info = Util_CallAPI::get_data_from_java_api($api_url);
         $data['planStatus'] = $plan_info['data']['plan']['statusDescrip'] == '推广中' ? 1 : 0;
         $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId);
         $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0;
         $data['budgetUnit'] = '元';
     } else {
         $brokerInfo = Model_Broker_AjkBrokerExtend::getDataByBrokerId($brokerId);
         $planId = Model_Plan_EsfFixedPlan::addPlan('定价推广组', 1, $brokerInfo->cityId, $brokerInfo->userId, $brokerInfo->brokerId);
         $data['planId'] = $planId;
         $data['todayClicks'] = $data['todayConsume'] = $data['totalProps'] = $data['planStatus'] = 0;
         $data['todayConsumeUnit'] = $data['budgetUnit'] = '元';
         $limitInfo = Bll_Fixedspread_AjkFixedSpread::getLimitInfo($brokerId);
         $data['budget'] = !empty($limitInfo) ? round($limitInfo['amountLimit'] / 100, 2) : 0;
     }
     $result['data'] = $data;
     return $result;
 }
Пример #6
0
 /**
  * 获取精选概况
  *
  * @param $brokerId
  * @return array|bool
  */
 public function getBrokerChoiceSummary($brokerId)
 {
     try {
         //获取经纪人基本信息
         $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
         if (empty($brokerBaseInfo)) {
             $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG);
         }
         $cityId = $brokerBaseInfo->cityId;
         //判断经纪人城市是否开通精选
         if (!$this->checkChoiceOpen($brokerBaseInfo->cityId)) {
             $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG);
         }
         //初始化返回数组
         $data = array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'totalProps' => 0);
         //获取所有点击和话费相关信息
         $bidBll = new Bll_Plan_Bid_EsfBid();
         if (($todayClickAndCostInfo = $bidBll->getBrokerClickAndCostDay($brokerId, date('Ymd'), $cityId)) === false) {
             $this->error($bidBll->errorCode, $bidBll->errorMsg);
         }
         $data['todayClicks'] = $todayClickAndCostInfo['todayClicks'];
         $data['todayConsume'] = Util_Formatter::formatTodayConsume($todayClickAndCostInfo['todayConsume']);
         //获取精选计划数
         $data['totalProps'] = Model_Plan_EsfAjkPropSpread::getPlanCountByBroker($brokerId, Model_Plan_EsfAjkPropSpread::CHOICEVERSION);
         return $data;
     } catch (Exception $e) {
         if ($e instanceof Exception_BllErrorException) {
             $this->errorCode = $e->getCode();
         } else {
             $this->errorCode = self::UNKNOW_ERROR;
         }
         $this->errorMsg = $e->getMessage();
         return false;
     }
 }