예제 #1
0
 public function handle_request_internal()
 {
     $response = Bll_Service_House::ajkImageDescEdit(array('aid' => $this->_params['aid'], 'desc' => isset($this->_params['desc']) ? $this->_params['desc'] : ''));
     if ($response->isFailed()) {
         throw new Exception('更新失败,请求内部API失败。');
     }
     if ($response['status'] == 'error') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => $response['info']);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'message' => $response['info']);
 }
예제 #2
0
 /**
  * 获取经纪人房源
  * @param $ajkBrokerId
  * @param $cityId
  * @param int $rsl 二进制开关
  * @return array
  */
 public static function getBrokerProps($ajkBrokerId, $cityId, $rsl = 11)
 {
     // 获取房源关系列表
     $response = Bll_Service_House::hzGetBrokerProps(array('brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'rsl' => bindec($rsl)));
     if ($response->isFailed()) {
         return Util_GlobalFunc::buildReturn(0, '好租获取房源失败,请求内部API失败.');
     }
     if ($response['status'] == 'error') {
         return Util_GlobalFunc::buildReturn(0, '好租获取房源失败' . $response['info']);
     }
     return Util_GlobalFunc::buildReturn(1, array('plans' => isset($response['plan']) ? $response['plan'] : array(), 'plannings' => isset($response['propPlanning']) ? $response['propPlanning'] : array(), 'props' => isset($response['property']) ? $response['property'] : array()));
 }
예제 #3
0
 public static function saveHouseInfo($brokerId, $cityId, $commissionId, $params, $isComboBroker)
 {
     /** 验证小区 */
     $communityId = $params['CommId'];
     if (!Bll_House_EsfPublish::verifyCommunity($cityId, $communityId)) {
         return array('status' => 'error', 'info' => '小区不存在');
     }
     $field = Bll_House_EsfPublish::prepareApiParam($brokerId, $params);
     /**
      * @var $result Bll_Service_Client_HttpResponse
      */
     if ($isComboBroker) {
         $result = Bll_Service_House::esfAddHouseCombo($field);
     } else {
         $result = Bll_Service_House::esfAddHousePPC($field);
     }
     if ($result->isFailed()) {
         return array('status' => 'error', 'info' => '调用API超时');
     }
     if ($result['status'] != 'ok') {
         return array('status' => 'error', 'code' => $result['code'], 'info' => $result['info']);
     }
     $houseId = $result['action']['proid'];
     //todo 更新委托房源信息
     static::insertCommissionSaleLog($brokerId, $cityId, $commissionId, $houseId);
     $saveImageResult = Bll_House_EsfPublish::saveImage($houseId, $params);
     $saveImageResult['houseId'] = $houseId;
     return $saveImageResult;
 }
예제 #4
0
 /**
  * 房源发布
  *
  * @param int $brokerId
  * @param $params
  * @throws
  *
  * @return int
  */
 public static function publishHouse($brokerId, $params)
 {
     if (!is_array($params) || empty($params)) {
         throw new Exception('发布房源,房源信息不能为空');
     }
     $params['broker_id'] = $brokerId;
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         $result = Bll_Service_House::esfAddHouseCombo($params);
     } elseif (Bll_Broker_HzBroker::isPpcBroker($brokerId)) {
         $result = Bll_Service_House::esfAddHousePPC($params);
     } else {
         throw new Exception('经纪人不是新套餐或PPC经纪人');
     }
     if ($result['status'] == 'ok') {
         return $result['action']['proid'];
     }
     return 0;
 }
예제 #5
0
 /**
  * 房源编辑保存房源信息
  *
  * @param $brokerId
  * @param $cityId
  * @param $houseId
  * @param $params
  * @return array
  */
 public static function saveHouseInfo($brokerId, $cityId, $houseId, $params)
 {
     $params['broker_id'] = $brokerId;
     $fields = static::prepareApiParam($houseId, $params);
     /**
      * @var $result Bll_Service_Client_HttpResponse
      */
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         $result = Bll_Service_House::esfUpdateHouseCombo($fields);
     } else {
         $result = Bll_Service_House::esfUpdateHousePPC($fields);
     }
     if (!$result->isSucceeded()) {
         return array('status' => 'error', 'info' => '调用API超时');
     }
     if ($result['status'] != 'ok') {
         return array('status' => 'error', 'code' => $result['code'], 'info' => $result['info']);
     }
     $saveImageResult = Bll_House_EsfPublish::saveImage($houseId, $params);
     return $saveImageResult;
 }
