Esempio n. 1
0
 /**
  * 设置profile信息
  * @param type $settingType
  * @param type $key
  * @param type $value
  */
 public function setValue($settingType, $key, $value)
 {
     $delKeySql = "DELETE FROM mdl_usersetting where SettingKey=:SettingKey and SettingType=:SettingType";
     $this->db->createCommand($delKeySql, [":SettingType" => $settingType, ":SettingKey" => $key])->execute();
     $data = ["mdl_UserSettingId" => \mysoft\helpers\String::uuid(), "SettingType" => $settingType, "SettingKey" => $key, "SettingValue" => $value, "versionnumber" => '1'];
     $this->db->createCommand()->insert("mdl_usersetting", $data)->execute();
 }
Esempio n. 2
0
 /**
  * 记录统计信息
  * @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);
 }
Esempio n. 3
0
 /**
  * @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;
 }
Esempio n. 4
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));
             }
         }
     }
 }
Esempio n. 5
0
File: DbLog.php Progetto: 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;
 }
 /**
  * 初始化函数
  */
 public function actions()
 {
     //根据前端cookie backurl跳转
     $this->backUrlLocation();
     $this->webUrl = Yii::getAlias('@webUrl');
     // HTTP根目录
     $this->theme = $this->theme ? $this->theme : 'default';
     //当前主题皮肤
     $this->pub = Yii::getAlias('@webUrl') . '/modules/' . $this->module->id . '/themes/pub';
     //注册静态资源依赖关系
     \yunke\helpers\Assets::register();
     //重复提交表单验证
     $user_ticket = I('ticket');
     $this->ticket = Yii::$app->session->get('ticket');
     //若票据不一致,则返回错误信息
     if ($user_ticket && $this->ticket != $user_ticket) {
         if (Yii::$app->request->isAjax) {
             $this->ajax_response('0', '请不要重复提交', '100000');
         } else {
             throw E("请不要重复提交", '100000');
         }
     } elseif ($user_ticket) {
         //一次请求成功后,重置ticket
         $this->ticket = NULL;
     }
     //重置ticket
     if (empty($this->ticket)) {
         $this->ticket = String::uuid();
         Yii::$app->session->set('ticket', $this->ticket);
     }
     //全局赋值
     $this->assign('webUrl', $this->webUrl);
     $this->assign('theme', $this->theme);
     $this->assign('pub', $this->pub);
     $this->orgcode = I("__orgcode");
 }
Esempio n. 7
0
 /**
  * 获取企业号管理员登录信息
  * @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);
 }
Esempio n. 8
0
File: Client.php Progetto: 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;
 }
Esempio n. 9
0
 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 '';
     }
 }
Esempio n. 10
0
 /**
  * 发送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);
 }
Esempio n. 11
0
/**
 * 取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));
    }
}
 /**
  * 添加短信日志
  * @param string $orgcode 租户编码
  * @param unknown $logid  日志id
  * @param unknown $tel	    电话号码
  * @param unknown $msg	    短信内容
  * @param unknown $response 短信响应
  * @return string
  */
 public static function AddSmsLog($orgcode, $logId, $tel, $msg, $response)
 {
     //新增
     if (empty($logId)) {
         $logId = String::uuid();
         $logRequest = ['sms_logId' => $logId, 'request' => json_encode(["apiBaseURL" => self::$apiBaseURL, "authURL" => self::$authURL, "clientId" => self::$clientId, "clientSecret" => self::$clientSecret, "tel" => $tel, "msg" => $msg]), 'startdate' => date('Y-m-d H:i:s')];
         $res = (new DbProvider($orgcode))->fetch('pub/sms/addSmsLog', [$logId, $logRequest]);
         return $logId;
     } else {
         //更新
         $logResponse = ['response' => json_encode($response), 'enddate' => date("Y-m-d H:i:s")];
         $res = (new DbProvider($orgcode))->fetch('pub/sms/modifySmsLog', [$logId, $logResponse]);
     }
 }