Browse Source

短信调通

junfei 6 years ago
parent
commit
fa035febb3

+ 15 - 8
app/common.php

@@ -50,7 +50,7 @@ $arr = array('a' => '555', 'b' => 56454564);
  *            bool HTTPS时是否进行严格认证
  * @return string
  */
-function curl_post_json($url, $data,$timeout=100){
+function curl_huawei_sms($url, $data, $timeout=100){
 
     $CA = false;
 
@@ -86,11 +86,16 @@ function curl_post_json($url, $data,$timeout=100){
     $time           = time();
     $created        = date('Y-m-d', $time) . 'T' . date('H:i:s', $time) . 'Z';
     //$created        = '2019-07-10T15:02:08Z';
+    $username = 'd9c3190120db4b2ab078a543d59ba47d';
     $password       = '33ab0a75ee246f85e41f2c15d867ca5d';
+
+    //正式
+    $username='67ef6805e6004cce9cce24b7f13767c6';
+    $password       = '1e88f55b4e034b1783e2686ec9dfbffd';
     $nonce = base64_encode($nonce);// . $created . $password;
     $signRawString = $nonce . $created . $password;//;//
-//    echo "明文:", $signRawString,"\n";
-//    echo "明文:", $signRawString,"\n";
+    echo "明文:", $signRawString,"\n";
+    echo "明文:", $signRawString,"\n";
     //$signRawString = '66C92B11FF8A425FB8D4CCFE2019-07-08T17:56:46Z33ab0a75ee246f85e41f2c15d867ca5d';
     //$signRawString='a';
     //var_dump(hash('sha256',$signRawString,true));exit;
@@ -102,12 +107,12 @@ function curl_post_json($url, $data,$timeout=100){
 
 
     $headerArr[] = 'Authorization: WSSE realm="SDP", profile="UsernameToken", type="Appkey"';
-    $headerArr[] = 'X-WSSE:UsernameToken Username="d9c3190120db4b2ab078a543d59ba47d",PasswordDigest="' . $passwordDigest . '",Nonce="' . $nonce . '",Created="' . $created . '"';
+    $headerArr[] = 'X-WSSE:UsernameToken Username="'.$username.'",PasswordDigest="' . $passwordDigest . '",Nonce="' . $nonce . '",Created="' . $created . '"';
     $headerArr[] = 'Content-Type: application/json; charset=UTF-8';
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
     //var_dump(C('test_proxy'));exit;
     //if(C('test_proxy')) {
-    //curl_setopt($ch, CURLOPT_PROXY, '192.168.1.211:8888');
+    curl_setopt($ch, CURLOPT_PROXY, '192.168.16.96:8888');
     //}
     $ret = curl_exec($ch);
     if (empty($ret)) {
@@ -135,7 +140,7 @@ function curl_post_json_pay($url, $data,$headers=[],$timeout=100){
     $ch     = curl_init();
     curl_setopt($ch, CURLOPT_POST, true);
 
-    if(!empty($data))   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     //var_dump($data);exit;
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
@@ -159,7 +164,7 @@ function curl_post_json_pay($url, $data,$headers=[],$timeout=100){
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     //var_dump(C('test_proxy'));exit;
     //if(C('test_proxy')) {
-    //curl_setopt($ch, CURLOPT_PROXY, '192.168.16.96:8888');
+    curl_setopt($ch, CURLOPT_PROXY, '192.168.16.96:8888');
     //}
     $ret = curl_exec($ch);
     if (empty($ret)) {
@@ -260,4 +265,6 @@ function curl_post_json_sdk($url, $data,$timeout=100){
 
 function I(string $key = '', $default = null, $filter = ''){
     return input($key,$default,$filter);
-}
+}
+
+

+ 33 - 0
app/common/exception/Notification.php

@@ -0,0 +1,33 @@
+<?php
+namespace rest\common\exception;
+
+use Exception;
+use think\exception\Handle;
+use think\exception\HttpException;
+class Notification extends Handle
+{
+
+    public function render(Exception $e)
+    {
+      /*  // 参数验证错误
+        if ($e instanceof ValidateException) {
+            return json($e->getError(), 422);
+        }
+
+        // 请求异常
+        if ($e instanceof HttpException && request()->isAjax()) {
+            return response($e->getMessage(), $e->getStatusCode());
+        }*/
+
+
+        //TODO::开发者对异常的操作
+
+        $errorContent = $e->getMessage().' '.$e->getFile().' '.$e->getLine().'行';
+        //echo $errorContent;
+        if(function_exists('error_notify'))  error_notify($errorContent);
+
+        //可以在此交由系统处理
+        return parent::render($e);
+    }
+
+}

+ 53 - 0
app/common/util/http.php

@@ -0,0 +1,53 @@
+<?php
+namespace app\common\util;
+class http
+{
+    protected $baseUrl = 'http://localhost';
+    protected $client;
+    protected $cookieJar;
+
+    function __construct()
+    {
+
+
+        $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar();
+
+        $config = [
+            'base_uri' => "",
+            'timeout'  => 10.0,
+            'cookies'  => $this->cookieJar,
+            'cookies'  => true,
+            //'proxy' => 'http://192.168.16.16:8888',
+            // 'allow_redirects' => false,
+        ];
+
+        $config['proxy'] = 'http://192.168.16.96:8888';
+
+        $this->client = new \GuzzleHttp\Client($config);
+    }
+
+    function request($uri, $method, $param, $header = [])
+    {
+
+        $method = strtolower($method);
+
+        $options            = [];
+        $options['cookies'] = $this->cookieJar;
+        $options['headers'] = $header;
+        $options['verify']  = false;
+
+
+        if (is_array($param)) {
+            $options['form_params'] = $param;
+        } elseif (is_string($param)) {
+            $options['body'] = $param;
+        }
+
+        $method = strtoupper($method);
+        $r      = $this->client->request($method, $uri, $options);
+        return $r;
+
+    }
+
+
+}

+ 19 - 0
app/config.php

@@ -0,0 +1,19 @@
+<?php
+return
+    [
+    'exception_handle'       => '\\rest\\common\\exception\\Notification',
+    'log'                    => [
+        'type'  => 'File',
+        'path'  => LOG_PATH,
+        'level' => ['error','sql'],
+        'file_size'=>102400000,
+    ],
+    'enable_log_request'=>true, //记录请求日志
+	 'mail'=>[
+        'username'=>'123456@qq.com',
+        'password'=>'123456',
+        'host'=>'smtp.qq.com',
+        'port'=>465,
+    ],
+];
+  

+ 17 - 8
app/controller/Index.php

@@ -9,6 +9,12 @@ use think\facade\Db;
 class Index extends BaseController
 {
 
+    function test(){
+        ini_set("display_errors","On");
+        error_reporting(E_ALL );
+        //actionBegin();
+    }
+
     function pay(){
         return view();
     }
@@ -160,7 +166,7 @@ class Index extends BaseController
         $params['countryID']     = $countryID;
 
 
-        $ret = curl_post_json($url, json_encode($params));
+        $ret = curl_huawei_sms($url, json_encode($params));
 
 
 
@@ -212,7 +218,7 @@ class Index extends BaseController
         $params['countryID']     = 'CN';
 
 
-        $ret = curl_post_json($url, json_encode($params));
+        $ret = curl_huawei_sms($url, json_encode($params));
     }
 
     function province()
@@ -285,12 +291,13 @@ class Index extends BaseController
         ];
 
         $params['originalAmount'] = I('totalPrice');
+        $params = json_encode($params);
 
 
-        //$params = '{"originalAmount":"6","currency":"USD","intent":"sale","shortCode":"100000703","commodityDesc":"PGW payment","note2Payer":"Good Choice","merchantInvoiceNumber":"abc","discountedAmount":"1"}';
+        $params = '{"originalAmount":"6","currency":"USD","intent":"sale","shortCode":"100000703","commodityDesc":"PGW payment","note2Payer":"Good Choice","merchantInvoiceNumber":"abc","discountedAmount":"1"}';
 
         //$params = var_export(json_decode($params,true),true);
-        $params = json_encode($params);
+
 
         $headers[] = 'X-APP-Key: APP ID';
         $headers[] = 'Authorization:Bearer Access-Token';
@@ -305,18 +312,20 @@ class Index extends BaseController
 
     function execute()
     {
+
         $paymentID = I('paymentID');
 
         //$paymentID          = 'PP27F16000000000051006';
         $url                = "https://www.apifabric.com.cn/apiaccess/payment/paymentGateway/checkout/v1/{$paymentID}/execute";
-        $params             = [];
-        $params['couponID'] = '1';
-        $params             = json_encode($params);
-
+        //$params             = [];
+        //$params['couponID'] = '1';
+        //$params             = json_encode($params);
+        $params='';
         $headers[] = 'X-APP-Key: APP ID';
         $headers[] = 'Authorization:Bearer Access-Token';
         $headers[] = 'Content-Type: application/json; charset=UTF-8';
         $ret       = curl_post_json_pay($url, $params, $headers);
+        $ret = json_decode($ret,true);
         $ret['isSuccess'] = true;
         return jsonp($ret);
 

+ 112 - 4
app/controller/Sms.php

@@ -4,6 +4,8 @@ namespace app\controller;
 
 use app\BaseController;
 use think\facade\Db;
+use \app\common\util\http;
+
 
 class Sms extends BaseController
 {
@@ -16,13 +18,51 @@ class Sms extends BaseController
     ];
 
 
+    /**
+     * 未做,日志记录,出错记录等
+     */
+    function send(){
+
+
+        $input = file_get_contents("php://input");
+        $input = json_decode($input,true);
+        $countryID = $input['countryID']; //CN,SG
+        $phoneNumber = $input['to'];
+        $content = $input['content'];
+
+
+        $param['user']=$content;
+        $params['smsTemplateId'] = '0a2dc8e2-0f64-4b41-a10c-50222d8b6e65';
+        $params['paramValues'] = $param; //        paramValues:{"user":"XXX"}
+        $params['msisdn']      = $phoneNumber;
+        $params['countryID']   = $countryID;
+
+
+        $url                     = "https://www.huaweiita.com:17131/apiaccess/sms/sendTemplateSms/v1";
+        $retCurl = curl_huawei_sms($url, json_encode($params));
+        $retCurl = json_decode($retCurl,true); //原始信息入库
+        if($retCurl['code'] == '0000000'){
+            $ret['code'] = 1;
+            $ret['msg']  = $retCurl['description'];
+        }else{
+            $ret['code'] = 0;
+            $ret['msg']  = $retCurl['description'];
+            $ret['error_code'] = $retCurl['code'];
+            $ret['error_msg'] = $retCurl['exErrorMessage'];
+
+            //记录原始错误消息入库
+        }
+
+
+    }
+
     /**
      * $templateId
      * $param
      * $phone_number
      * countryID
      */
-    function send()
+    function sendByAuth()
     {
 
         $headerAuthorization = I('server.HTTP_AUTHORIZATION');
@@ -76,7 +116,7 @@ class Sms extends BaseController
             $params['operatorCode']   = $postDta['operatorCode'];
 
 
-            $retCurl = curl_post_json($url, json_encode($params));
+            $retCurl = curl_huawei_sms($url, json_encode($params));
             $retCurl = json_decode($retCurl,true); //原始信息入库
             if($retCurl['code'] == '0000000'){
                 $ret['code'] = 1;
@@ -136,16 +176,84 @@ class Sms extends BaseController
     {
         $url                     = "https://www.huaweiita.com:17131/apiaccess/sms/sendTemplateSms/v1";
         $params                  = [];
+        //$params['smsTemplateId'] = '695db7b5-6d4f-4791-aea0-f733f2ef06ce';
+        $params['smsTemplateId'] = '0a2dc8e2-0f64-4b41-a10c-50222d8b6e65';
+        $paramValues             = [];
+        $paramValues['user']     = 'test1';
+        $params['paramValues']   = $paramValues; //        paramValues:{"user":"XXX"}
+        $params['msisdn']        = '8615821868265';
+        $params['countryID']     = 'SG';
+        //$params['msisdn']        = '8613162836361';
+        //$params['countryID']     = 'CN';
+
+
+
+        $ret = curl_huawei_sms($url, json_encode($params));
+    }
+
+
+    function sendByGuzzle()
+    {
+
+
+        $url                     = "https://www.huaweiita.com:17131/apiaccess/sms/sendTemplateSms/v1";
+        //$url                     = "http://stest.uzipm.com/index/index";
+        $params                  = [];
         $params['smsTemplateId'] = '695db7b5-6d4f-4791-aea0-f733f2ef06ce';
+        $params['smsTemplateId'] = '0a2dc8e2-0f64-4b41-a10c-50222d8b6e65';
         $paramValues             = [];
         $paramValues['user']     = 'test1';
         $params['paramValues']   = $paramValues; //        paramValues:{"user":"XXX"}
         $params['msisdn']        = '8615821868265';
-        $params['countryID']     = 'CN';
+        $params['countryID']     = 'SG';
+//        $params['msisdn']        = '8613162836361';
+//        $params['countryID']     = 'CN';
+
+
 
+        //$ret = curl_post_json($url, json_encode($params));
 
-        $ret = curl_post_json($url, json_encode($params));
+        $header = $this->getHeader();
+
+        $http = new http();
+        $http->request($url,'post',json_encode($params),$header);
+    }
+
+    function getHeader(){
+        date_default_timezone_set("UTC");
+        //$nonce          = '66C92B11FF8A425FB8D4CCFE';
+        $nonce = $nonce1          = mt_rand(100000,9999999999);
+        $time           = time();
+        $created        = date('Y-m-d', $time) . 'T' . date('H:i:s', $time) . 'Z';
+        //$created        = '2019-07-10T15:02:08Z';
+
+        //test
+        $username = 'd9c3190120db4b2ab078a543d59ba47d';
+        $password       = '33ab0a75ee246f85e41f2c15d867ca5d';
+
+        //正式
+        $username='67ef6805e6004cce9cce24b7f13767c6';
+        $password       = '1e88f55b4e034b1783e2686ec9dfbffd';
+        $nonce = base64_encode($nonce);// . $created . $password;
+        $signRawString = $nonce . $created . $password;//;//
+        echo "明文:", $signRawString,"\n";
+        echo "明文:", $signRawString,"\n";
+        //$signRawString = '66C92B11FF8A425FB8D4CCFE2019-07-08T17:56:46Z33ab0a75ee246f85e41f2c15d867ca5d';
+        //$signRawString='a';
+        //var_dump(hash('sha256',$signRawString,true));exit;
+        $passwordDigest = base64_encode(hash('sha256',$signRawString,true));
+
+        //echo "明文: $signRawString \n";
+        //echo "密文: $passwordDigest \n";
+        //exit;
+
+        $headerArr=[];
+        $headerArr['Authorization'] = 'WSSE realm="SDP", profile="UsernameToken", type="Appkey"';
+        $headerArr['X-WSSE'] = 'UsernameToken Username="'.$username.'",PasswordDigest="' . $passwordDigest . '",Nonce="' . $nonce . '",Created="' . $created . '"';
+        $headerArr['Content-Type'] = 'application/json; charset=UTF-8';
+        return $headerArr;
     }
 
 
 }
+

+ 6 - 0
app/database.php

@@ -0,0 +1,6 @@
+<?php
+return [
+	//其它配置...
+    'debug'       => true,
+ 
+];

+ 3 - 1
app/event.php

@@ -15,7 +15,9 @@ return [
     ],
 
     'listen'    => [
-        'AppInit'  => [],
+        'AppInit'  => [
+        //    '\application\listener\Trace'
+        ],
         'HttpRun'  => [],
         'HttpEnd'  => [],
         'LogLevel' => [],

+ 105 - 0
app/index/behavior/Trace.php

@@ -0,0 +1,105 @@
+<?php
+
+namespace application\index\behavior;
+class Trace
+{
+    function actionBegin(){
+
+        if(!config('enable_log_request') || IS_CLI)	return;
+
+       try {
+            //error_reporting(E_ERROR | E_PARSE);
+            //error_reporting(E_ALL);
+            defined('IS_POST') or define('IS_POST', request()->isPost());
+            defined('IS_AJAX') or define('IS_AJAX',request()->isAjax());
+            defined('IS_GET') or define('IS_GET', request()->isGet());
+            
+			//不需要记录的url地址
+			$blacklist = [
+                "/index/news/getList",
+            ];
+
+            foreach ($blacklist as $v) {
+                if (strpos($_SERVER['REQUEST_URI'], $v) !== false) return;
+            }
+
+            $data = array();
+            $data['url'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+            if (IS_POST) {
+                $params = $_POST;
+            } elseif (IS_GET) {
+                $params = $_GET;
+            }
+            if (empty($params)) $params['input'] = file_get_contents("php://input");
+            $data['params'] = json_encode($params);
+            //$data['cookie'] = json_encode($_COOKIE);
+            //$data['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+            $data['ip'] = get_client_ip();
+            $detail = array();
+            $detail['request'] = $_REQUEST;
+
+            $header = [];
+            $fields = ['HTTP_USER_ID', 'HTTP_DEVICE_VID', 'HTTP_DEVICE_ID', 'HTTP_PLATFORM', 'HTTP_VERSION']; //'HTTP_USER_AGENT',
+            foreach ($fields as $k => $v) {
+                if (empty($_SERVER[$v])) continue;
+                $header[$v] = $_SERVER[$v];
+            }
+            /*$this->version = I('server.HTTP_VERSION');
+            $this->device_id = I('device_id') ?:I('server.HTTP_DEVICE_ID');
+            $this->platform = I('server.HTTP_PLATFORM');
+            $user_id = I('user_id') ?: I('server.HTTP_USER_ID');
+            $detail['server'] = $_SERVER;*/
+            //$detail['header'] = $header;
+            //$data['detail'] = json_encode($detail);
+            $url = $_SERVER['REQUEST_METHOD'] . " " . $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " " . $_SERVER['SERVER_PROTOCOL'] . "\r\n";
+            $request = $url . getallheaders(true);
+
+            $raw_post = '';
+            if (IS_POST) {
+                $raw_post = http_build_query($_POST);
+                if (empty($raw_post)) {
+                    $raw_post = file_get_contents("php://input");
+                }
+            }
+            $request .= "\r\n" . $raw_post;
+
+            $data['detail'] = $request;
+            $data['user_agent'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
+            //$data['platform'] = I('server.HTTP_PLATFORM');
+            $data['user_id'] = I('user_id');////cookie可能取出null,要求字段必须可为null
+            if (empty($data['user_id'])) {
+                $userInfo = cookie('LOGIN_USER');
+                $user_id = $userInfo['user_id'];
+                $data['user_id'] = $user_id;
+            }
+
+            $data['create_time'] = date("Y-m-d H:i:s");
+            $data['method'] = $_SERVER['REQUEST_METHOD'];
+            //$data['date_int'] = time();
+
+
+            $m = db('LogRequest');
+            //$m->create($data);
+            $result = $m->insert($data);
+            $logId = $m->getLastInsID();
+            config('logId', $logId);
+        }catch (\Exception $e){
+            tplog($e->getMessage());
+        }
+
+        \think\Db::listen(function($sql, $time, $explain){
+
+            $logId = config('logId');
+            if(!empty($logId) && strpos($sql,'log_request') === false){
+                file_put_contents(RUNTIME_PATH."/$logId.sql", $sql.PHP_EOL, FILE_APPEND);
+            }
+
+            // 记录SQL
+            //echo $sql. ' ['.$time.'s]';
+            // 查看性能分析结果
+            //dump($explain);
+        });
+        // exit('x');
+
+    }
+}

+ 98 - 0
app/index/controller/Monitor.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace rest\index\controller;
+use think\Controller;
+
+class Monitor extends Controller
+{
+    public $m;
+
+
+
+    public function startQueue()
+    {
+        $this->m = db('queue');
+
+        $r = $this->m->select();
+        foreach ($r as $k => $v) {
+            $message = json_decode($v['message'],true);
+            extract($message);
+            if(empty($module)) $module = "User";
+            //var_dump($parameter);
+            //var_dump("{$module}/{$controller}/{$action}");
+            $r = action("{$module}/{$controller}/{$action}",$parameter);
+            if($r){
+                $this->m->delete($v['id']);
+            }
+            //var_dump($r);
+        }
+    }
+	
+	    function logSqlToDb(){
+
+        $files = glob(RUNTIME_PATH."*.sql");
+        foreach ($files as $k=>$file){
+            $pathinfo = pathinfo($file);
+            $id = $pathinfo['filename'];
+            if(!is_numeric($id)) continue;
+            $sqlContent = file_get_contents($file);
+            //$sqlContent = addslashes($sqlContent);
+            $r = \think\Db::name('LogRequest')->where(['id'=>$id])->update(['response'=>$sqlContent]);
+            //echo \think\Db::name('LogRequest')->getLastSql();
+            if($r){
+                unlink($file);
+            }
+        }
+    }
+	 
+    /**
+     * 用于处理队列
+     * 必须定义接受参数,否则接受不到列表分发器传过来的参数
+     * @param $content
+
+     */
+    function alarm(string $content){
+        try{
+            $admin_mail = config('admin_eamil');
+            if($admin_mail){
+                $r = sendmail("出错啦!",$content,$admin_mail,'');
+                if($r) return true;
+            }
+        }catch (\Exception $e){
+            tplog('邮件发送失败');
+        }
+        return false;
+    }
+
+    /**
+     * 用于处理队列
+     * 必须定义接受参数,否则接受不到列表分发器传过来的参数
+     * @param $content
+
+     */
+    function alarm_sms(string $content){
+        try{
+            //发短信提示课程拥有者
+            //$mobile = getMobileOfCourseOwner();
+            $mobile = '13100001111';
+
+            $content = cn_substr_utf8($content,40);
+            $template_id = 'SMS_123';
+
+            $d = [];
+            $d['mobile'] = $mobile;
+            $d['content'] = "content:{$content} ";
+            $d['ip'] = get_client_ip();
+            $sms_id = db('SmsQueue')->add($d);
+            $r = send_sms_system($mobile, ['content'=>$content],$template_id,$sms_id);
+        }catch (\Exception $e){
+            tplog('新评论提示符短信发送失败');
+        }
+    }
+}
+
+
+
+
+
+

+ 105 - 0
app/listener/Trace.php

@@ -0,0 +1,105 @@
+<?php
+
+namespace application\listener;
+class Trace
+{
+    function handle(){
+
+        if(!config('enable_log_request') || IS_CLI)	return;
+
+       try {
+            //error_reporting(E_ERROR | E_PARSE);
+            //error_reporting(E_ALL);
+            defined('IS_POST') or define('IS_POST', request()->isPost());
+            defined('IS_AJAX') or define('IS_AJAX',request()->isAjax());
+            defined('IS_GET') or define('IS_GET', request()->isGet());
+            
+			//不需要记录的url地址
+			$blacklist = [
+                "/index/news/getList",
+            ];
+
+            foreach ($blacklist as $v) {
+                if (strpos($_SERVER['REQUEST_URI'], $v) !== false) return;
+            }
+
+            $data = array();
+            $data['url'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+            if (IS_POST) {
+                $params = $_POST;
+            } elseif (IS_GET) {
+                $params = $_GET;
+            }
+            if (empty($params)) $params['input'] = file_get_contents("php://input");
+            $data['params'] = json_encode($params);
+            //$data['cookie'] = json_encode($_COOKIE);
+            //$data['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+            $data['ip'] = get_client_ip();
+            $detail = array();
+            $detail['request'] = $_REQUEST;
+
+            $header = [];
+            $fields = ['HTTP_USER_ID', 'HTTP_DEVICE_VID', 'HTTP_DEVICE_ID', 'HTTP_PLATFORM', 'HTTP_VERSION']; //'HTTP_USER_AGENT',
+            foreach ($fields as $k => $v) {
+                if (empty($_SERVER[$v])) continue;
+                $header[$v] = $_SERVER[$v];
+            }
+            /*$this->version = I('server.HTTP_VERSION');
+            $this->device_id = I('device_id') ?:I('server.HTTP_DEVICE_ID');
+            $this->platform = I('server.HTTP_PLATFORM');
+            $user_id = I('user_id') ?: I('server.HTTP_USER_ID');
+            $detail['server'] = $_SERVER;*/
+            //$detail['header'] = $header;
+            //$data['detail'] = json_encode($detail);
+            $url = $_SERVER['REQUEST_METHOD'] . " " . $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " " . $_SERVER['SERVER_PROTOCOL'] . "\r\n";
+            $request = $url . getallheaders(true);
+
+            $raw_post = '';
+            if (IS_POST) {
+                $raw_post = http_build_query($_POST);
+                if (empty($raw_post)) {
+                    $raw_post = file_get_contents("php://input");
+                }
+            }
+            $request .= "\r\n" . $raw_post;
+
+            $data['detail'] = $request;
+            $data['user_agent'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
+            //$data['platform'] = I('server.HTTP_PLATFORM');
+            $data['user_id'] = I('user_id');////cookie可能取出null,要求字段必须可为null
+            if (empty($data['user_id'])) {
+                $userInfo = cookie('LOGIN_USER');
+                $user_id = $userInfo['user_id'];
+                $data['user_id'] = $user_id;
+            }
+
+            $data['create_time'] = date("Y-m-d H:i:s");
+            $data['method'] = $_SERVER['REQUEST_METHOD'];
+            //$data['date_int'] = time();
+
+
+            $m = db('LogRequest');
+            //$m->create($data);
+            $result = $m->insert($data);
+            $logId = $m->getLastInsID();
+            config('logId', $logId);
+        }catch (\Exception $e){
+            tplog($e->getMessage());
+        }
+
+        \think\Db::listen(function($sql, $time, $explain){
+
+            $logId = config('logId');
+            if(!empty($logId) && strpos($sql,'log_request') === false){
+                file_put_contents(RUNTIME_PATH."/$logId.sql", $sql.PHP_EOL, FILE_APPEND);
+            }
+
+            // 记录SQL
+            //echo $sql. ' ['.$time.'s]';
+            // 查看性能分析结果
+            //dump($explain);
+        });
+        // exit('x');
+
+    }
+}

+ 6 - 0
app/tags.php

@@ -0,0 +1,6 @@
+<?php
+return [
+    'action_begin'=> [
+        'rest\\index\\behavior\\Trace',
+    ],
+];

+ 363 - 313
composer.lock

@@ -4,213 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "33d5378972f1416a2cb116debf84d013",
+    "content-hash": "30b824d7bbe84ae98c3b8ec7339bb92e",
     "packages": [
-        {
-            "name": "guzzlehttp/guzzle",
-            "version": "6.3.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/guzzle/guzzle.git",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
-                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
-            },
-            "require": {
-                "guzzlehttp/promises": "^1.0",
-                "guzzlehttp/psr7": "^1.4",
-                "php": ">=5.5"
-            },
-            "require-dev": {
-                "ext-curl": "*",
-                "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
-                "psr/log": "^1.0"
-            },
-            "suggest": {
-                "psr/log": "Required for using the Log middleware"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "6.3-dev"
-                }
-            },
-            "autoload": {
-                "files": [
-                    "src/functions_include.php"
-                ],
-                "psr-4": {
-                    "GuzzleHttp\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Michael Dowling",
-                    "email": "mtdowling@gmail.com",
-                    "homepage": "https://github.com/mtdowling"
-                }
-            ],
-            "description": "Guzzle is a PHP HTTP client library",
-            "homepage": "http://guzzlephp.org/",
-            "keywords": [
-                "client",
-                "curl",
-                "framework",
-                "http",
-                "http client",
-                "rest",
-                "web service"
-            ],
-            "time": "2018-04-22T15:46:56+00:00"
-        },
-        {
-            "name": "guzzlehttp/promises",
-            "version": "v1.3.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/guzzle/promises.git",
-                "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
-                "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
-            },
-            "require": {
-                "php": ">=5.5.0"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^4.0"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.4-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "GuzzleHttp\\Promise\\": "src/"
-                },
-                "files": [
-                    "src/functions_include.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Michael Dowling",
-                    "email": "mtdowling@gmail.com",
-                    "homepage": "https://github.com/mtdowling"
-                }
-            ],
-            "description": "Guzzle promises library",
-            "keywords": [
-                "promise"
-            ],
-            "time": "2016-12-20T10:07:11+00:00"
-        },
-        {
-            "name": "guzzlehttp/psr7",
-            "version": "1.6.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/guzzle/psr7.git",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
-            },
-            "require": {
-                "php": ">=5.4.0",
-                "psr/http-message": "~1.0",
-                "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
-            },
-            "provide": {
-                "psr/http-message-implementation": "1.0"
-            },
-            "require-dev": {
-                "ext-zlib": "*",
-                "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
-            },
-            "suggest": {
-                "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.6-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "GuzzleHttp\\Psr7\\": "src/"
-                },
-                "files": [
-                    "src/functions_include.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Michael Dowling",
-                    "email": "mtdowling@gmail.com",
-                    "homepage": "https://github.com/mtdowling"
-                },
-                {
-                    "name": "Tobias Schultze",
-                    "homepage": "https://github.com/Tobion"
-                }
-            ],
-            "description": "PSR-7 message implementation that also provides common utility methods",
-            "keywords": [
-                "http",
-                "message",
-                "psr-7",
-                "request",
-                "response",
-                "stream",
-                "uri",
-                "url"
-            ],
-            "time": "2019-07-01T23:21:34+00:00"
-        },
         {
             "name": "league/flysystem",
             "version": "1.0.46",
@@ -529,17 +324,17 @@
             "time": "2017-02-14T16:28:37+00:00"
         },
         {
-            "name": "psr/http-message",
-            "version": "1.0.1",
+            "name": "psr/log",
+            "version": "1.1.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/php-fig/http-message.git",
-                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+                "url": "https://github.com/php-fig/log.git",
+                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
-                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+                "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
+                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -559,7 +354,7 @@
             },
             "autoload": {
                 "psr-4": {
-                    "Psr\\Http\\Message\\": "src/"
+                    "Psr\\Log\\": "Psr/Log/"
                 }
             },
             "notification-url": "https://packagist.org/downloads/",
@@ -572,30 +367,27 @@
                     "homepage": "http://www.php-fig.org/"
                 }
             ],
-            "description": "Common interface for HTTP messages",
-            "homepage": "https://github.com/php-fig/http-message",
+            "description": "Common interface for logging libraries",
+            "homepage": "https://github.com/php-fig/log",
             "keywords": [
-                "http",
-                "http-message",
+                "log",
                 "psr",
-                "psr-7",
-                "request",
-                "response"
+                "psr-3"
             ],
-            "time": "2016-08-06T14:39:51+00:00"
+            "time": "2018-11-20T15:27:04+00:00"
         },
         {
-            "name": "psr/log",
-            "version": "1.1.0",
+            "name": "psr/simple-cache",
+            "version": "1.0.1",
             "source": {
                 "type": "git",
-                "url": "https://github.com/php-fig/log.git",
-                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
+                "url": "https://github.com/php-fig/simple-cache.git",
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
-                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
+                "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -615,7 +407,7 @@
             },
             "autoload": {
                 "psr-4": {
-                    "Psr\\Log\\": "Psr/Log/"
+                    "Psr\\SimpleCache\\": "src/"
                 }
             },
             "notification-url": "https://packagist.org/downloads/",
@@ -628,27 +420,28 @@
                     "homepage": "http://www.php-fig.org/"
                 }
             ],
-            "description": "Common interface for logging libraries",
-            "homepage": "https://github.com/php-fig/log",
+            "description": "Common interfaces for simple caching",
             "keywords": [
-                "log",
+                "cache",
+                "caching",
                 "psr",
-                "psr-3"
+                "psr-16",
+                "simple-cache"
             ],
-            "time": "2018-11-20T15:27:04+00:00"
+            "time": "2017-10-23T01:57:42+00:00"
         },
         {
-            "name": "psr/simple-cache",
-            "version": "1.0.1",
+            "name": "rrbrr/cgf",
+            "version": "dev-master",
             "source": {
                 "type": "git",
-                "url": "https://github.com/php-fig/simple-cache.git",
-                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
+                "url": "https://github.com/caoygx/CGF.git",
+                "reference": "6209b37bb03bf3214415a4218a8c9bd8c28667b7"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
-                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+                "url": "https://api.github.com/repos/caoygx/CGF/zipball/6209b37bb03bf3214415a4218a8c9bd8c28667b7",
+                "reference": "6209b37bb03bf3214415a4218a8c9bd8c28667b7",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -658,97 +451,44 @@
                 ]
             },
             "require": {
-                "php": ">=5.3.0"
+                "php": ">=7.1.0"
             },
             "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.0.x-dev"
-                }
-            },
             "autoload": {
                 "psr-4": {
-                    "Psr\\SimpleCache\\": "src/"
-                }
+                    "Cgf\\": "src/"
+                },
+                "files": []
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
-                "MIT"
+                "Apache-2.0"
             ],
             "authors": [
                 {
-                    "name": "PHP-FIG",
-                    "homepage": "http://www.php-fig.org/"
+                    "name": "rrbrr",
+                    "email": "caoygx@qq.com"
                 }
             ],
-            "description": "Common interfaces for simple caching",
+            "description": "generate form from table",
             "keywords": [
-                "cache",
-                "caching",
-                "psr",
-                "psr-16",
-                "simple-cache"
-            ],
-            "time": "2017-10-23T01:57:42+00:00"
-        },
-        {
-            "name": "ralouphie/getallheaders",
-            "version": "3.0.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/ralouphie/getallheaders.git",
-                "reference": "120b605dfeb996808c31b6477290a714d356e822"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
-                "reference": "120b605dfeb996808c31b6477290a714d356e822",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
-            },
-            "require": {
-                "php": ">=5.6"
-            },
-            "require-dev": {
-                "php-coveralls/php-coveralls": "^2.1",
-                "phpunit/phpunit": "^5 || ^6.5"
-            },
-            "type": "library",
-            "autoload": {
-                "files": [
-                    "src/getallheaders.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Ralph Khattar",
-                    "email": "ralph.khattar@gmail.com"
-                }
+                "form",
+                "table"
             ],