예제 #6
0
 /**
  * 保存房源信息
  *
  * @param bool $isComboBroker
  * @param int $brokerId
  * @param array $params
  * @return array
  */
 public static function saveHouseInfo($brokerId, $params, $isComboBroker)
 {
     $field = static::prepareApiParam($brokerId, $params);
     /**
      * @var $result Bll_Service_Client_HttpResponse
      */
     if ($isComboBroker) {
         $result = Bll_Service_House::esfAddHouseCombo($field);
     } else {
         $result = Bll_Service_House::esfAddHousePPC($field);
     }
     if ($result->isFailed()) {
         return array('status' => 'error', 'info' => '调用API超时');
     }
     if ($result['status'] != 'ok') {
         return array('status' => 'error', 'code' => $result['code'], 'info' => $result['info']);
     }
     $houseId = $result['action']['proid'];
     $saveImageResult = static::saveImage($houseId, $params);
     $saveImageResult['houseId'] = $houseId;
     return $saveImageResult;
 }
예제 #7
0
 /**
  * 获取房源历史总点击量(可批量)
  * 注:对查询跨度对限制,限制只能查询一个月内的
  * @param $proIds
  * @param $cityId
  * @param $ajkBrokerId
  * @param $field (返回过滤字段, 可能的值amount|cnum|freeCnum|icnum|realAmount)
  * @return array
  */
 public static function getPropTotalClicks($proIds, $cityId, $ajkBrokerId, $field = '*')
 {
     if (!is_array($proIds)) {
         $proIds = explode(',', $proIds);
     }
     $key = sprintf('%s_%s_%s_%d_%d_%s123', __CLASS__, __METHOD__, implode(',', $proIds), $cityId, $ajkBrokerId, $field);
     $cacheObj = APF_Cache_Factory::get_instance()->get_memcache();
     $result = $cacheObj->get($key);
     if ($result) {
         return Util_GlobalFunc::buildReturn(1, $result);
     }
     $response = Bll_Service_House::hzGetPropTotalClicks(array('brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'proIds' => implode(',', $proIds), 'startDate' => date('Ymd', strtotime('-90 days')), 'endDate' => date('Ymd')));
     if ($response->isFailed()) {
         return Util_GlobalFunc::buildReturn(0, '好租获取房源历史总点击量失败,请求内部API失败.');
     }
     if ($response['status'] == 'error') {
         return Util_GlobalFunc::buildReturn(0, '好租获取房源历史总点击量失败,' . $response['info']);
     }
     $result = array();
     foreach ($proIds as $proId) {
         if ($response['count'] == 0) {
             $result[$proId] = $field == '*' ? array() : 0;
         } else {
             foreach ($response['property'] as $item) {
                 if ($item['proId'] == $proId) {
                     $result[$proId] = $field == '*' ? $item : $item[$field];
                     break;
                 }
             }
         }
     }
     $cacheObj->set($key, $result, 0, self::EXPIRE_TIME);
     return Util_GlobalFunc::buildReturn(1, $result);
 }
예제 #8
0
 public function handle_request()
 {
     $this->setLog(sprintf('开始处理[%d - %d]的日志......', $this->_suffix, $this->_lastLogId));
     $type = array(1, 2, 14, 20);
     $houseLogList = Model_Log_HouseLogNew::getLogInfoMoreThanIdEx($this->_lastLogId, $this->_suffix, 1, $type);
     $currentTimestamp = date('Y-m-d H:i:s');
     if (empty($houseLogList)) {
         $currentDate = date('Ymd');
         if ($this->_suffix != $currentDate) {
             $this->setFlag(array('id' => 0, 'date' => $currentDate, 'time' => $currentTimestamp));
         }
         $this->setShCommonSleepTime(1);
         return;
     }
     $houseIllegalFilter = new Bll_House_Filter();
     foreach ($houseLogList as $row) {
         $cityId = $row['cityId'];
         $brokerId = $row['brokerId'];
         $houseId = $row['houseId'];
         $this->setLogPrefix(sprintf('%d - %d - %d', $cityId, $brokerId, $houseId));
         if (strtotime($row['addDate']) > time() - 60) {
             $this->setLog(sprintf('日志延时处理%s', $row['addDate']));
             $this->setShCommonSleepTime(300);
             return;
         }
         $this->setLog(sprintf('开始处理日志:%s', json_encode($row)));
         $this->setFlag(array('id' => $row['id'], 'date' => $this->_suffix, 'time' => $currentTimestamp));
         $houseInfo = Bll_House_EsfHouse::getHouseInfoById($houseId, $cityId);
         if (empty($houseInfo)) {
             $this->setLog('没有获取到房源的信息');
             continue;
         }
         $this->setLog(sprintf('房源信息:%s', json_encode($houseInfo)));
         if ($houseInfo['operateState'] != 1) {
             $this->setLog(sprintf('房源状态[%d]无效,不处理', $houseInfo['operateState']));
             continue;
         }
         if ($houseInfo['isVisible'] == 0 && $houseInfo['expireWorker'] != 'propertyReport') {
             $this->setLog(sprintf('房源已经违规[isVisible=%d, expireWorker=%s],不处理', $houseInfo['isVisible'], $houseInfo['expireWorker']));
             continue;
         }
         $isHouseIllegal = $houseIllegalFilter->execute($houseInfo, $logContent);
         $this->setLog(implode(PHP_EOL, $logContent));
         if ($isHouseIllegal) {
             $this->setLog('正常房源');
             continue;
         }
         $this->setLog('房源违规');
         $params = array('cityId' => $cityId, 'propId' => $houseId, 'newIsVisible' => 0, 'newModifyDate' => time(), 'newExpireDate' => 0);
         $apiResponse = array();
         /** 调用API违规房源 */
         for ($i = 0; $i < 3; $i++) {
             /**
              * @var Bll_Service_Client_HttpResponse $apiResponse
              */
             $apiResponse = Bll_Service_House::esfUpdatePropertyInfo($params);
             if ($apiResponse->isSucceeded()) {
                 break;
             }
         }
         if ($apiResponse->isFailed()) {
             $this->setLog(sprintf('调用API超时: %s', json_encode($apiResponse->getTransferInfo())));
         } else {
             $this->setLog(sprintf('调用API的返回信息: %s', json_encode($apiResponse->getResponse())));
         }
         if (isset($apiResponse['status']) && strcasecmp('ok', $apiResponse['status']) == 0) {
             $this->setLog('设置房源状态违规成功');
         } else {
             $this->setLog('设置房源状态违规失败');
         }
         $reasonArr = array('propId' => $houseId, 'brokerId' => $brokerId, 'type' => 2, 'reason' => '房源信息不实!', 'postTime' => time(), 'mid' => 0);
         Model_Log_AjkIllegalHouse::writeHouseIllegalInfo($reasonArr);
         $hpData = array('ProId' => $houseId, 'Remark' => '虚假房源违规', 'BrokerId' => $brokerId, 'CityId' => $cityId, 'Type' => 1, 'OperateId' => 0, 'From' => __CLASS__);
         Model_House_AjkHpProSpreadChange::insertProSpreadChange($hpData);
         $data = array('houseId' => $houseId, 'planId' => 0, 'brokerId' => $brokerId, 'cityId' => $cityId, 'type' => 103, 'remark' => '虚假房源违规', 'flag' => 0, 'addDate' => time(), 'dealRemark' => '', 'operateId' => 0, 'from' => __CLASS__, 'siteType' => 1);
         if (!Model_House_UpDown_Task::create($data, date('Ymd'))->save()) {
             $this->setLog('上下架通知失败');
         }
     }
     $this->setShCommonSleepTime(1);
 }
 /**
  * @param $proId
  * @param $blockId
  * @param $areaId
  * @param $cityId
  * @return int
  */
 private function changePropBlock($proId, $blockId, $areaId, $cityId, $ajk_brokerid)
 {
     //获取房源信息
     $propInfo = Bll_House_HzHouse::getPropInfo($proId, $cityId);
     //重组房源信息,同时编辑区域板块id
     //$rebuildPropInfo = $this->rebuildPropInfo($propInfo, $blockId, $areaId, $ajk_brokerid);
     $commName = $propInfo['msg']['commname'];
     $commAddress = $propInfo['msg']['address'];
     $rebuildPropInfo = array('proid' => $proId, 'blockId' => $blockId, 'areaId' => $areaId, 'isCommUpdate' => 1, 'commName' => $commName, 'commAddress' => $commAddress);
     $response = Bll_Service_House::HzUpdateCommunitysMessageInHouse($rebuildPropInfo);
     if ($response->isFailed()) {
         return Util_GlobalFunc::buildReturn(0, '好租更新房源失败,请求内部API失败.');
     }
     if ($response['status'] == 'error') {
         return Util_GlobalFunc::buildReturn(0, '好租更新失败,' . $response['info']);
     }
     return Util_GlobalFunc::buildReturn(1, 'success');
     //        //javaApi update
     //        $host = APF::get_instance()->get_config("JavaAPIHost");
     //        $url = $host . "service-combo/rest/rent/properties/update?json";
     //        $curl = new Util_Http_Curl();
     //        $re = $curl->setDefaults()->setConnectTimeOut(30)->post($url, $rebuildPropInfo);
     //        $re = json_decode($re, true);
     //        return $re;
 }