コード例 #1
0
ファイル: VisitStatiService.php プロジェクト: gtyd/jira
 /**
  * 记录统计信息
  * @param type $statisInfo
  */
 public static function log(array $statisInfo)
 {
     $type = 'mysoft\\statistics\\StatisticsQueue';
     if (YII_ENV == 'dev') {
         $type = 'mysoft\\statistics\\StatisticsLocalQueue';
     }
     $queueSrv = \Yii::createObject($type);
     $jsonStr = \mysoft\helpers\String::jsonEncode($statisInfo);
     $queueSrv->putMessage($jsonStr);
 }
コード例 #2
0
ファイル: ApiProxyBase.php プロジェクト: gtyd/jira
 /**
  * @param $api 接口路径
  * @param $data 参数
  * @param array $cachekey 缓存key
  * @return mixed
  * @throws \mysoft\base\Exception|void
  */
 protected function _Proxy($api, $data, $cachekey = [])
 {
     $resdata = false;
     if ($cachekey != []) {
         $resdata = \yii::$app->cache->get($cachekey);
     }
     if ($resdata === false) {
         $client = new Client();
         $resultdata = json_decode($client->get($api, $data), true);
         if ($resultdata["success"] == "1") {
             $resdata = $resultdata["data"];
         } else {
             throw E(\mysoft\helpers\String::jsonEncode($resultdata["data"]));
         }
     }
     return $resdata;
 }
コード例 #3
0
 protected function handleModifyData($erpData)
 {
     if (!empty($erpData['data']['ModifyTable'])) {
         $queueMap = [];
         //为每个租户,每个应用创建队列,将消息分发到各个队列
         foreach ($erpData['data']['ModifyTable'] as $tableName) {
             $cfg = $this->getPullDataCfg()->getDispatchConfig($this->orgcode, $tableName);
             if (!empty($cfg)) {
                 $queueKey = sprintf('org{%s}app{%s}', $this->orgcode, $cfg['app']);
                 if (!isset($queueMap[$queueKey])) {
                     $queueMap[$queueKey] = new PullDataNoticeQueue($cfg['app']);
                 }
                 $cfg['orgcode'] = $this->orgcode;
                 $queueMap[$queueKey]->putMessage(\mysoft\helpers\String::jsonEncode($cfg));
             }
         }
     }
 }
コード例 #4
0
ファイル: DbLog.php プロジェクト: gtyd/jira
 private function convertData($data)
 {
     $saveData = [];
     foreach ($data as $key => $val) {
         //不记录postData,receiveData注释
         if ($key == 'receiveDataStr') {
             $saveData['receiveData'] = $val;
             continue;
         }
         if ($key == 'postDataStr') {
             $saveData['postData'] = $val;
             continue;
         }
         if (is_array($val)) {
             $saveData[$key] = \mysoft\helpers\String::jsonEncode($val);
         } else {
             $saveData[$key] = $val;
         }
     }
     return $saveData;
 }
コード例 #5
0
ファイル: QyHelper.php プロジェクト: gtyd/jira
 /**
  * 获取企业号管理员登录信息
  * @param type $provider_access_token   服务提供商的accesstoken
  * @param type $auth_code   oauth2.0授权企业号管理员登录产生的code
  * @return type
  */
 static function getQyLoginInfo($provider_access_token, $auth_code)
 {
     $curl = new Curl();
     $ret = $curl->post(self::GET_LOGIN_INFO . http_build_query(['provider_access_token' => $provider_access_token]), String::jsonEncode($auth_code));
     return json_decode($ret, true);
 }
