Пример #1
0
 private function getClickInfoAction($brokerId, $cityId, $params)
 {
     if (!isset($params['plan_type']) || !isset($params['propIds'])) {
         return $this->buildResponse('error', array(), '非法请求。');
     }
     $houseIds = is_array($params['propIds']) ? $params['propIds'] : explode(',', $params['propIds']);
     $houseClickInfo = array_fill_keys($houseIds, 0);
     /** 获取套餐推广的房源的点击量 */
     if ($params['plan_type'] == 'combo') {
         $houseClickInfo = Bll_House_EsfHouse::getHouseTodayComboClick($houseIds);
         if (isset($params['type']) && $params['type'] == 'today') {
             $bidHouseClickInfo = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, $cityId, date('Ymd'));
             foreach ($bidHouseClickInfo as $houseId => $click) {
                 $houseClickInfo[$houseId] += $click;
             }
             return $this->buildResponse('ok', $houseClickInfo, '获取房源今日点击量成功。');
         }
         if (isset($params['type']) && $params['type'] == 'all') {
             $houseAccumulateClickInfo = Bll_House_EsfHouse::getComboHouseAccumulateClick($brokerId, $houseIds, $cityId);
             foreach ($houseAccumulateClickInfo as $houseId => $click) {
                 $houseClickInfo[$houseId] += $click;
             }
             $houseChoiceClickList = Model_Choice_PropClickCount::getChoiceClickInfo($brokerId, $cityId, $houseIds);
             foreach ($houseChoiceClickList as $houseChoiceClick) {
                 $houseClickInfo[$houseChoiceClick['propId']] += $houseChoiceClick['count'];
             }
             return $this->buildResponse('ok', $houseClickInfo, '获取房源累计点击量成功。');
         }
     }
     if ($params['plan_type'] == 'bid') {
         return $this->buildResponse('ok', Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, $cityId, date('Ymd')), '');
     }
     return $this->buildResponse('ok', $houseClickInfo, '请求失败。');
 }
Пример #2
0
 private function deletePlan($brokerId, $cityId, $planId, $remark)
 {
     if (Bll_Plan_Bid_AjkPlan::deletePlan($brokerId, $planId, $cityId)) {
         Bll_Plan_Bid_AjkPlan::addHouseBidSpreadLog($planId, $brokerId, 'DEL', $remark, 0);
         return array('status' => 'ok');
     }
     return array('status' => 'error');
 }
