Exemplo n.º 1
0
 /**
  * 以列的方式向hbase中post数据
  * @param string $server
  * @param string $key HBase的对应信息的key
  * @param mixed $content 提交的内容
  * @return string | array
  */
 private function putRowToHbase($server, $key, $content)
 {
     $hBase_config = APF::get_instance()->get_config($server, 'hbase');
     if (empty($hBase_config)) {
         return '';
     }
     $api = $hBase_config['rest_api'] . '/' . urlencode($hBase_config['table_name']) . '/' . urlencode($key);
     if ($hBase_config['column']) {
         $api .= "/" . urlencode($hBase_config['column'] . ":x");
     }
     $columns = array();
     if (is_object($content) || is_array($content)) {
         foreach ($content as $c_k => $c_v) {
             if (is_object($c_v) || is_array($c_v)) {
                 $c_v = json_encode($c_v);
             }
             $columns[] = array('column' => base64_encode("{$hBase_config['column']}:" . $c_k), '$' => base64_encode($c_v));
         }
     } elseif (is_string($content)) {
         $columns[] = $content;
     }
     $data = array('Row' => array(array('key' => base64_encode($key), 'Cell' => $columns)));
     $curl = new Util_Http_Curl();
     $curl->setDefaults()->addHeader('Content-Type', 'application/json')->addOption(CURLOPT_POSTFIELDS, json_encode($data))->post($api);
     $getInfo = $curl->getTransferInfo();
     return array('info' => $getInfo, 'data' => json_encode($data));
 }
Exemplo n.º 2
0
 /**
  * @param int $brokerId
  * @return array|bool
  * 如果没有客户主任:userName=客服代表,mobile=400-620-9008
  */
 public static function getWorkerNumInfo($brokerId = 0)
 {
     if (empty($brokerId)) {
         return false;
     }
     $host = APF::get_instance()->get_config("JavaAPIHost");
     $url = $host . "service-internal/rest/brokers/workerNumInfo?brokerId=" . $brokerId . "&json";
     $curl = new Util_Http_Curl();
     $res = $curl->setDefaults()->setConnectTimeOut(1)->get($url);
     $broker = array();
     if (!empty($res)) {
         $res = json_decode($res, true);
     }
     if ($res && $res['status'] == "ok") {
         $broker = $res['broker'];
     }
     return !empty($broker) ? $broker : array('userName' => '客服代表', 'mobile' => '400-620-9008');
 }
Exemplo n.º 3
0
 public function false_handle($info)
 {
     $url = APF::get_instance()->get_config('JavaAPIHost');
     $url .= 'service-ppc/rest/ppc/properties/updatePropertyInfo?json';
     $curl = new Util_Http_Curl();
     $fields['cityId'] = $info['cityId'];
     $fields['propId'] = $info['proId'];
     $fields['newIsVisible'] = 0;
     $fields['newModifyDate'] = time();
     $fields['newExpireDate'] = 0;
     $res = $curl->setDefaults()->post($url, $fields);
     $resArr = json_decode($res, true);
     if (strcasecmp('ok', $resArr['status']) == 0) {
         $log = sprintf("[%s]:[房源id]:%s, [房源面积]:%s,[房源户型]:%s,违规房源处理成功。", date('Y-m-d h:i:s'), $info['proId'], $info['areaNum'], $info['roomNum']);
         $this->setLog($log);
         return true;
     } else {
         $log = sprintf("[%s]:[房源id]:%s, [房源面积]:%s,[房源户型]:%s,违规房源处理失败。", date('Y-m-d h:i:s'), $info['proId'], $info['areaNum'], $info['roomNum']);
         $this->setLog($log);
         return false;
     }
 }
Exemplo n.º 4
0
 private function post($url, $data)
 {
     $curl = new Util_Http_Curl();
     $response = $curl->setDefaults()->addHeader('Content-Type', 'application/xml')->addOption(CURLOPT_USERAGENT, $this->getUserAgent())->addOption(CURLOPT_POSTFIELDS, $data)->post($url);
     $httpResponse = new Util_Solr_Response();
     $httpResponse->setTransferInfo($curl->getTransferInfo());
     if ($response === false) {
         $httpResponse->fail();
     } else {
         if ($curl->getTransferInfo('http_code') == '200') {
             $httpResponse->succeed()->setResponse($response);
         } else {
             $httpResponse->fail()->setResponse($response);
         }
     }
     return $httpResponse;
 }