コード例 #6
0
ファイル: Client.php プロジェクト: gtyd/jira
 /**
  * 请求Api
  * @param strign       $http_method , post or get
  * @param string       $url , '/orgcode/demo/site/index'   
  * @param array        $params ,['id'=>1,'type'=>'test' ,...] ,也可以不传,如果参数在url参数上,这里必须传空
  * @param array|string $data post提交数据的时候必须传
  * @return string
  * @throws \Exception
  */
 private function _callApi($http_method, $url, $params = [], $data = [])
 {
     //        $cache_result = $this->_getFromCache($url,$params);
     //        if($cache_result){
     //            return $cache_result;
     //        }
     $curl = new Curl();
     if ($this->curl_options) {
         //设置超时请求
         foreach ($this->curl_options as $key => $val) {
             $curl->setOption($key, $val);
             //设置curl options
         }
     }
     //将签名参数加入到GET请求里,最终生成一个参数值,从而简化了请求
     $params[$this->sign_key] = $this->_getSign($this->appid, $this->appsecret, time());
     switch (strtoupper($http_method)) {
         case 'GET':
             $result = $curl->get($url, $params, $this->debug);
             break;
         case 'POST':
             $result = $curl->post($url, $data, $params, $this->debug);
             break;
         default:
             throw new \Exception('不支持的HTTP请求方法');
     }
     if ($curl->getError()) {
         return \mysoft\helpers\String::jsonEncode(['success' => 0, 'data' => $curl->getError()]);
     }
     return $result;
 }
コード例 #7
0
ファイル: LogService.php プロジェクト: gtyd/jira
 public function logRequest($postData, $receiveData, $requestUrl = "", $context = array())
 {
     try {
         $logInfo = ['orgcode' => $this->_orgcode, 'postDataStr' => \mysoft\helpers\String::jsonEncode((array) $postData), 'requestUrl' => $requestUrl, 'receiveDataStr' => \mysoft\helpers\String::jsonEncode($receiveData), 'taskId' => isset($context['taskId']) ? $context['taskId'] : '', 'requestTime' => isset($context['requestTime']) ? $context['requestTime'] : -1];
         if (!empty($context['logId'])) {
             //预先指定组件ID
             $logInfo['_id'] = $context['logId'];
         }
         if (isset($context['bgnTime'])) {
             $logInfo['bgnTime'] = $context['bgnTime'];
         }
         $logInfo['endTime'] = date(self::DATE_FORMART);
         if (isset($postData->data['ServiceName'])) {
             $logInfo['taskName'] = $postData->data['ServiceName'];
         }
         if (!empty($context['taskName'])) {
             $logInfo['taskName'] = $context['taskName'];
         }
         $logId = $this->_log->logging($logInfo, self::LOG_DATA);
         return $logId;
     } catch (\Exception $exc) {
         $this->logExc($exc);
         return '';
     }
 }
コード例 #8
0
ファイル: ErpApiClient.php プロジェクト: gtyd/jira
 /**
  * 发送post请求
  * @param type $apiPath
  * @param type $data
  * @param array $params
  * @param type $context 请求上下文,比如带状态的请求的taskId,格式['taskId'=>'','logId'=>'']
  * @return type
  */
 public function post($apiPath, $data, $params = array(), $context = [])
 {
     $signature = $this->_getSign($this->_appid, $this->_appsecret, time());
     $params[$this->sign_key] = $signature;
     $params['appid'] = $this->_appid;
     $curl = new Curl();
     if (!isset($this->timeout)) {
         $this->timeout = 120;
     }
     $curl->setOption(CURLOPT_TIMEOUT, $this->timeout);
     $curl->setOption(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOption(CURLOPT_SSL_VERIFYHOST, FALSE);
     $url = $this->_buildUrl($apiPath);
     $postData = ['url' => $url, 'data' => $data, 'params' => $params];
     $startTime = microtime(true);
     $context['bgnTime'] = date('Y-m-d H:i:s');
     $receiveData = $curl->post($url, \mysoft\helpers\String::jsonEncode($data), $params);
     $context['endTime'] = date('Y-m-d H:i:s');
     $context['requestTime'] = (microtime(true) - $startTime) * 1000;
     return $this->_handleReceiveData($curl, $postData, $receiveData, $context);
 }
コード例 #9
0
ファイル: functions.php プロジェクト: gtyd/jira
/**
 * 取api接口的返回值,有异常会爆出异常
 * @param $result_data
 * @return string 返回data的值
 */
function get_api_data($result_data)
{
    $resultdata = json_decode($result_data);
    if ($resultdata->success == "1") {
        return $resultdata->data;
    } else {
        throw E(\mysoft\helpers\String::jsonEncode($resultdata->data));
    }
}