Пример #3
0
 /**
  * 金铺-精选房源设置页面
  *
  * @param int $brokerId
  * @param int $cityId
  * @param int $houseId
  * @param array $params
  *
  * @return array
  */
 public static function esf_setting($brokerId, $cityId, $houseId, $userId, $params = array())
 {
     $pageAttribute = array();
     //获取精选推广预算
     $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID'];
     $choiceSet = APF::get_instance()->get_config('choice_set');
     //根据经纪人公司不同有不同的预算
     if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) {
         $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MAX_BUDGET'];
     } else {
         $pageAttribute['min_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MAX_BUDGET'];
     }
     self::setChoiceNum($cityId);
     //判断当前经纪人已经精选推广的房源数
     if (isset($params['act']) && isset($params['rebid'])) {
         if (self::checkEsfBidChoiceFull($brokerId, $cityId, 1)) {
             //检查二手房精选是否达到最大
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源');
         }
     } else {
         if (self::checkEsfBidChoiceFull($brokerId, $cityId)) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源');
         }
     }
     /** 经纪人重新推广房源 */
     if (isset($params['act']) && isset($params['rebid'])) {
         //在精选管理页就已经设置时候是重新推广
         $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId);
         if ($planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
         }
         $pageAttribute['plan_id'] = $params['plan_id'];
         $pageAttribute['rebid'] = true;
     }
     $balance = self::get_broker_balance_by_broker_id($brokerId);
     //获取经纪人账户余额
     $pageAttribute['balance'] = $balance;
     if ($balance > 0) {
         $balance = sprintf('%.2f', $balance / 100);
     }
     $pageAttribute['balance_fmt'] = $balance;
     //获取房源信息
     $pageAttribute['housesInfo'] = Bll_House_EsfHouse::getHouseBaseInfo($houseId, $cityId);
     if (empty($pageAttribute['housesInfo'])) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在!');
     }
     $houseInfo = $pageAttribute['housesInfo'][0];
     if ($houseInfo->userId != $userId) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不属于当前操作人');
     }
     if ($houseInfo->isVisible != 1) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源是违规房源,不可以参加精选房源推广');
     }
     if ($houseInfo->isHighQulity == 0) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     if (date('Ymd', strtotime('-15 days')) > date('Ymd', $houseInfo->postDate)) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) {
         /** 判断是在套餐推广中 */
         $houseState = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         if (empty($houseState)) {
             return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '该房源不在推广中');
         }
     }
     //判断是否已在竞价计划中
     $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId);
     if (!empty($planInfo) && !isset($params['act']) && !isset($params['rebid'])) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
     }
     $pageAttribute['title'] = sprintf("%s,%d室%d厅%d卫,%d平,%.2f万", $houseInfo->commName, $houseInfo->roomNum, $houseInfo->hallNum, $houseInfo->toiletNum, intval($houseInfo->areaNum), $houseInfo->proPrice);
     $pageAttribute['community_name'] = $houseInfo->commName;
     $housePrice = intval($houseInfo->proPrice * 10000);
     //获取坑位信息
     $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $cityId, $housePrice);
     //获取坑位信息
     if (empty($bucketInfo)) {
         Bll_Choice_EsfBidBucket::init_bucket_info($houseInfo->commId, $cityId, $housePrice);
         $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $cityId, $housePrice);
     }
     if ($bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']) {
         $pageAttribute['hidden']['show'] = 1;
     }
     $pageAttribute['bucket_total'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_used'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum'];
     $priceInfo = Model_House_EsfPrice::get_price_by_id($bucketInfo['priceId']);
     $pageAttribute['price_title'] = sprintf("%d-%d万", intval($priceInfo['minPrice'] / 10000), intval($priceInfo['maxPrice'] / 10000));
     //价格
     $clickPrice = Bll_Service_Choice::ajkClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'commId' => $houseInfo->commId));
     if ($clickPrice['status'] == 'error') {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '服务器繁忙,请重试(code: -' . __LINE__ . ')');
     }
     if ($clickPrice['realTradeAmount'] != $clickPrice['shouldTradeAmount']) {
         $pageAttribute['favorable'] = true;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
         $pageAttribute['origin_price'] = round($clickPrice['shouldTradeAmount'] / 100, 2);
         $pageAttribute['favorable_end_time'] = date('Y-m-d', strtotime($clickPrice['rebateEndTime']));
     } else {
         $pageAttribute['favorable'] = false;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
     }
     $clickAndBudget = Bll_Choice_EsfBidBucket::getBucketAverageClickBudget($houseInfo->commId, $cityId, $housePrice);
     //获取坑位的平均点击的预算
     if (!empty($clickAndBudget)) {
         $pageAttribute['averageClick'] = $clickAndBudget['averageClick'];
         $pageAttribute['averageBudget'] = $clickAndBudget['averageBudget'] / 100;
     }
     /**重组板块精选url**/
     $bidPlanList = Bll_Plan_Bid_AjkPlan::getBrokerValidPlanListByhouseId($houseId, $brokerId, $cityId, true);
     //板块加价格
     $bidPlanList = $bidPlanList[0];
     if (isset($bidPlanList)) {
         $blockInfo['bidStatus'] = $bidPlanList['status'];
         if ($bidPlanList['status'] == 1) {
             $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
         } elseif ($bidPlanList['status'] == 11) {
             $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
         } else {
             if ($bidPlanList['status'] != 2) {
                 $bidUrl = "/ajkbroker/user/choice/blockset/ajk/" . $houseInfo['proId'] . '/?act=1&rebid=1&plan_id=' . $bidPlanList['id'];
             }
         }
     } else {
         $bidUrl = "/ajkbroker/user/choice/blockset/ajk/" . $houseInfo['proId'];
     }
     $pageAttribute['bidUrl'] = $bidUrl;
     return $pageAttribute;
 }