-            "description": "A polyfill for getallheaders.",
-            "time": "2019-03-08T08:55:37+00:00"
+            "time": "2019-07-09T09:22:20+00:00"
         },
         {
-            "name": "rrbrr/cgf",
+            "name": "rrbrr/log",
             "version": "dev-master",
             "source": {
                 "type": "git",
-                "url": "https://github.com/caoygx/CGF.git",
-                "reference": "6209b37bb03bf3214415a4218a8c9bd8c28667b7"
+                "url": "https://github.com/caoygx/ThinkphpLogAndErrorAlarm.git",
+                "reference": "8cee0022978475f61306167efc92e6c2e50118eb"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/caoygx/CGF/zipball/6209b37bb03bf3214415a4218a8c9bd8c28667b7",
-                "reference": "6209b37bb03bf3214415a4218a8c9bd8c28667b7",
+                "url": "https://api.github.com/repos/caoygx/ThinkphpLogAndErrorAlarm/zipball/8cee0022978475f61306167efc92e6c2e50118eb",
+                "reference": "8cee0022978475f61306167efc92e6c2e50118eb",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -758,14 +498,16 @@
                 ]
             },
             "require": {
-                "php": ">=7.1.0"
+                "php": ">=5.6.0"
             },
             "type": "library",
             "autoload": {
                 "psr-4": {
-                    "Cgf\\": "src/"
+                    "Symfony\\Polyfill\\Mbstring\\": ""
                 },
-                "files": []
+                "files": [
+                    "bootstrap.php"
+                ]
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
@@ -782,7 +524,7 @@
                 "form",
                 "table"
             ],