Exemplo n.º 5
0
 /**
  * 给app发送消息
  * @param $brokerId
  * @param $brokerHouseId
  * @param $houseId
  * @param $userId 房东ID
  * @return mixed
  */
 private function senfAppMsg($brokerId, $brokerHouseId, $houseId, $userId)
 {
     // 通知到API用户端提示信息(消息推送)
     try {
         if (!empty($_SERVER['PG_TEST'])) {
             //如果是PG
             $userCheckInPushUrl = 'http://api.anjuke.test/mobile/v5/ershou/prop/entrust/broker_spread_notice?is_nocheck=1';
         } else {
             $userCheckInPushUrl = 'http://api.anjuke.com/mobile/v5/ershou/prop/entrust/broker_spread_notice?is_nocheck=1';
         }
         $curl = new Util_Http_Curl();
         $curl->setDefaults()->post($userCheckInPushUrl, array('broker_id' => $brokerId, 'prop_id' => $houseId, 'published_prop_id' => $brokerHouseId, 'owner_id' => $userId));
         return true;
     } catch (Exception $e) {
         // 暂时忽略请求
     }
     return false;
 }
 public function action_collect_Api_new($params)
 {
     //动作收集url
     $action_collect_url = APF::get_instance()->get_config('action_collect_url');
     $post_data = array();
     //私钥
     $key = $this->make_key($params);
     $post_data['pro_id'] = $params['prop_id'];
     $post_data['plan_id'] = $params['spread_id'];
     $post_data['broker_id'] = $params['ajk_broker_id'];
     $post_data['type'] = $params['type'];
     $post_data['from'] = $params['from'];
     $post_data['time'] = $params['time'];
     $post_data['remark'] = $params['remark'];
     $post_data['operate_id'] = $params['operate_id'];
     $post_data['site_type'] = $params['site_type'];
     $post_data['key'] = $key;
     $curl = new Util_Http_Curl();
     $result = $curl->setDefaults()->setConnectTimeOut(30)->post($action_collect_url, $post_data);
     return $result;
 }
Exemplo n.º 7
0
 /**
  * 处理单点登录
  */
 public function singleSignon($userName, $password, $sid)
 {
     $post_data = array("loginpost" => 1, "formhash" => '', "sid" => $sid, "url" => base64_encode('http://www.anjuke.com/'), "systemtime" => time(), "frombroker" => 1, "act" => 'login', "username" => $userName, "password" => $password, "history" => '');
     $loginUrl = APF::get_instance()->get_config("login_url", 'login');
     $curl = new Util_Http_Curl();
     $res = $curl->setDefaults()->post($loginUrl, $post_data);
     preg_match_all("/<img src=\\'(.+?)\\'.*?>/", $res, $allVerifyUrl);
     foreach ($allVerifyUrl[1] as $verifyUrl) {
         $verifyUrl = str_replace('&amp;', '&', $verifyUrl);
         $curl = new Util_Http_Curl();
         $curl->addOption(CURLOPT_FOLLOWLOCATION, 1);
         $curl->setDefaults()->get($verifyUrl);
     }
     preg_match_all("/<meta http-equiv=\"refresh\" content=\"0;URL=(.+?)\" \\/>/", $res, $allVerifyUrl);
     foreach ($allVerifyUrl[1] as $verifyUrl) {
         $verifyUrl = str_replace('&amp;', '&', $verifyUrl);
         $curl = new Util_Http_Curl();
         $curl->addOption(CURLOPT_FOLLOWLOCATION, 1);
         $curl->setDefaults()->get($verifyUrl);
     }
 }
