/**
  * 根据房源ID获取计划信息
  *
  * @param int $houseId
  * @param int $brokerId
  * @param int $cityId
  * @return array
  */
 public static function getRelationByHouseId($houseId, $brokerId, $cityId)
 {
     try {
         return Model_Plan_AjkFixRelation::data_access($cityId)->filter('proId', $houseId)->filter('brokerId', $brokerId)->get_row();
     } catch (Exception $e) {
         return array();
     }
 }
 /**
  * 判断房源是否在定价推广计划中
  *
  * @param int $cityId
  * @param int $houseId
  * @return bool
  */
 public static function isHouseOnline($cityId, $houseId)
 {
     $relation = Model_Plan_AjkFixRelation::getRelationByProIdEx($houseId, $cityId);
     if (empty($relation)) {
         return false;
     }
     return $relation['status'] == 1;
 }
示例#3
0
 public function handle_request_internal()
 {
     //判断房源是否定价 拿propid去static_price_relation 查PlanId 再去static_price_plan表中查定价信息
     $propId = $this->_params['propId'];
     $cityId = $this->_params['cityId'];
     //好丑陋。。。。。。好无奈。。。。。。
     //委托房源自动转发停用,为了app能够展示报错信息。。。
     if (empty($propId)) {
         $this->_params['apiDebug'] = 1;
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '0000', 'message' => '委托房源自动转发功能已停用;若要发布请手动发布');
     }
     $relation = Model_Plan_AjkFixRelation::getRelationByProId($propId, $cityId);
     $result['status'] = 'ok';
     $data['totalClicks'] = $data['todayClicks'] = $data['clickPrice'] = 0;
     $data['planId'] = '';
     if (!empty($relation)) {
         if ($relation['status'] == Model_Plan_AjkFixRelation::STATUS_NORMAL) {
             $data['status'] = 1;
             //房源在定价推广中
         } else {
             $data['status'] = 0;
             //未推广
         }
         $plan = Model_Plan_EsfFixedPlan::getValidStaticPricePlanById($relation['planId']);
         $data['planId'] = $plan[0]['id'];
         if (!empty($plan)) {
             //房源在定价推广中
             //房源点击量
             $proClickDao = new DAO_My_Ppc_PlanOpe();
             $proClickInfo = $proClickDao->getProClick($propId, strtotime("20120901"));
             if (!empty($proClickInfo)) {
                 if (isset($proClickInfo[$propId])) {
                     $data['totalClicks'] = $proClickInfo[$propId];
                 }
                 $data['todayClicks'] = $proClickInfo['todayClicks'];
             }
         }
     } else {
         $data['status'] = 0;
         //未推广
     }
     //获取点击单价
     $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId);
     if (!empty($houseInfo)) {
         $proPriceInt = $houseInfo[0]['proPriceInt'];
         $priceArr = DAO_My_Ppc_UtilTool::getPriceInterval($cityId, $proPriceInt - 0.01);
         if (!empty($priceArr)) {
             $data['clickPrice'] = round($priceArr['price'], 2);
         }
     }
     $data['clickPriceUnit'] = '元';
     $result['data'] = $data;
     return $result;
 }
示例#4
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;
 }
 public function handle_request()
 {
     $loadFields = array('proId', 'brokerId');
     $houseList = Bll_House_EsfHouse::scanInvalidateHouse($this->_cityId, $this->_startId, self::DEAL_LIMIT, $loadFields);
     if (count($houseList) < self::DEAL_LIMIT) {
         $this->dealDone(true);
     } else {
         $this->dealDone(false);
     }
     foreach ($houseList as $house) {
         $houseId = $house['proId'];
         $brokerId = $house['brokerId'];
         $this->setCursor($houseId);
         /** 套餐城市 */
         if (Bll_City::isComboCity($this->_cityId)) {
             $spreadRelation = Bll_Combo_HouseRelation::getRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
             if (empty($spreadRelation)) {
                 $this->logMsg(sprintf('没有获取到房源[%d]的套餐推广关系[BrokerId=%d CityId=%d]', $houseId, $brokerId, $this->_cityId));
                 continue;
             }
             if ($spreadRelation['brokerId'] != $brokerId || $spreadRelation['cityId'] != $this->_cityId) {
                 $this->logMsg(sprintf('房源[%d]的 [BrokerId=%d CityId=%d] xxxx [BrokerId=%d CityId=%d]', $houseId, $brokerId, $this->_cityId, $spreadRelation['brokerId'], $spreadRelation['cityId']));
                 $this->saveErrorHouseId($houseId, $brokerId);
                 continue;
             }
             $this->logMsg(sprintf('房源[%d]的套餐推广关系正确[BrokerId=%d CityId=%d]', $houseId, $brokerId, $this->_cityId));
         } else {
             $spreadRelation = Model_Plan_AjkFixRelation::getRelationByProIdEx($houseId, $this->_cityId);
             if (empty($spreadRelation)) {
                 $this->logMsg(sprintf('没有获取到房源[%d]的定价推广关系[BrokerId=%d CityId=%d]', $houseId, $brokerId, $this->_cityId));
                 continue;
             }
             if ($spreadRelation['brokerId'] != $brokerId) {
                 $this->logMsg(sprintf('房源[%d]的 [BrokerId=%d CityId=%d] 关系的 [BrokerId=%d]', $houseId, $brokerId, $this->_cityId, $spreadRelation['brokerId']));
                 $this->saveErrorHouseId($houseId, $brokerId);
                 continue;
             }
             $this->logMsg(sprintf('房源[%d]的定价推广关系正确[BrokerId=%d CityId=%d]', $houseId, $brokerId, $this->_cityId));
         }
     }
 }
