예제 #1
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);
 }
예제 #2
0
 /**
  * 获取二手房竞价计划点击量
  *
  * @param $params
  * @return array
  */
 private function do_esf_click($params)
 {
     $params['houseid'] = trim($params['houseid'], ',');
     if (empty($params['houseid'])) {
         return array();
     }
     /**
      * @var $request AJKRequest
      */
     $request = APF::get_instance()->get_request();
     $cityId = $request->getBrokerCityId();
     $houseId = explode(',', $params['houseid']);
     if (empty($houseId[count($houseId) - 1])) {
         unset($houseId[count($houseId) - 1]);
     }
     if ($houseId) {
         $result = Model_Plan_HpProStatsDay::data_access($cityId)->filter_by_op('proId', 'in', $houseId)->filter_by_op('datei', '=', date('Ymd'))->find();
     } else {
         $result = array();
     }
     $rstArr = array();
     foreach ($result as $k => $v) {
         $base = isset($rstArr[$v->proId]) ? $rstArr[$v->proId] : 0;
         $rstArr[$v->proId] = $base + $v->cnum;
     }
     return $rstArr;
 }
예제 #3
0
 /**
  * 根据房源ID获取总点击和话费
  *
  * @param $propIds
  */
 public function getPropTotalClicksAndCost($propIds, $cityId)
 {
     $data = array();
     $allClickAndCostInfo = Model_Plan_HpProStatsDay::getPropClickAndCost($propIds, $cityId);
     foreach ($allClickAndCostInfo as $row) {
         if (isset($data[$row->proId])) {
             $data[$row->proId]['totalClicks'] += $row->cnum;
             $data[$row->proId]['totalConsume'] += $row->amount / 100;
         } else {
             $data[$row->proId]['totalClicks'] = $row->cnum;
             $data[$row->proId]['totalConsume'] = $row->amount / 100;
         }
     }
     return $data;
 }