Exemplo n.º 8
0
 /**
  * 房东房源被抢给app推送消息
  * @param $brokerId 抢的经纪人ID
  * @param $houseId 房东房源ID
  * @return bool
  */
 public function pushEntrustMsg($brokerId, $houseId)
 {
     if (empty($brokerId) || empty($houseId)) {
         return false;
     }
     // 判断委托房源是否存在
     $house = Model_House_CommissionHouse::data_access()->filter('id', $houseId)->find_only();
     if (empty($house)) {
         //房源不存在,不需要推送消息
         return false;
     }
     // 通知到API用户端提示信息(消息推送)
     try {
         if (!empty($_SERVER['PG_TEST'])) {
             //如果是PG
             $userCheckInPushUrl = 'http://api.anjuke.test/mobile/v5/broker/checkin/notice?is_nocheck=1';
         } else {
             $userCheckInPushUrl = 'http://api.anjuke.com/mobile/v5/broker/checkin/notice?is_nocheck=1';
         }
         $curl = new Util_Http_Curl();
         return $curl->setDefaults()->post($userCheckInPushUrl, array('broker_id' => $brokerId, 'prop_id' => $houseId, 'updated' => time(), 'owner_id' => $house->userId, 'owner_name' => $house->userName));
     } catch (Exception $e) {
         // 暂时忽略请求
         return false;
     }
 }
Exemplo n.º 9
0
 /**
  *
  * 备注:
  * 1.$fields['from'] 为必传值,标记来源的。
  *
  * @param $fields 中间件参数
  * @param $type 调用的中间健类型
  * @param $site_type 网站类型
  * @param string $split
  * @param string $requestId $requestId 和中间件打交道的唯一id<房源日志来的数据为分表的日志>
  * @param string $remark
  * @return bool|mixed
  */
 private static function noticeSolrApi($fields, $type, $site_type, $split = '', $requestId = '', $remark = '')
 {
     //简单判断来源值
     if (empty($fields['from_type'])) {
         return false;
     }
     //请求唯一id生成
     if (empty($requestId)) {
         $requestId = is_array($fields['pro_id']) ? time() . mt_rand(1000, time()) : time() . $fields['pro_id'];
     }
     //获取中间健的host
     $url = self::getNoticeUrl($type);
     $url .= 'publish?tunnel=' . $type . "&requestId=" . $requestId;
     $curl = new Util_Http_Curl();
     $res = $curl->setDefaults()->addOption(CURLOPT_POSTFIELDS, json_encode($fields))->post($url);
     //记录请求与返回值
     if (is_array($fields['pro_id'])) {
         foreach ($fields['pro_id'] as $pro_id) {
             $proId = $pro_id;
             $brokerId = $fields['broker_id'];
             $cityId = $fields['city_id'];
             $param = json_encode($fields);
             $result = $res;
             $from = $fields['from_type'];
             $siteType = $site_type;
             $split = empty($split) ? date('Ymd') : $split;
             Model_House_HouseLogSolr::addProLogSolr($requestId, $proId, $brokerId, $cityId, $url, $param, $result, $remark, $from, $siteType, $split);
         }
     } else {
         $proId = $fields['pro_id'];
         $brokerId = $fields['broker_id'];
         $cityId = $fields['city_id'];
         $param = json_encode($fields);
         $result = $res;
         $from = $fields['from_type'];
         $siteType = $site_type;
         $split = empty($split) ? date('Ymd') : $split;
         Model_House_HouseLogSolr::addProLogSolr($requestId, $proId, $brokerId, $cityId, $url, $param, $result, $remark, $from, $siteType, $split);
     }
     return json_decode($res, true);
 }
Exemplo n.º 10
0
 /**
  * 精选通知solr
  */
 public function choiceUpDownSendSolr($fields)
 {
     /** 2015-06-08 曹阳说已经在上下架Job里处理了 */
     return true;
     $url = Bll_Combo_NoticeSolrUpDown::getNoticeUrl('esf_prop_auction_updown');
     $url .= 'publish?tunnel=esf_prop_auction_updown';
     file_put_contents('/data1/logs/SendSolrForApi.log', $url . "\n", FILE_APPEND);
     file_put_contents('/data1/logs/SendSolrForApi.log', json_encode($fields) . "\n", FILE_APPEND);
     $curl = new Util_Http_Curl();
     $res = $curl->setDefaults()->addOption(CURLOPT_POSTFIELDS, json_encode($fields))->post($url);
     file_put_contents('/data1/logs/SendSolrForApi.log', $res . "\n", FILE_APPEND);
     $resArr = json_decode($res, true);
     if ($resArr['status'] == 'ok') {
         return true;
     } else {
         $this->setMsg($res);
         return false;
     }
 }