示例#6
0
 public function handle_request_internal()
 {
     // TODO: Implement handle_request_internal() method.
     $result['status'] = 'ok';
     $cityId = $this->_params['cityId'];
     $brokerId = $this->_params['brokerId'];
     $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($this->_params['planId'], $cityId);
     $propertyList = array('newList' => array(), 'oldList' => array());
     if (!empty($relations)) {
         $propIds = array();
         foreach ($relations as $row) {
             $propIds[] = $row['proId'];
         }
         $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId, array('postDate' => 'desc'));
         //房源点击量
         $proClickDao = new DAO_My_Ppc_PlanOpe();
         $proClickInfo = $proClickDao->getProClick($propIds, strtotime("20120901"));
         $spreads = Model_Plan_AjkPropspread::getAjkPropSpreadByIds($propIds);
         if (!empty($spreads)) {
             foreach ($spreads as $row) {
                 $spreadArr[$row['propId']]['bidVersion'] = $row['bidVersion'];
                 $spreadArr[$row['propId']]['status'] = $row['status'];
             }
         }
         foreach ($houseInfo as $row) {
             $propId = $row['proId'];
             $list['propId'] = $propId;
             $list['title'] = $row['proName'];
             $list['commId'] = $row['commId'];
             $list['commName'] = $row['commName'];
             $list['roomNum'] = $row['roomNum'];
             $list['hallNum'] = $row['hallNum'];
             $list['toiletNum'] = $row['toiletNum'];
             $list['area'] = round($row['areaNum']);
             $list['price'] = is_float($row['proPrice']) ? round($row['proPrice'], 1) : $row['proPrice'];
             $list['priceUnit'] = '万';
             $list['totalClicks'] = isset($proClickInfo[$propId]) ? $proClickInfo[$propId] : 0;
             $list['isBid'] = $list['isChoice'] = 0;
             if (isset($spreadArr) && isset($spreadArr[$propId])) {
                 if ($spreadArr[$propId]['bidVersion'] == 1 && $spreadArr[$propId]['status'] == 1) {
                     $list['isBid'] = 1;
                 } elseif ($spreadArr[$propId]['bidVersion'] == 2 && ($spreadArr[$propId]['status'] == 1 || $spreadArr[$propId]['status'] == 11)) {
                     $list['isChoice'] = 1;
                 }
             }
             $list['isMoreImg'] = $row['isHighQulity'];
             $list['isVisible'] = $row['isVisible'];
             $list['isPhonePub'] = $row['uriCode'] == 'mobile.asyn' || $row['uriCode'] == 'mobile-ajk-broker.asyn' ? 1 : 0;
             $list['createTime'] = $row['postDate'];
             $imgBll = Bll_Image_EsfHouseImage::getInstance();
             $list['imgUrl'] = $imgBll->getThumbImageUrl($propId, $row['commId']);
             //增加委托房源标签
             if ($row['commitionType'] == 2) {
                 $list['isEntrust'] = 1;
             } else {
                 $list['isEntrust'] = 0;
             }
             //计算出房源推广天数
             $timeFixStr = strtotime(date("Ymd", $row['postDate']));
             $leftDay = floor((time() - $timeFixStr) / 86400);
             if ($leftDay >= 30) {
                 $propertyList['oldList'][] = $list;
             } else {
                 $propertyList['newList'][] = $list;
             }
         }
     }
     $result['data'] = $propertyList;
     return $result;
 }
示例#7
0
 /**
  * @param $proIds
  * @param $brokerId
  * @param $cityId
  * @return bool
  */
 private function getInPlanHouseNumByBrokerIdAndProIds($proIds, $brokerId, $cityId)
 {
     if (empty($proIds) || empty($brokerId) || empty($cityId)) {
         return 0;
     }
     $res = Model_Plan_AjkFixRelation::data_access($cityId)->filter('proId', $proIds)->filter('brokerId', $brokerId)->filter('status', Model_Plan_AjkFixRelation::STATUS_NORMAL)->filter('tradeType', Model_Plan_AjkFixRelation::TRADETYPE_SALE)->count();
     return $res;
 }