Пример #4
0
 /**
  * 获取经纪人有效的竞价计划
  *
  * @param int $brokerId
  * @param int $cityId
  * @param array $propIds
  * @param bool $isChoiceCity
  * @return array
  */
 public static function getBrokerBidPlanList($brokerId, $cityId, &$propIds, $isChoiceCity)
 {
     $choicePlanList = Bll_Plan_Bid_AjkPlan::getBrokerValidPlanList($brokerId, $cityId, $isChoiceCity);
     if (empty($choicePlanList)) {
         return array();
     }
     if (!is_array($propIds)) {
         $propIds = array();
     }
     $result = array();
     foreach ($choicePlanList as $choicePlan) {
         $propIds[] = $choicePlan['propId'];
         $result[$choicePlan['propId']] = $choicePlan;
     }
     return $result;
 }
Пример #5
0
 /**
  * 获取房源竞价推广七天的消费和点击统计信息
  *
  * @param int $houseId
  * @param int $cityId
  * @return array
  */
 public static function getHouseBidSpreadInfo($houseId, $cityId)
 {
     $startDate = date('Ymd', strtotime('-6 days'));
     $endDate = date('Ymd');
     $houseBidSpreadInfoList = Bll_Plan_Bid_AjkPlan::getHouseSpreadStatsByInterval($houseId, $cityId, $startDate, $endDate);
     $houseBidSpreadClickInfoList = array();
     $houseBidSpreadCostInfoList = array();
     for ($interval = -6; $interval <= 0; $interval++) {
         $day = date('m.d', strtotime("{$interval} day"));
         $houseBidSpreadClickInfoList[$day] = 0;
         $houseBidSpreadCostInfoList[$day] = 0;
     }
     foreach ($houseBidSpreadInfoList as $houseBidSpreadInfo) {
         $day = date('m.d', strtotime($houseBidSpreadInfo['datei']));
         $houseBidSpreadClickInfoList[$day] += intval($houseBidSpreadInfo['cnum']);
         $houseBidSpreadCostInfoList[$day] += intval($houseBidSpreadInfo['amount']) / 100;
     }
     return array('clickInfo' => $houseBidSpreadClickInfoList, 'costInfo' => $houseBidSpreadCostInfoList);
 }
Пример #6
0
 /**
  * @param $brokerId
  * @param $startDate
  * @param $endDate
  */
 public static function getBrokerBidClickAjk($brokerId, $cityId, $startDate, $endDate)
 {
     $startDate = date('Ymd', strtotime($startDate));
     $endDate = date('Ymd', strtotime($endDate));
     $result = array();
     for ($day = $startDate; $day <= $endDate; $day = date("Ymd", strtotime($day) + 86400)) {
         $ajkDayBidClick = Bll_Plan_Bid_AjkPlan::getBrokerBidClick($brokerId, $day, $cityId);
         if (isset($result[$day])) {
             $result[$day] += $ajkDayBidClick;
         } else {
             $result[$day] = $ajkDayBidClick;
         }
     }
     return $result;
 }
