Esempio n. 1
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;
 }
Esempio n. 2
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;
     }
 }