示例#8
0
 /**
  * 删除房源
  *
  * @param $brokerId
  * @param $cityId
  * @param $houseIds
  * @return bool
  */
 public static function deleteHouse($brokerId, $cityId, $houseIds)
 {
     $houseIds = is_array($houseIds) ? $houseIds : explode(',', $houseIds);
     if (Bll_Ppc_ServiceAPI::deleteHouse($brokerId, $houseIds)) {
         /**
          * 查询计划房源信息
          * 20140416 曹阳 房源删除时,确认房源是否在计划中。
          * 防止房源已经从计划中移除,导致房源再次被处理,产生推广动作。
          */
         foreach ($houseIds as $houseId) {
             $relation = Model_Plan_AjkFixRelation::getRelationByProId($houseId, $cityId);
             if ($relation === false || $relation->status != 1) {
                 continue;
             }
             Model_Plan_AjkFixRelation::updateRelationById($relation->id, $cityId, 5);
         }
         return true;
     }
     return false;
 }
示例#9
0
 /**
  * 根据根据房源获取制定参数
  * @param $cityId
  * @param array $proIds
  * @return array|bool
  */
 public static function getFixedProBy($cityId, $proIds = array())
 {
     if (empty($cityId) || !is_numeric($cityId) || empty($proIds)) {
         return array();
     }
     return Model_Plan_AjkFixRelation::getRelationListByStatus($proIds, $cityId);
 }
示例#10
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     //经纪人信息
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $communityList = array();
     $cityId = $brokerInfo->cityId;
     $hzBrokerId = Model_Broker_HzMapping::get_hz_broker_id($brokerId);
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         /** 租房 */
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1);
         //套餐列表
         $propIds = array();
         foreach ($comboList as $combo) {
             $propIds[] = $combo['houseId'];
         }
         if ($propIds && $hzBrokerId) {
             $hzPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $cityId);
             //房源信息
             foreach ($hzPropList as $list) {
                 //过滤无效房源
                 if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
                     continue;
                 }
                 $row = array();
                 $row['commId'] = $list['commid'];
                 $row['commName'] = $list['commname'];
                 $communityList[$list['commid']] = $row;
             }
         }
         /** 二手房 */
         $comboSpreadHouseList = Bll_Broker_Combo_ManageAjk::getComboSpreadHouseList($brokerId, $cityId);
         if ($comboSpreadHouseList) {
             //获取房源信息
             $propIds = array_keys($comboSpreadHouseList);
             $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
             foreach ($propsInfo as $prop) {
                 $row = array();
                 $row['commId'] = $prop->commId;
                 $row['commName'] = $prop->commName;
                 $communityList[$prop->commId] = $row;
             }
         }
     } else {
         //定价的情况
         $brokerProps = Bll_Broker_HzBroker::getBrokerProps($brokerId, $cityId);
         // 获取房源关系列表
         if ($brokerProps['status']) {
             /** 租房*/
             $brokerProps = $brokerProps['msg'];
             $plans = $brokerProps['plans'][0];
             //定价计划
             $plannings = $brokerProps['plannings'];
             //计划房源关系
             $propsTemp = $brokerProps['props'];
             //定价房源
             if (empty($plans)) {
                 $hzPropList = array();
             } else {
                 $hzPropList = array();
                 foreach ($propsTemp as $prop) {
                     $hzPropList[$prop['proId']] = $prop;
                 }
                 foreach ($plannings as $key => $planning) {
                     // 非有效 过滤掉
                     if (!Bll_HzFixPlan::isValidPlanning($planning['isValid'])) {
                         unset($hzPropList[$planning['proId']]);
                     }
                 }
             }
             foreach ($hzPropList as $prop) {
                 $row = array();
                 $row['commId'] = $prop['commId'];
                 $row['commName'] = $prop['commName'];
                 $communityList[$prop['commId']] = $row;
             }
         }
         /** 二手房*/
         //获取经纪人有效定价计划  计划表
         $fixSpreadPlanList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList($brokerId);
         $fixPlanId = $fixSpreadPlanList[0]['id'];
         //关系表中获取房源;
         if ($fixPlanId) {
             $relations = Model_Plan_AjkFixRelation::getRelationListByPlanId($fixPlanId, $cityId);
             $propIds = array();
             foreach ($relations as $relation) {
                 $propIds[] = $relation['proId'];
             }
             if ($propIds) {
                 $propsInfo = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $cityId);
                 foreach ($propsInfo as $prop) {
                     $row = array();
                     $row['commId'] = $prop->commId;
                     $row['commName'] = $prop->commName;
                     $communityList[$prop->commId] = $row;
                 }
             }
         }
     }
     //对小区按首字母排序
     $communityList = $this->communitySortByCommCode($communityList);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('communityList' => array_values($communityList)));
 }
 private function getStaticPriceRelation($planIds, $cityId)
 {
     return Model_Plan_AjkFixRelation::getRelationListByPlanIdEx($planIds, $cityId);
 }