Пример #7
0
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     $houseIds = $request->get_parameter('propIds');
     /**
      * type: today, all
      */
     $type = $request->get_parameter('type');
     /**
      * plan_type: bid, fix
      */
     $planType = $request->get_parameter('plan_type');
     $rtn = array_fill_keys($houseIds, 0);
     if (strcasecmp($planType, 'fix') === 0) {
         /**
          * 定价房源点击量
          */
         if (strcasecmp($type, 'today') == 0 && !empty($houseIds)) {
             /**
              * 房源今日点击量
              */
             $date = date('Ymd');
             // $houseClickInfoList = Bll_Ppc_ServiceAPI::getHouseClickInfo($houseIds, strtotime(date('Y-m-d 00:00:00')), time(), static::$intBrokerID);
             $houseClickInfoList = Bll_Ppc_ServiceAPI::getHouseClickInfoNew(static::$intBrokerID, $houseIds, $date, $date);
             foreach ($houseClickInfoList as $houseClickInfo) {
                 $rtn[$houseClickInfo['propId']] += max(0, $houseClickInfo['clickNum']);
             }
             /**
              * 精选点击
              */
             $choiceClickList = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, static::$intBrokerCityID, date('Ymd'));
             foreach ($choiceClickList as $houseId => $clickCount) {
                 $rtn[$houseId] += $clickCount;
             }
         } else {
             /**
              * 房源累计点击量
              */
             $fixPlanIdList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList(static::$intBrokerID);
             if (empty($fixPlanIdList)) {
                 $rtn = array();
             } else {
                 $fixPlanId = $fixPlanIdList[0]['id'];
                 $houseClickInfoList = Bll_Ppc_ServiceAPI::propFixClickNum(static::$intBrokerID, $houseIds, $fixPlanId);
                 foreach ($houseClickInfoList as $houseClickInfo) {
                     $rtn[$houseClickInfo['propId']] = max(0, $houseClickInfo['clickNum']);
                 }
             }
             $houseChoiceClickList = Model_Choice_PropClickCount::getChoiceClickInfo(static::$intBrokerID, static::$intBrokerCityID, $houseIds);
             foreach ($houseChoiceClickList as $houseChoiceClick) {
                 $rtn[$houseChoiceClick['propId']] += $houseChoiceClick['count'];
             }
         }
     } else {
         /**
          * 竞价今日点击量
          */
         $rtn = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, static::$intBrokerCityID, date('Ymd'));
     }
     echo json_encode($rtn, JSON_FORCE_OBJECT);
     return false;
 }
Пример #8
0
 /**
  * 获取经纪人有效的竞价计划
  *
  * @param int $brokerId
  * @param int $cityId
  * @param array $propIds
  * @param bool $isChoiceCity
  * @return array
  */
 public static function getBrokerBidPlanList($brokerId, $cityId, &$propIds, $isChoiceCity)
 {
     $bidPlanList = Bll_Plan_Bid_AjkPlan::getBrokerValidPlanList($brokerId, $cityId, $isChoiceCity);
     if (empty($bidPlanList)) {
         return array();
     }
     if (!is_array($propIds)) {
         $propIds = array();
     }
     $spreadingPlanList = array();
     $stoppedPlanList = array();
     $waitingPlanList = array();
     foreach ($bidPlanList as $bidPlan) {
         $propIds[] = $bidPlan['propId'];
         if (1 == $bidPlan['status']) {
             // $bidPlan['rank'] = Bll_Plan_Bid_AjkPlan::getHouseBidRank($bidPlan['propId'], $bidPlan['commId'], $bidPlan['smallprice'], $bidPlan['bigprice'], $bidPlan['commsHpratioA'], 3);
             $spreadingPlanList[] = $bidPlan;
         } elseif (11 == $bidPlan['status']) {
             $waitingPlanList[] = $bidPlan;
         } else {
             $stoppedPlanList[] = $bidPlan;
         }
     }
     $result = array();
     $bidPlanList = array_merge($spreadingPlanList, $waitingPlanList, $stoppedPlanList);
     foreach ($bidPlanList as $bidPlan) {
         $result[$bidPlan['propId']] = $bidPlan;
     }
     return $result;
 }