Exemplo n.º 11
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propertyId = $this->_params['propertyId'];
     //读取经纪人信息
     $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     //城市是否开通房源库
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($BrokerInfo['BaseInfo']['CITYID']);
     if ($cityInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '已开通房源库,不可抢~', 'errcode' => Const_APIStatus::E_COMMISSION_INVALID);
     }
     //是否收费
     $isToll = Bll_Broker_EntrustPrice::getInstance()->checkCityConsumeStatus($BrokerInfo['BaseInfo']['CITYID']);
     if ($isToll) {
         // 不能再抢了请升级
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_PROMPT_UPDATE, 'message' => '你的版本太老了,快更新到新版本吧!');
     }
     // 判断是否是推送房源
     $pushedHouse = Model_House_CommissionHousePushed::data_access()->filter('brokerId', $brokerId)->filter('propertyId', $propertyId)->filter('propertyStatus', array(Model_House_CommissionHouse::STATUS_ONGOING, Model_House_CommissionHousePushed::STATUS_RUSHED))->find_only();
     if (!$pushedHouse) {
         throw new Exception('来晚了,房源已删除', Const_APIStatus::E_COMMISSION_INVALID);
     }
     // 判断委托房源是否存在
     $house = Model_House_CommissionHouse::data_access()->filter('id', $propertyId)->find_only();
     if (!$house || $house->proStatus != Model_House_CommissionHouse::STATUS_ONGOING) {
         throw new Exception('来晚了,房源已删除', Const_APIStatus::E_COMMISSION_INVALID);
     }
     // 判断是否已抢过委托
     $commission = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $propertyId)->find_only();
     if ($commission) {
         // 更新推送房源状态
         if ($pushedHouse->propertyStatus != Model_House_CommissionHousePushed::STATUS_RUSHED) {
             $this->pushedHouseRushed($pushedHouse);
         }
         // 如果已抢,仍然返回成功状态
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'message' => '抢过了!去“我的委托”里看看');
     }
     if ($house->openBrokerCnt >= Model_House_CommissionHouse::allowedMaxCommissionCount()) {
         throw new Exception('抢完了~', Const_APIStatus::E_COMMISSION_FULL);
     }
     // 防并发(先插入,再检测(超出,删除),最后更新)
     // TODO 该方案层使用在2013圣诞活动“找锤子,砸金蛋”,并导致数据库多次TMC,但是在该业务场景中瞬时并发并没有那么多,暂定使用 by 胡言言 2014.02.28
     $commission = Model_House_Commission::create(array('type' => $house->commissionType, 'ownerId' => $house->userId, 'houseId' => $house->id, 'brokerId' => $brokerId, 'origin' => Model_House_Commission::ORIGIN_APP, 'createTime' => date('Y-m-d H:i:s'), 'updateTime' => date('Y-m-d H:i:s')));
     $commission->save();
     $rank = Model_House_Commission::data_access()->filter_by_op('houseId', '=', $house->id)->filter_by_op('id', '<=', $commission->id)->sort('id', 'asc')->count();
     if ($rank > Model_House_CommissionHouse::allowedMaxCommissionCount()) {
         $commission->delete();
         throw new Exception('抢完了~', Const_APIStatus::E_COMMISSION_FULL);
     }
     // 更新房源的委托数量
     $house->incrCommissionCount();
     // 更新推送房源状态
     $this->pushedHouseRushed($pushedHouse);
     // 通知到API用户端提示信息(消息推送)
     try {
         $userCheckInPushUrl = 'http://api.anjuke.com/mobile/v5/broker/checkin/notice?is_nocheck=1';
         $curl = new Util_Http_Curl();
         $curl->setDefaults()->post($userCheckInPushUrl, array('broker_id' => $brokerId, 'prop_id' => $propertyId, 'updated' => time(), 'owner_id' => $house['userId'], 'owner_name' => $house['userName']));
     } catch (Exception $e) {
         // 暂时忽略请求
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'message' => '抢成功!快去联系业主吧');
 }