예제 #1
0
 public static function get_json_from_lucene($url, $need_debug = true)
 {
     $logfile = APF::get_instance()->get_config("save_curltime_path");
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type:text/xml; charset=utf-8"));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($curl, CURLOPT_TIMEOUT, 5);
     $start = microtime(true);
     $res = curl_exec($curl);
     $end = microtime(true);
     if (Uri_Curl::enable_save_curl() && $end - $start > 1) {
         $content = "time:" . ($end - $start) . " date:" . date('d H:i:s', time()) . " url:" . $url . "\n";
         Uri_Curl::write_file($logfile, $content);
     }
     $info = curl_getinfo($curl);
     curl_close($curl);
     if ($need_debug) {
         APF::get_instance()->debug($url);
     }
     if ($info['http_code'] != 200) {
         return "[]";
     }
     return $res;
 }
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     $mail = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     $frozenList = Model_Payment_AcFreezen::data_access()->filter('freezeEffective', 1)->filter('appid', $this->appids)->filter_by_op('createTime', '<=', $this->errorTime)->get_all();
     $re = $accountId = array();
     if ($frozenList) {
         $this->setLog('今日共' . count($frozenList));
         foreach ($frozenList as $frozen) {
             $word = $this->getWord($frozen['appid']);
             $re[$word['word']]['数量']++;
             $re[$word['word']]['金额'] += $frozen['amount'];
             $userInfo = Model_Payment_AjkUserAccount::data_access()->filter('accountId', $frozen['accountId'])->get_row();
             if (!$userInfo['userId']) {
                 continue;
             }
             $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userInfo['userId'])->get_row();
             if (!$brokerInfo['brokerId']) {
                 continue;
             }
             $brokerId = $brokerInfo['brokerId'];
             $accountId[$brokerId]['word'] = $word['word'];
             $accountId[$brokerId]['amount'] = $frozen['amount'];
             if ($this->dealFlag) {
                 //解冻处理
                 $url = $this->acenterHost . 'acenter/interfaces/?action=use&account=' . $frozen['accountId'] . '&amount=0&frozen=' . $frozen['acBalanceId'] . '&note=解冻金额&appid=' . $frozen['appid'] . '&appkey=' . $this->appInfo[$word['constWord']]['appKey'] . '&requestid=' . date('YmdHis') . mt_rand(0, 1000) . $frozen['accountId'];
                 $result = Uri_Curl::get_curl($url);
                 $this->setLog($url);
                 $this->setLog($result);
                 if ($result['result']) {
                     //解冻成功,call @马荟的查询余额接口进行数据修复
                     $balanceUrl = $this->proxyHost . 'service-exes/rest/exes/inquiry?json&appId=23&appKey=' . $this->appInfo['ajk_bid']['appKey'] . '&account=' . $frozen['accountId'];
                     $reBalance = Uri_Curl::get_curl($balanceUrl);
                     $this->setLog($balanceUrl);
                     $this->setLog($reBalance);
                     $this->setLog('account: ' . $frozen['accountId'] . ' ,业务: ' . $word['word'] . ' ,amount: ' . $frozen['amount'] . ' ,serialNumber: ' . $frozen['acBalanceId']);
                 }
             }
         }
         $str = '<table border="1"><tr><td>业务类型</td><td>数量</td><td>金额</td></tr>';
         foreach ($re as $wr => $ac) {
             $str .= '<tr><td>' . $wr . '</td><td>' . $ac['数量'] . '</td><td>' . $ac['金额'] . '</td></tr>';
         }
         $str .= '</table><br /><br /><table border="1"><tr><td>业务类型</td><td>经纪人ID</td><td>金额</td></tr>';
         foreach ($accountId as $brokerId => $ac) {
             $str .= '<tr><td>' . $ac['word'] . '</td><td>' . $brokerId . '</td><td>' . $ac['amount'] . '</td></tr>';
         }
         $str .= '</table>';
         $this->send_mail($mail, '有问题的冻结共 ' . count($frozenList), $str);
         return true;
     } else {
         $this->send_mail($mail, '今天没有有问题的冻结', '今天没有有问题的冻结');
         return true;
     }
 }
