コード例 #1
0
ファイル: EsfBid.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 获取经纪人一天的点击和话费
  * 直接为controller调用
  *
  * @param $brokerId
  * @param $datei
  * @return array|bool
  */
 public function getBrokerClickAndCostDay($brokerId, $datei, $cityId = false)
 {
     try {
         if (!$cityId) {
             //获取经纪人基本信息
             $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
             if (empty($brokerBaseInfo)) {
                 $this->error(bll_choice_EsfAPPAPIChoice::EMPTY_BROKER_ERROR, bll_choice_EsfAPPAPIChoice::EMPTY_BROKER_ERROR_MSG);
             }
             $cityId = $brokerBaseInfo->cityId;
         }
         //获取点击和花费信息
         $data = array('todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元');
         $allClickAndCostInfo = Model_Plan_HpProStatsDay::getBrokerClickAndCostDay($brokerId, $cityId, $datei);
         foreach ($allClickAndCostInfo as $row) {
             $data['todayClicks'] += $row->cnum;
             $data['todayConsume'] += $row->amount / 100;
         }
         return $data;
     } catch (Exception $e) {
         if ($e instanceof Exception_BllErrorException) {
             $this->errorCode = $e->getCode();
         } else {
             $this->errorCode = bll_choice_EsfAPPAPIChoice::UNKNOW_ERROR;
         }
         $this->errorMsg = $e->getMessage();
         return false;
     }
 }
コード例 #2
0
ファイル: Summary.php プロジェクト: emilymwang8/ajk-broker
 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);
 }