예제 #4
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     //检查经纪人是否存在
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId);
     }
     // 判断城市是否开通竞价业务
     $cityId = $brokerInfo->cityId;
     if (!Bll_City::isBidCity($cityId)) {
         throw new Exception_City_NotBidCity('CityId: ' . $cityId);
     }
     //房子的竞价计划
     $bidPlan = Model_Plan_EsfAjkPropSpread::getBidPlanInfoByHouseid($propId);
     if (empty($bidPlan)) {
         //房源信息
         $propInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $brokerInfo->cityId);
         if (!$propInfo[0]->isHighQulity) {
             throw new Exception_Property_NotMultiImages("Anjuke propId: {$propId}");
         }
         throw new Exception_BidPlan_NotFound('PropId: ' . $propId);
     }
     //房源总点击
     $bidClickInfo = Model_Plan_HpProStatsDay::getPropClicks($propId, $brokerInfo->cityId);
     $data = array();
     $data['totalClicks'] = $bidClickInfo[$propId]['totalClicks'];
     //房源竞价总点击
     $data['todayClicks'] = Model_plan_HpProStatsDay::getPropClickByDate($propId, $cityId, date('Ymd'));
     //今日点击
     $data['planId'] = $bidPlan->id;
     $priceInfo = Model_House_EsfPrice::get_price($cityId, $bidPlan->propriceint);
     $data['minClickPrice'] = $priceInfo['vPrice'];
     //最小出价
     $data['minClickPriceUnit'] = '元';
     //最小出价
     //推广中 排队中
     if ($bidPlan->status == Model_Plan_EsfAjkPropSpread::ONLINE || $bidPlan->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
         $data['planStatus'] = 1;
         // 推广中 or 排队中
         $data['budget'] = $bidPlan->budget / 100;
         //预算
         $data['budgetUnit'] = '元';
         $consume = Model_plan_HpProStatsDay::getPlanAmounts($bidPlan->id, $cityId);
         $data['budgetRemain'] = ($bidPlan->budget - $consume) / 100;
         $data['budgetRemainUnit'] = '元';
         $data['clickPrice'] = $bidPlan->offer / 100;
         //出价
         $data['clickPriceUnit'] = '元';
         $data['rankMsg'] = '排队中';
         if ($bidPlan->status == Model_Plan_EsfAjkPropSpread::ONLINE) {
             //排名
             $data['rank'] = $this->getPpcSaleRankBll($propId, $bidPlan->commId, $bidPlan->smallprice, $bidPlan->bigprice, $bidPlan->commsHpratioA, 3);
             $data['rankMsg'] = '推广中';
         }
     } else {
         $data['planStatus'] = 2;
         //已暂停
         $data['budget'] = 0;
         $data['budgetUnit'] = '元';
         $data['budgetRemain'] = 0;
         $data['budgetRemainUnit'] = '元';
         $data['clickPrice'] = 0;
         $data['clickPriceUnit'] = '元';
         $data['rankMsg'] = '已暂停';
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
예제 #5
0
 /**
  * 获取房源精选概况
  *
  * @param $brokerId
  * @param array $houseId
  */
 public function getPropChoiceSummary($brokerId, $houseId)
 {
     //初始化返回数组
     $data = array('totalClicks' => 0, 'balance' => 0, 'balanceUnit' => '元', 'todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'clickPrice' => 0, 'clickPriceUnit' => '元', 'maxBucketNum' => 0, 'usedBucketNum' => 0, 'bucketId' => '', 'status' => self::PROP_ACTIONTYPE_CHOICE_NOTFIT, 'statusMsg' => self::PROP_ACTIONTYPE_CHOICE_NOTFIT_MSG, 'remindStatus' => -1, 'remindStatusMsg' => '不符合精选订阅条件', 'minChoicePrice' => Bll_Plan_Bid_Choice::ESF_CHOICE_MIN_BUDGET, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => Bll_Plan_Bid_Choice::ESF_CHOICE_MAX_BUDGET, 'maxChoicePriceUnit' => '元');
     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);
         }
         //根据房源id获取精选计划信息
         $choicePlanInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId);
         if ($choicePlanInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $choicePlanInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
             $data['balance'] = $choicePlanInfo->balance / 100;
             $data['clickPrice'] = $choicePlanInfo->offer / 100;
             if ($choicePlanInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE) {
                 $data['status'] = self::PROP_ACTIONTYPE_CHOIED_ONLINE;
                 $data['statusMsg'] = self::PROP_ACTIONTYPE_CHOIED_ONLINE_MSG;
             } elseif ($choicePlanInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
                 $rankNum = Bll_Plan_Bid_Choice::getEsfOnQueueNum($choicePlanInfo->id, $choicePlanInfo->commId, $choicePlanInfo->smallprice, $choicePlanInfo->bigprice);
                 $data['status'] = self::PROP_ACTIONTYPE_CHOIED_ONQUEUE;
                 $data['statusMsg'] = sprintf(self::PROP_ACTIONTYPE_CHOIED_ONQUEUE_MSG, $rankNum);
             }
             //获取所有点击和话费相关信息
             $clickAndCostInfo = Model_Plan_HpProStatsDay::getPropClickAndCost($houseId, $cityId);
             if ($clickAndCostInfo->datei == date('Ymd')) {
                 $data['todayClicks'] += $clickAndCostInfo->cnum;
                 $data['todayConsume'] += $clickAndCostInfo->amount / 100;
             }
             $data['totalClicks'] += $clickAndCostInfo->cnum;
         } else {
             //获取房源信息
             $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($houseId, $cityId);
             if (empty($houseInfo)) {
                 $this->error(self::PROP_NOT_EXIST_ERROR, self::PROP_NOT_EXIST_ERROR_MSG);
             }
             $houseInfo = $houseInfo[0];
             //房源是否可以精选验证
             if ($houseInfo->isVisible != 1) {
                 //违规验证
                 return $data;
             }
             if ($houseInfo->isHighQulity == 0) {
                 //多图验证
                 return $data;
             }
             if (date('Ymd', strtotime('-16 days')) > date('Ymd', $houseInfo->postDate)) {
                 //发布时间验证
                 return $data;
             }
             $housePrice = intval($houseInfo->proPrice * 10000);
             $priceIntervalInfo = Model_House_EsfPrice::get_price($cityId, $housePrice);
             if (empty($priceIntervalInfo)) {
                 $this->error(self::PROP_PRICE_UNKNOW_ERROR, self::PROP_PRICE_UNKNOW_ERROR_MSG);
             }
             $priceId = $priceIntervalInfo['id'];
             //查询坑情况
             $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $priceId);
             if (empty($bucketInfo)) {
                 if (Model_Choice_EsfBidBucket::init_bucket_info($houseInfo->commId, $priceId, $cityId)) {
                     $bucketInfo = array('communityId' => $houseInfo->commId, 'priceId' => $priceId, 'totalNum' => Model_Choice_EsfBidBucket::TOTALNUM, 'usedNum' => 0, 'maxOnlineNum' => Model_Choice_EsfBidBucket::MAXONLINENUM);
                 } else {
                     $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
                 }
             }
             $data['bucketId'] = $bucketInfo['id'];
             $data['maxBucketNum'] = $bucketInfo['totalNum'];
             $data['usedBucketNum'] = $bucketInfo['usedNum'];
             $data['maxOnlineNum'] = $bucketInfo['maxOnlineNum'];
             if ($data['usedBucketNum'] < $data['maxOnlineNum']) {
                 $data['status'] = self::PROP_ACTIONTYPE_CHOICE_FIT_ONLINE;
                 $data['statusMsg'] = self::PROP_ACTIONTYPE_CHOICE_FIT_ONLINE_MSG;
             } elseif ($data['usedBucketNum'] < $data['maxBucketNum']) {
                 $data['status'] = self::PROP_ACTIONTYPE_CHOICE_FIT_ONQUEUE;
                 $data['statusMsg'] = self::PROP_ACTIONTYPE_CHOICE_FIT_ONQUEUE_MSG;
             } else {
                 $data['status'] = self::PROP_ACTIONTYPE_CHOICE_BUCKET_FULL;
                 $data['statusMsg'] = self::PROP_ACTIONTYPE_CHOICE_BUCKET_FULL_MSG;
                 $subscriptionInfo = Model_Choice_Subscription::selectData(array(Model_Choice_Subscription::SITE => Model_Choice_Subscription::SITE_AJK, Model_Choice_Subscription::BROKER_ID => $brokerId, Model_Choice_Subscription::PROP_ID => $houseId, Model_Choice_Subscription::BUCKET_ID => $data['bucketId'], Model_Choice_Subscription::STATUS => Model_Choice_Subscription::SUBSCRIPTION_START), array(), 'get_row');
                 if (empty($subscriptionInfo)) {
                     $data['remindStatus'] = self::PROP_ACTIONTYPE_CHOICE_SUBSCRIPTION_NO;
                     $data['remindStatusMsg'] = self::PROP_ACTIONTYPE_CHOICE_SUBSCRIPTION_NO_MSG;
                 } else {
                     $data['remindStatus'] = self::PROP_ACTIONTYPE_CHOICE_SUBSCRIPTION_YES;
                     $data['remindStatusMsg'] = self::PROP_ACTIONTYPE_CHOICE_SUBSCRIPTION_YES_MSG;
                 }
                 return $data;
             }
             for ($i = 0; $i < 3; $i++) {
                 //点击单价
                 $clickPrice = Bll_Service_Choice::ajkClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'commId' => $houseInfo->commId));
                 if ($clickPrice->isSucceeded()) {
                     break;
                 }
             }
             if (empty($clickPrice) || $clickPrice['status'] != 'ok') {
                 $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
             }
             $data['clickPrice'] = round($clickPrice['realTradeAmount'] / 100, 2);
         }
         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;
     }
 }
예제 #6
0
 /**
  * 获取经纪人的竞价点击信息
  *
  * @param int $brokerId
  * @param int $date
  * @param int $cityId
  * @return int
  */
 public static function getBrokerBidClick($brokerId, $date, $cityId)
 {
     $bidSpreadInfoList = Model_Plan_HpProStatsDay::getBrokerBidSpreadStats($brokerId, $date, $cityId);
     if (empty($bidSpreadInfoList)) {
         return 0;
     }
     $clicks = 0;
     foreach ($bidSpreadInfoList as $bidSpreadInfo) {
         $clicks += intval($bidSpreadInfo['cnum']);
     }
     return $clicks;
 }
예제 #7
0
 /**
  * 获取经纪人竞价推广某天的点击和花费信息
  *
  *
  *
  * @param $brokerId
  * @param $cityId
  * @param $datei
  * @return array
  */
 public static function getBrokerClickAndCostDay($brokerId, $cityId, $datei)
 {
     return Model_Plan_HpProStatsDay::data_access($cityId)->filter_by_op('brokerId', '=', $brokerId)->filter_by_op('datei', '=', $datei)->find();
 }