예제 #3
0
 public function handle_request()
 {
     if (empty($this->cityid)) {
         return;
     }
     $brokers = array();
     $dao = Model_Plan_AjkPropspread::data_access();
     if ($this->brokerid) {
         $dao->filter('brokerId', $this->brokerid);
     }
     $dao->filter('cityId', $this->cityid);
     $dao->filter('status', array(1, 11));
     $datas = $dao->find();
     foreach ($datas as $data) {
         if (isset($brokers[$data['brokerId']])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'user/broker/transformmoney', array('id' => $data['brokerId'], 'status' => 5));
         printf('[%s]开始处理二手房: 城市ID为%s的历史数据,brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $data['cityId'], $data['brokerId'], $result);
         $brokers[$data['brokerId']] = 1;
     }
 }
예제 #4
0
 public function handle_request()
 {
     $brokers = array();
     $dao = Model_Plan_HzPlanBasic::data_access();
     if ($this->brokerid) {
         $insql = 'a.user_id=? and ';
         $params = array($this->brokerid, $this->cityid);
     } else {
         $insql = '';
         $params = array($this->cityid);
     }
     $datas = $dao->native_sql('SELECT DISTINCT(a.user_id) AS user_id FROM rent_db.promotion_planning_basic AS a LEFT JOIN rent_db.promotion_prop_planning AS b  ON a.id=b.plan_id WHERE ' . $insql . ' b.`city_id`=? AND a.plan_type=2 AND a.`status`=1 AND b.is_valid=1;', $params);
     foreach ($datas as $data) {
         $brokerid = $data['user_id'];
         if (isset($brokers[$brokerid])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'zufang/api/broker/transformmoney', array('userid' => $brokerid, 'status' => 5));
         printf('[%s]开始处理租房: brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $brokerid, $result);
         $brokers[$brokerid] = 1;
     }
 }
예제 #5
0
 public function handle_request()
 {
     $brokers = array();
     $dao = Model_Plan_Jp::data_access();
     if ($this->brokerid) {
         $dao->filter('memberId', $this->brokerid);
     }
     $dao->filter('cityId', $this->cityid);
     $dao->filter('type', 2);
     $dao->filter('status', 2);
     $dao->filter('isDelete', '0');
     $datas = $dao->find();
     foreach ($datas as $data) {
         $brokerid = $data['memberId'];
         if (isset($brokers[$brokerid])) {
             continue;
         }
         $result = Uri_Curl::get($this->url . 'jinpu/api/choice/brokerprop', array('brokerid' => $brokerid, 'status' => 5));
         printf('[%s]开始处理金铺: brokerId为 %s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $brokerid, $result);
         $brokers[$brokerid] = 1;
     }
 }
예제 #6
0
 public function handle_request()
 {
     $brokerid = $this->getOption('brokerid');
     $cityId = 11;
     printf('[%s] lastLogId: %s, start: %s, end: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId, $this->start, $this->end);
     if (!isset($brokerid)) {
         $brokerid = 0;
     }
     $brokerInfos = Model_Broker_AjkBrokerExtend::getBrokerInfoByCityId($cityId, $this->lastLogId, $this->pageSize, $brokerid, 'K');
     if (empty($brokerInfos)) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成.');
         $this->setStop();
         $this->setShStopFlag();
         exit;
     }
     foreach ($brokerInfos as $brokerInfo) {
         if ($cityId != $brokerInfo->cityId) {
             continue;
         }
         $this->lastLogId = $brokerInfo->brokerId;
         $brokers = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerInfo->brokerId);
         if (empty($brokers)) {
             echo "no data! \r\n";
         } else {
             if ($brokers->ajkBrokerid) {
                 printf('[%s]开始处理二手房: 城市ID为%s的历史数据,brokerId为%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid);
                 //请求二手房API,处理竞价历史数据
                 $result = Uri_Curl::get($this->url . 'user/broker/transformmoney', array('id' => $brokers->ajkBrokerid, 'status' => 5));
                 printf('[%s]开始处理二手房: 城市ID为%s的历史数据,brokerId为%s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid, $result);
             }
             if ($brokers->hzBrokerid) {
                 printf('[%s]开始处理租房: 城市ID为%s的历史数据,brokerId为%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid);
                 //请求租房API,处理竞价历史数据
                 $result = Uri_Curl::get($this->url . 'zufang/api/broker/transformmoney', array('id' => $brokers->ajkBrokerid, 'status' => 5));
                 printf('[%s]开始处理租房: 城市ID为%s的历史数据,brokerId为%s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid, $result);
             }
             if ($brokers->jpBrokerid) {
                 printf('[%s]开始处理商业地产: 城市ID为%s的历史数据,brokerId为%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid);
                 //请求商业地产API,处理竞价历史数据
                 $result = Uri_Curl::get($this->url . 'jinpu/api/choice/brokerprop', array('brokerid' => $brokers->jpBrokerid, 'status' => 5));
                 printf('[%s]开始处理商业地产: 城市ID为%s的历史数据,brokerId为%s,处理结果:%s' . PHP_EOL, date('Y-m-d H:i:s'), $cityId, $brokers->ajkBrokerid, $result);
             }
             sleep(1);
         }
     }
     $params = array('cityId' => $cityId, 'lastLogId' => $this->lastLogId);
     $this->setFlag($params);
 }