-            "time": "2019-07-09T09:22:20+00:00"
+            "time": "2019-07-24T05:59:08+00:00"
         },
         {
             "name": "topthink/framework",
@@ -1132,6 +874,313 @@
         }
     ],
     "packages-dev": [
+        {
+            "name": "guzzlehttp/guzzle",
+            "version": "6.3.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/guzzle/guzzle.git",
+                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
+                "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "guzzlehttp/promises": "^1.0",
+                "guzzlehttp/psr7": "^1.4",
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "ext-curl": "*",
+                "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
+                "psr/log": "^1.0"
+            },
+            "suggest": {
+                "psr/log": "Required for using the Log middleware"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "6.3-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "src/functions_include.php"
+                ],
+                "psr-4": {
+                    "GuzzleHttp\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Michael Dowling",
+                    "email": "mtdowling@gmail.com",
+                    "homepage": "https://github.com/mtdowling"
+                }
+            ],
+            "description": "Guzzle is a PHP HTTP client library",
+            "homepage": "http://guzzlephp.org/",
+            "keywords": [
+                "client",
+                "curl",
+                "framework",
+                "http",
+                "http client",
+                "rest",
+                "web service"
+            ],
+            "time": "2018-04-22T15:46:56+00:00"
+        },
+        {
+            "name": "guzzlehttp/promises",
+            "version": "v1.3.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/guzzle/promises.git",
+                "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
+                "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.5.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.4-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "GuzzleHttp\\Promise\\": "src/"
+                },
+                "files": [
+                    "src/functions_include.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Michael Dowling",
+                    "email": "mtdowling@gmail.com",
+                    "homepage": "https://github.com/mtdowling"
+                }
+            ],
+            "description": "Guzzle promises library",
+            "keywords": [
+                "promise"
+            ],
+            "time": "2016-12-20T10:07:11+00:00"
+        },
+        {
+            "name": "guzzlehttp/psr7",
+            "version": "1.6.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/guzzle/psr7.git",
+                "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
+                "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.4.0",
+                "psr/http-message": "~1.0",
+                "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
+            },
+            "provide": {
+                "psr/http-message-implementation": "1.0"
+            },
+            "require-dev": {
+                "ext-zlib": "*",
+                "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
+            },
+            "suggest": {
+                "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.6-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "GuzzleHttp\\Psr7\\": "src/"
+                },
+                "files": [
+                    "src/functions_include.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Michael Dowling",
+                    "email": "mtdowling@gmail.com",
+                    "homepage": "https://github.com/mtdowling"
+                },
+                {
+                    "name": "Tobias Schultze",
+                    "homepage": "https://github.com/Tobion"
+                }
+            ],
+            "description": "PSR-7 message implementation that also provides common utility methods",
+            "keywords": [
+                "http",
+                "message",
+                "psr-7",
+                "request",
+                "response",
+                "stream",
+                "uri",
+                "url"
+            ],
+            "time": "2019-07-01T23:21:34+00:00"
+        },
+        {
+            "name": "psr/http-message",
+            "version": "1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/http-message.git",
+                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Http\\Message\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "http://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for HTTP messages",
+            "homepage": "https://github.com/php-fig/http-message",
+            "keywords": [
+                "http",
+                "http-message",
+                "psr",
+                "psr-7",
+                "request",
+                "response"
+            ],
+            "time": "2016-08-06T14:39:51+00:00"
+        },
+        {
+            "name": "ralouphie/getallheaders",
+            "version": "3.0.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/ralouphie/getallheaders.git",
+                "reference": "120b605dfeb996808c31b6477290a714d356e822"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+                "reference": "120b605dfeb996808c31b6477290a714d356e822",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.6"
+            },
+            "require-dev": {
+                "php-coveralls/php-coveralls": "^2.1",
+                "phpunit/phpunit": "^5 || ^6.5"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/getallheaders.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Ralph Khattar",
+                    "email": "ralph.khattar@gmail.com"
+                }
+            ],
+            "description": "A polyfill for getallheaders.",
+            "time": "2019-03-08T08:55:37+00:00"
+        },
         {
             "name": "symfony/polyfill-mbstring",
             "version": "v1.11.0",
@@ -1345,7 +1394,8 @@
     "minimum-stability": "stable",
     "stability-flags": {
         "topthink/framework": 20,
-        "rrbrr/cgf": 20
+        "rrbrr/cgf": 20,
+        "rrbrr/log": 20
     },
     "prefer-stable": false,
     "prefer-lowest": false,

+ 2 - 0
config/app.php

@@ -45,4 +45,6 @@ return [
     // 显示错误信息
     'show_error_msg'   => false,
    // 'default_return_type'=>'json'
+
+    'app_debug' =>  true,
 ];

+ 4 - 2
public/pay.html

@@ -221,7 +221,7 @@
 
             // var CREATE_URL = 'https://10.93.49.141:8443/portal-service-demo/biz_pgw/demo/checkout/api/payment/create';
             var CREATE_URL =
-                'http://www.tp6.com/index/payment';
+                '/index/payment';
             return MMPay.payment.create(CREATE_URL, data)
                 .then(function (res) {
                     return res.paymentID;
@@ -231,7 +231,7 @@
         onAuthorize: function (data) {
 
             var EXECUTE_URL =
-                'http://www.tp6.com/index/execute';
+                '/index/execute';
 
             var data = {
                 env: this.env,
@@ -243,6 +243,8 @@
             // Make a call to your server to execute the payment
             return MMPay.payment.execute(EXECUTE_URL, data)
                 .then(function (res) {
+                    console.log(res);
+                    alert('支付成功');
                     window.location.href =
                         "/portal-service-demo/success.jsp?paymentID=" +
                         res.paymentID;