rabin 7 months ago
commit
0ead3325d6
72 changed files with 4037 additions and 0 deletions
  1. 17 0
      api/Cate.php
  2. 43 0
      api/Manage.php
  3. 219 0
      api/Notify.php
  4. 11 0
      api/Test.php
  5. 5 0
      index.php
  6. 33 0
      lib/Api.php
  7. 117 0
      lib/App.php
  8. 10 0
      lib/Cert.php
  9. 195 0
      lib/Platform.php
  10. 155 0
      lib/Platform/Field.php
  11. 58 0
      lib/Platform/Request.php
  12. 358 0
      lib/Platform/Response.php
  13. 145 0
      lib/Platform/Sign.php
  14. 127 0
      lib/Platform/Ssl.php
  15. 37 0
      lib/Spec.php
  16. 242 0
      manage/api.php
  17. 13 0
      manage/api_notify_code.php
  18. 2 0
      manage/api_request_body.php
  19. 2 0
      manage/api_request_header.php
  20. 35 0
      manage/api_request_input.php
  21. 26 0
      manage/api_request_output.php
  22. 21 0
      manage/api_response.php
  23. 2 0
      manage/api_response_body.php
  24. 2 0
      manage/api_response_header.php
  25. 22 0
      manage/api_save.php
  26. 14 0
      manage/api_uri.php
  27. 64 0
      manage/app.php
  28. 74 0
      manage/app_func.php
  29. 35 0
      manage/app_func_work.php
  30. 3 0
      manage/cate.php
  31. 82 0
      manage/core.php
  32. 175 0
      manage/platform.php
  33. 75 0
      manage/platform_cert.php
  34. 12 0
      manage/platform_convert.php
  35. 21 0
      manage/platform_request_body.php
  36. 2 0
      manage/platform_request_header.php
  37. 2 0
      manage/platform_response_body.php
  38. 12 0
      manage/platform_response_code.php
  39. 2 0
      manage/platform_response_header.php
  40. 25 0
      manage/platform_setting.php
  41. 143 0
      manage/platform_ssl.php
  42. 30 0
      manage/sku.php
  43. 146 0
      table/api.php
  44. 32 0
      table/api_log.php
  45. 38 0
      table/api_notify_code.php
  46. 13 0
      table/api_request_body.php
  47. 13 0
      table/api_request_header.php
  48. 70 0
      table/api_request_input.php
  49. 39 0
      table/api_request_output.php
  50. 14 0
      table/api_response.php
  51. 14 0
      table/api_response_body.php
  52. 14 0
      table/api_response_header.php
  53. 45 0
      table/api_save.php
  54. 48 0
      table/api_uri.php
  55. 44 0
      table/app.php
  56. 83 0
      table/app_func.php
  57. 45 0
      table/app_func_work.php
  58. 19 0
      table/app_platform.php
  59. 4 0
      table/cate.php
  60. 224 0
      table/platform.php
  61. 50 0
      table/platform_cert.php
  62. 25 0
      table/platform_convert.php
  63. 55 0
      table/platform_request_body.php
  64. 4 0
      table/platform_request_header.php
  65. 5 0
      table/platform_response_body.php
  66. 31 0
      table/platform_response_code.php
  67. 5 0
      table/platform_response_header.php
  68. 32 0
      table/platform_setting.php
  69. 134 0
      table/platform_ssl.php
  70. 44 0
      table/sku.php
  71. 32 0
      table/spec.php
  72. 47 0
      table/spec_value.php

+ 17 - 0
api/Cate.php

@@ -0,0 +1,17 @@
+<?php namespace Api\Api;
+use Dever;
+class Cate
+{
+    public function getApi($value = false)
+    {
+        if ($value) {
+            if (is_array($value)) {
+                $value = implode(',', $value);
+            }
+            $where['cate'] = $value;
+            $result['api_id']['value'] = '';
+            $result['api_id']['option'] = Dever::db('api', 'api')->select($where);
+            return $result;
+        }
+    }
+}

+ 43 - 0
api/Manage.php

@@ -0,0 +1,43 @@
+<?php namespace Api\Api;
+use Dever;
+use Manage\Lib\Auth;
+class Manage extends Auth
+{
+    # 将sku中的key解析成前端可以读取的格式
+    public function keyToField($key)
+    {
+        if ($key != -1) {
+            $result = array();
+            $array = explode(',', $key);
+            $result['key']['set'] = array();
+            foreach ($array as $k => $v) {
+                $value = Dever::db('spec_value', 'api')->find($v);
+                if ($value) {
+                    $spec = Dever::db('spec', 'api')->find($value['spec_id']);
+                    $result['key']['set']['s_' . $spec['id']] = array($spec['name'], $value['value']);
+                }
+            }
+            return $result;
+        }
+    }
+
+    # 获取参数设置表的参数名
+    public function getSettingName($value = false)
+    {
+        if ($value) {
+            $info = Dever::db('platform_setting', 'api')->find($value);
+            $result['key']['value'] = $info['key'];
+            return $result;
+        }
+    }
+
+    # 获取参数设置表的参数名
+    public function getCertName($value = false)
+    {
+        if ($value) {
+            $info = Dever::db('platform_cert', 'api')->find($value);
+            $result['type']['value'] = $info['type'];
+            return $result;
+        }
+    }
+}

+ 219 - 0
api/Notify.php

@@ -0,0 +1,219 @@
+<?php namespace Api\Api;
+use Dever;
+use Api\Lib\Api;
+class Notify extends Api
+{
+    public function common()
+    {
+        $file = file_get_contents("php://input");
+        if ($file) {
+            $file = json_decode($file, true);
+            if ($file) {
+                $input = array_merge($file, $input);
+            }
+        } else {
+            $input = Dever::input();
+        }
+        Dever::log($input, 'notify');
+        echo 11;die;
+        //$param = '{"s":"132dcszvteLAx3r5eKrjarbGyJilBFECGu2F7mCX-H6K2_w","appid":"app483393213726","order_id":"Q202401040798155761553480","merchant_order_id":"yk18f2401040253000002","status":2,"cash":1000,"msg":"充值成功","actual_cash":1004.9999999999999,"time":1704308034101,"nonce":"fa0912fcfeb3ddfec4e821c26","signature":"d58295706e069e61a4a4ef9428ae0d155b36fae6"}';
+        //$input = Dever::json_decode($param);
+        $input = Dever::input();
+        if (!isset($input['s'])) {
+            $this->error('error');
+        }
+        $s = \Dever\Helper\Str::decode($input['s']);
+        if ($s) {
+            list($connect_id, $api_id, $order_id) = explode('|', $s);
+        } elseif (isset($input['order_num'])) {
+            $order_id = Dever::db('order', 'seller')->find(array('order_num' => $input['order_num']));
+            if (!$order_id) {
+                $this->error('error');
+            }
+            $channel = Dever::db('info', 'channel')->find($order_id['channel_id']);
+            if (!$channel) {
+                $this->error('order error');
+            }
+            $connect_id = $channel['connect_id'];
+            $api = Dever::db('api', 'api')->find(array('connect_id' => $connect_id, 'type' => 1));
+            if (!$api) {
+                $this->error('order error');
+            }
+            $api_id = $api['id'];
+
+        } else {
+            $this->error('error');
+        }
+        $this->connect = Dever::db('info', 'api')->find($connect_id);
+        $this->info = Dever::db('api', 'api')->find($api_id);
+        
+        unset($input['s']);
+        unset($input['l']);
+        if (!$input) {
+            $input = file_get_contents("php://input");
+            if ($input) {
+                $input = json_decode($input, true);
+                if (is_array($input)) {
+                    if (isset($input['s'])) {
+                        unset($input['s']);
+                    }
+                    if (isset($input['l'])) {
+                        unset($input['l']);
+                    }
+                } else {
+                    $this->error('error');
+                }
+            }
+        }
+        if (!$input) {
+            $this->error('error');
+        }
+        $this->load($input, $connect_id, $api_id, $order_id);
+    }
+
+    private function load($input, $connect_id, $api_id, $order_id)
+    {
+        //Dever::log($input, 'notify');
+        if (is_array($order_id)) {
+            $order = $order_id;
+        } else {
+            $order = Dever::db('order', 'seller')->find($order_id);
+        }
+        if (!$order || $order['status'] >= 10) {
+            $this->error('order error');
+        }
+        $channel = Dever::db('info', 'channel')->find($order['channel_id']);
+        if (!$channel) {
+            $this->error('channel error');
+        }
+        $this->connect['appsecret'] = $channel['appsecret'];
+
+        $code = Dever::db('api_notify_code', 'api')->select(array('api_id' => $api_id));
+
+        $status = 0;
+        if ($code) {
+            foreach ($code as $k => $v) {
+                if (isset($input[$v['key']]) && $input[$v['key']] == $v['value']) {
+                    $status = $v['type'];
+                }
+            }
+        }
+        $data = $input;
+        $data['status'] = $status;
+        $data = $this->service($data);
+
+        $msg = '';
+        if ($status == 1) {
+            $msg = 'ok';
+        } elseif ($status == 2) {
+            $msg = 'error';
+        }
+        if ($this->info['notify_sign_col']) {
+            $this->info['sign_col'] = $this->info['notify_sign_col'];
+        }
+        if ($sign = Dever::issets($input, $this->connect['sign_name'])) {
+            unset($input[$this->connect['sign_name']]);
+            unset($input['l']);
+            /*
+            $string = '';
+            if ($sign != $this->sign($input, $string)) {
+                $this->error('sign error');
+            }*/
+        }
+        if ($msg) {
+            $update = array();
+            $update['official_msg'] = $data['official_msg'] ?? '';
+            $update['official_order_num'] = $data['official_order_num'] ?? '';
+            $update['channel_callback'] = json_encode($input, JSON_UNESCAPED_UNICODE);
+            $update['channel_callback_date'] = time();
+
+            if ($msg != 'ok') {
+                $channel_num = Dever::db('channel', 'seller')->count(array('seller_id' => $order['seller_id'], 'goods_id' => $order['goods_id'], 'status' => 1));
+                if ($channel_num > 1) {
+                    # 记录渠道错误信息
+                    $selected = array();
+                    $selected[$order['channel_id']] = true;
+                    $order_error_data = Dever::db('order_error', 'seller')->select(array('order_num' => $order['order_num']));
+                    if ($order_error_data) {
+                        foreach ($order_error_data as $k => $v) {
+                            $selected[$v['channel_id']] = true;
+                        }
+                    }
+                    $num = count($selected);
+                    $channel_num = $channel_num - $num;
+                    if ($channel_num > 0) {
+                        $order_error = array();
+                        $order_error['order_num'] = $order['order_num'];
+                        $order_error['buy_price'] = $order['buy_price'];
+                        $order_error['channel_id'] = $order['channel_id'];
+                        $order_error['channel_goods_id'] = $order['channel_goods_id'];
+                        $order_error['channel_goods_discount'] = $order['channel_goods_discount'];
+                        $order_error['channel_order_date'] = $order['channel_order_date'];
+                        $order_error['channel_order_num'] = $order['channel_order_num'];
+                        $order_error['channel_request'] = $order['channel_request'];
+                        $order_error['channel_response'] = $order['channel_response'];
+                        $order_error['channel_callback'] = $update['channel_callback'];
+                        $order_error['channel_callback_date'] = $update['channel_callback_date'];
+                        Dever::db('order_error', 'seller')->insert($order_error);
+                        Dever::load('order', 'seller')->handleAct($order, $selected);
+                    } else {
+                        Dever::load('order', 'seller')->notify($order, $msg, $update);
+                    }
+                } else {
+                    Dever::load('order', 'seller')->notify($order, $msg, $update);
+                }
+            } else {
+                Dever::load('order', 'seller')->notify($order, $msg, $update);
+            }
+            echo $this->info['notify_success'];die;
+        }
+        $this->error('error');
+    }
+
+    private function error($msg)
+    {
+        if ($this->info && $this->info['notify_error']) {
+            if ($this->info['notify_error'] == 500) {
+                header("HTTP/1.1 500 Internal Server Error");
+                header("Status: 500 Internal Server Error");
+            } else {
+                echo $this->info['notify_error'];die;
+            }
+        }
+        echo $msg;die;
+    }
+
+    # 生成回调
+    public function callback()
+    {
+        //$param = '{"l":"notify.callback","t":"4-5-user_order","userid":"41438","order_id":"24020213181441438abbf5b39f","account":"15810090811","amount":"100","price":"104.1","state":"failed","user_order":"C2024020251094338265393","sign":"0447CC15F7D0218A1C5C09160A12A19A","voucher":""}';
+        //$input = Dever::json_decode($param);
+        $input = Dever::input();
+        if (!isset($input['t'])) {
+            $this->error('error');
+        }
+        $file = file_get_contents("php://input");
+        if ($file) {
+            $file = json_decode($file, true);
+            if ($file) {
+                $input = array_merge($file, $input);
+            }
+        }
+        $temp = explode('-', $input['t']);
+        $connect_id = $temp[0];
+        $api_id = $temp[1];
+        $order_key = $temp[2];
+        $this->connect = Dever::db('info', 'api')->find($connect_id);
+        $this->info = Dever::db('api', 'api')->find($api_id);
+        if (!isset($input[$order_key])) {
+            $this->error('error');
+        }
+        $order_id = $input[$order_key];
+        unset($input['t']);
+        $order = Dever::db('order', 'seller')->find(array('order_num' => $order_id));
+        if (!$order || $order['status'] >= 10) {
+            $this->error('order error');
+        }
+        $this->load($input, $connect_id, $api_id, $order);
+    }
+}

+ 11 - 0
api/Test.php

@@ -0,0 +1,11 @@
+<?php namespace Api\Api;
+use Dever;
+use Api\Lib\Api;
+class Test extends Api
+{
+    public function api()
+    {
+        $id = Dever::input('id');
+        return Dever::load('api', 'api')->run($id);
+    }
+}

+ 5 - 0
index.php

@@ -0,0 +1,5 @@
+<?php
+define('DEVER_APP_NAME', 'api');
+define('DEVER_APP_LANG', '接口管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(DEVER_APP_PATH . '../../../boot.php');

+ 33 - 0
lib/Api.php

@@ -0,0 +1,33 @@
+<?php namespace Api\Lib;
+use Dever;
+class Api extends Platform
+{
+    protected $type = 'api';
+
+    # 执行某个接口
+    public function run($id, $param = array())
+    {
+        $state = $this->setting($id, $param);
+        if (!$state) {
+            return $state;
+        }
+        return $this->curl();
+    }
+
+    # 跳转
+    public function jump($id, $param = array())
+    {
+        $state = $this->setting($id, $param);
+        if (!$state) {
+            return $state;
+        }
+        return $this->location();
+    }
+
+    # 生成回调
+    protected function createNotify($order_num)
+    {
+        $encode = \Dever\Helper\Str::encode($this->info['id'] . '|' . $order_num);
+        return Dever::url('api/notify.common', array('s' => $encode), false, 'src/channel/api/');
+    }
+}

+ 117 - 0
lib/App.php

@@ -0,0 +1,117 @@
+<?php namespace Api\Lib;
+use Dever;
+class App
+{
+    public function update($db, $data)
+    {
+        $func = Dever::db('app_func_work', 'api')->select(array('app_func_id' => $data['id']));
+        if ($func) {
+            $platform = array();
+            Dever::db('app_platform', 'api')->delete(array('app_id' => $data['app_id']));
+            foreach ($func as $k => $v) {
+                $api = Dever::db('api', 'api')->find($v['api_id']);
+                if ($api) {
+                    $platform[$api['platform_id']] = $api['platform_id'];
+                }
+            }
+            foreach ($platform as $k => $v) {
+                Dever::db('app_platform', 'api')->insert(array('app_id' => $data['app_id'], 'platform_id' => $v));
+            }
+        }
+    }
+
+    public function getPlatform($key)
+    {
+        $info = Dever::db('app', 'api')->find(array('key' => $key));
+
+        if ($info) {
+            $set['join'] = array
+            (
+                array
+                (
+                    'table' => 'platform',
+                    'type' => 'left join',
+                    'on' => 'platform.id=app_platform.platform_id',
+                ),
+            );
+            $set['col'] = 'platform.id as id,platform.name as name';
+            $platform = Dever::db('app_platform', 'api')->select(array('app_id' => $info['id']), $set);
+            return $platform;
+        }
+        return array();
+    }
+
+    public function getSetting($platform_id)
+    {
+        return Dever::db('platform_setting', 'api')->select(array('platform_id' => $platform_id));
+    }
+
+    public function getCert($platform_id)
+    {
+        return Dever::db('platform_cert', 'api')->select(array('platform_id' => $platform_id));
+    }
+
+    public function getCertName($id)
+    {
+        $info = Dever::db('platform_cert', 'api')->find($id);
+        return $info['name'];
+    }
+
+    public function getApi($app_key, $key, $platform_id, $env = 1)
+    {
+        $info = Dever::db('app', 'api')->find(array('key' => $app_key));
+        if ($info) {
+            $func = Dever::db('app_func', 'api')->find(array('app_id' => $info['id'], 'key' => $key));
+            if ($func) {
+                $set['join'] = array
+                (
+                    array
+                    (
+                        'table' => 'api',
+                        'type' => 'left join',
+                        'on' => 'api.id=app_func_work.api_id',
+                    ),
+                );
+                $set['col'] = 'api.*';
+                $set['order'] = 'app_func_work.sort asc,api.id desc';
+                $where['app_func_work.app_func_id'] = $func['id'];
+                $where['api.env_type'] = $env;
+                $api = Dever::db('app_func_work', 'api')->select($where, $set);
+                return $api;
+            }
+        }
+        return false;
+    }
+
+    # 直接执行api
+    public function run($app, $func, $platform_id, $set, $param, $env = 1, $method = 'run')
+    {
+        $api = $this->getApi($app, $func, $platform_id, $env);
+        if ($api) {
+            if ($set) {
+                $setting = Dever::db($set['table'] .'_setting')->select($set['where']);
+                if ($setting) {
+                    foreach ($setting as $k => $v) {
+                        if (isset($param[$v['key']])) {
+                            $v['value'] = $param[$v['key']];
+                        }
+                        $param[$v['key']] = $v['value'];
+                    }
+                }
+                if (isset($set['cert']) && $set['cert']) {
+                    $param['cert_table'] = $set['table'] .'_cert';
+                    $param['cert_data'] = $set['where'];
+                    $cert = Dever::db($param['cert_table'])->select($param['cert_data'], array('order' => 'edate desc'));
+                    if ($cert) {
+                        $param['cert'] = array();
+                        foreach ($cert as $k => $v) {
+                            $param['cert'][$v['platform_cert_id']] = $v;
+                        }
+                    }
+                }
+            }
+            $data = Dever::load('api', 'api')->$method($api[0], $param);
+            return $data;
+        }
+    }
+}

+ 10 - 0
lib/Cert.php

@@ -0,0 +1,10 @@
+<?php namespace Api\Lib;
+use Dever;
+class Cert
+{
+    # 获取证书列表
+    public function list($platform_id)
+    {
+        return Dever::db("api/platform_cert")->select(["platform_id" => $platform_id]);
+    }
+}

+ 195 - 0
lib/Platform.php

@@ -0,0 +1,195 @@
+<?php namespace Api\Lib;
+use Dever;
+use Api\Lib\Platform\Field;
+use Api\Lib\Platform\Sign;
+use Api\Lib\Platform\Ssl;
+use Api\Lib\Platform\Request;
+use Api\Lib\Platform\Response;
+class Platform
+{
+    protected $platform;
+    protected $info;
+    protected $field;
+
+    protected function setting($id, $field = array())
+    {
+        $this->info($id);
+        $this->platform();
+        $this->field($field);
+        return $this;
+    }
+
+    protected function info($id)
+    {
+        $this->info = is_array($id) ? $id : Dever::db($this->type, 'api')->find($id);
+        if (!$this->info) {
+            Dever::error('info error');
+        }
+    }
+
+    protected function platform()
+    {
+        $this->platform = Dever::db('platform', 'api')->find($this->info['platform_id']);
+        if (!$this->platform) {
+            Dever::error('platform error');
+        }
+        $this->sign = $this->response = array('id' => $this->platform['id']);
+        foreach ($this->platform as $k => $v) {
+            if (strstr($k, 'sign_')) {
+                $k = str_replace('sign_', '', $k);
+                $this->sign[$k] = $v;
+            }
+            if (strstr($k, 'response_')) {
+                $k = str_replace('response_', '', $k);
+                $this->response[$k] = $v;
+            }
+        }
+        if ($this->info['method'] == -1) {
+            $this->info['method'] = $this->platform['method'];
+            $this->info['post_method'] = $this->platform['post_method'];
+        }
+        if ($this->info['method'] == 1) {
+            $this->info['post_method'] = 1;
+        }
+    }
+
+    protected function field($field)
+    {
+        $this->field = new Field($field);
+        $this->field->setHost($this->platform['host']);
+        $this->field->setUri($this->info['uri']);
+        $this->field->setNotify($this->createNotify($field['order_num'] ?? ''));
+        $setting = Dever::db('platform_setting', 'api')->select(array('platform_id' => $this->platform['id']));
+        if ($setting) {
+            foreach ($setting as $k => $v) {
+                if (isset($field[$v['key']])) {
+                    $v['value'] = $field[$v['key']];
+                }
+                $key = $v['key'];
+                # 如果有自定义的设置
+                if (!$this->field->$key) {
+                    $this->field->set($key, $v['value']);
+                }
+            }
+        }
+    }
+
+    # 发起请求
+    protected function curl($url = false)
+    {
+        if (!$url) {
+            $url = $this->url();
+        }
+        $method = $this->method();
+        $request = new Request($this->field, $this->platform['id'], $this->type, $this->info['id']);
+        $request_body = $request->body();
+        if ($this->info['sign_col']) {
+            $this->platform['sign_col'] = $this->info['sign_col'];
+        }
+        $sign = new Sign($this->field, $this->sign);
+        $sign = $sign->get();
+
+        if ($this->platform['sign_name']) {
+            $request_body[$this->platform['sign_name']] = $sign;
+        }
+        $request_header = $request->header();
+
+        $json = $this->info['post_method'] == 3 ? true : false;
+        $curl = Dever::curl($url, $request_body, $method, $json, $request_header);
+        $curl->setResultHeader(true);
+        $response_body = $curl->result();
+        $response_header = $curl->header();
+        $response = new Response($response_body, $response_header, $this->response, $this->field, $this->type, $this->info['id'], $this->sign);
+        $result = $response->out();
+        $log['platform_id'] = $this->platform['id'];
+        $log['type'] = $this->type;
+        $log['type_id'] = $this->info['id'];
+        $log['url'] = $url;
+        $log['method'] = $method;
+        $log['json'] = $json;
+        $log['request_body'] = Dever::json_encode($request_body);
+        $log['request_header'] = Dever::json_encode($request_header);
+        $log['response_body'] = $response_body;
+        $log['response_header'] = Dever::json_encode($response_header);
+        Dever::debug($log);
+        return $result;
+    }
+
+    # 直接跳转
+    protected function location($url = false)
+    {
+        if (!$url) {
+            $url = $this->url();
+        }
+        $method = $this->method();
+        $request = new Request($this->field, $this->platform['id'], $this->type, $this->info['id']);
+        $request_body = $request->body();
+        if ($this->info['sign_col']) {
+            $this->platform['sign_col'] = $this->info['sign_col'];
+        }
+        $sign = new Sign($this->field, $this->sign);
+        $sign = $sign->get();
+
+        if ($this->platform['sign_name']) {
+            $request_body[$this->platform['sign_name']] = $sign;
+        }
+        $url .= '?';
+        foreach ($request_body as $k => $v) {
+            if ($k == '#') {
+                $url .= $k . $v;
+            } else {
+                $url .= $k . '=' . $v . '&';
+            }
+        }
+        header('Location: '. $url);
+    }
+
+    protected function method()
+    {
+        $method = 'get';
+        if ($this->info['post_method'] == 2) {
+            $method = 'file';
+        } elseif ($this->info['method'] == 2) {
+            $method = 'post';
+        }
+        $this->field->setMethod($method);
+        return $method;
+    }
+
+    protected function url()
+    {
+        if (strstr($this->info['uri'], 'http')) {
+            $this->platform['host'] = '';
+        }
+        $uri = Dever::db('api_uri', 'api')->select(array('api_id' => $this->info['id']));
+        if ($uri) {
+            $path = array();
+            $param = array();
+            foreach ($uri as $k => $v) {
+                $v['value'] = $this->field->value($v['value']);
+                if ($v['type'] == 1) {
+                    $path[] = $v['value'];
+                } elseif ($v['type'] == 2) {
+                    $path[] = $v['key'] . '/' . $v['value'];
+                } elseif ($v['type'] == 3) {
+                    $path[] = $v['key'] . '=' . $v['value'];
+                } elseif ($v['type'] == 4) {
+                    $param[] = $v['value'];
+                } elseif ($v['type'] == 5) {
+                    $param[] = $v['key'] . '=' . $v['value'];
+                }
+            }
+            if ($path) {
+                $this->info['uri'] .= implode('/', $path);
+            }
+            if ($param) {
+                if (!strstr($this->info['uri'], '?')) {
+                    $this->info['uri'] .= '?';
+                }
+                $this->info['uri'] .= implode('&', $param);
+            }
+        }
+        $this->field->setUri($this->info['uri']);
+        return $this->platform['host'] . $this->info['uri'];
+    }
+}

+ 155 - 0
lib/Platform/Field.php

@@ -0,0 +1,155 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Field
+{
+    private $data = array();
+    public $ssl;
+    public function __construct($data)
+    {
+        $this->data = $data;
+        $this->ssl = new Ssl($this);
+        $this->set('time', time());
+        $this->set('timestamp', \Dever\Helper\Secure::timestamp());
+        $this->set('nonce', \Dever\Helper\Secure::nonce());
+    }
+
+    public function set($key, $value)
+    {
+        $this->data[$key] = $value;
+    }
+
+    public function __set($key, $value)
+    {
+        $this->data[$key] = $value;
+    }
+
+    public function __get($key)
+    {
+        if (array_key_exists($key, $this->data)) {
+            return $this->data[$key];
+        } else {
+            return null;
+        }
+    }
+
+    public function setHost($value)
+    {
+        $this->set('body', $value);
+    }
+
+    public function setUri($value)
+    {
+        $this->set('uri', $value);
+    }
+
+    public function setNotify($value)
+    {
+        $this->set('notify', $value);
+    }
+
+    public function setSign($value)
+    {
+        $this->set('sign', $value);
+    }
+
+    public function setMethod($value)
+    {
+        $this->set('method', $value);
+    }
+
+    public function setBody($value)
+    {
+        $this->set('body', $value);
+    }
+
+    public function setBodyJson($value)
+    {
+        $this->set('body_json', $value);
+    }
+
+    public function setHeader($value)
+    {
+        $this->set('header', $value);
+    }
+
+    public function setNumber($value)
+    {
+        $this->set('number', $value);
+    }
+
+    public function value($value, $type = -1, $state = true)
+    {
+        $value = trim($value);
+        if ($this->data && isset($this->data[$value])) {
+            $value = $this->data[$value];
+        } elseif (strstr($value, 'key=') && strstr($value, '&')) {
+            $value = $this->parse($value);
+        } elseif ($a = strstr($value, '{') || strstr($value, '(')) {
+            $value = $this->eval($value);
+        }
+        return $this->handle($type, $value, $state);
+    }
+
+    protected function parse($value)
+    {
+        parse_str($value, $temp);
+        $k = $temp['key'];
+        unset($temp['key']);
+        if (isset($this->data[$k]) && isset($temp[$this->data[$k]])) {
+            $value = $temp[$this->data[$k]];
+        }
+        return $value;
+    }
+
+    protected function eval($value)
+    {
+        $func = function ($r) {
+            return $this->value($r[1]);
+        };
+        $value = preg_replace_callback('/{(.*?)}/', $func, $value);
+        $value = '$value = '.$value.';';
+        eval($value);
+        return $value;
+    }
+
+    protected function handle($type, $value, $state)
+    {
+        # state == true 是编码 == false 是解码
+        if ($type == -1) {
+            $value = (string) $value;
+        } elseif ($type == -2) {
+            $value = (float) $value;
+        } elseif ($type == -3) {
+            if ($state) {
+                $value = Dever::json_encode($value);
+            } else {
+                $value = Dever::json_decode($value);
+            }
+        } elseif ($type == -4) {
+            if ($state) {
+                $value = strtotime($value);
+            } else {
+                $value = date('Y-m-d H:i:s', $value);
+            }
+        } elseif ($type == -5) {
+            if ($state) {
+                $value = date('Y-m-d H:i:s', $value);
+            } else {
+                $value = strtotime($value);
+            }
+        } elseif ($type == -6) {
+            if ($state) {
+                $value = date('Y-m-d\TH:i:sP', $value);
+            } else {
+                $value = strtotime($value);
+            }
+        } else {
+            if ($state) {
+                $value = $this->ssl->encrypt($type, $value);
+            } else {
+                $value = $this->ssl->decrypt($type, $value);
+            }
+        }
+        return $value;
+    }
+}

+ 58 - 0
lib/Platform/Request.php

@@ -0,0 +1,58 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Request
+{
+    public function __construct($field, $platform_id, $type, $type_id)
+    {
+        $this->field = $field;
+        $this->platform_id = $platform_id;
+        $this->type = $type;
+        $this->type_id = $type_id;
+    }
+
+    public function body()
+    {
+        $body = array();
+        $this->load($body, 'body');
+        $this->field->setBody($body);
+        $this->field->setBodyJson($body ? Dever::json_encode($body) : '');
+        return $body;
+    }
+
+    public function header()
+    {
+        $header = array();
+        $this->load($header, 'header');
+        $this->field->setHeader($header);
+        return $header;
+    }
+
+    protected function load(&$data, $table)
+    {
+        $this->get($data, 'platform_request_' . $table, array('platform_id' => $this->platform_id));
+        $this->get($data, $this->type . '_request_' . $table, array($this->type . '_id' => $this->type_id));
+    }
+
+    protected function get(&$data, $table, $where)
+    {
+        $request = Dever::db($table, 'api')->select($where);
+        if ($request) {
+            foreach ($request as $k => $v) {
+                $value = $this->field->value($v['value'], $v['type']);
+                if ($value) {
+                    if (strstr($v['key'], '.')) {
+                        $keys = explode('.', $v['key']);
+                        $temp = &$data;
+                        foreach ($keys as $key) {
+                            $temp = &$temp[$key];
+                        }
+                        $temp = $value;
+                    } else {
+                        $data[$v['key']] = $value;
+                    }
+                    $this->field->set($v['key'], $value);
+                }
+            }
+        }
+    }
+}

+ 358 - 0
lib/Platform/Response.php

@@ -0,0 +1,358 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Response
+{
+    public function __construct($body, $header, $config, $field, $type, $type_id, $sign)
+    {
+        $this->body = $body;
+        $this->header = $header;
+        $this->config = $config;
+        $this->field = $field;
+        $this->type = $type;
+        $this->type_id = $type_id;
+        $this->sign = $sign;
+    }
+
+    public function out()
+    {
+        $this->header();
+        return $this->body();
+    }
+
+    public function header()
+    {
+        $header = Dever::db($this->type . '_response_header', 'api')->select(array($this->type . '_id' => $this->type_id));
+        if (!$header) {
+            $header = Dever::db('platform_response_header', 'api')->select(array('platform_id' => $this->config['id']));
+        }
+        if ($header) {
+            foreach ($header as $k => $v) {
+                if (isset($this->header[$v['value']])) {
+                    $value = $this->field->value($this->header[$v['value']], $v['type'], false);
+                    $this->field->set($v['key'], $value);
+                }
+            }
+        }
+    }
+
+    public function body()
+    {
+        if ($this->config['type'] == 1) {
+            $this->body = $this->filter($this->body);
+            return $this->body;
+        }
+        $this->field->setBodyJson($this->body);
+        $this->parse();
+        $status = $this->status();
+        $msg = $this->msg();
+        if ($status == 2) {
+            Dever::error($msg);
+        }
+        $body = $this->data();
+        $this->field->setBody($body);
+        $this->verify();
+        $data = $this->handle($body);
+        return $data;
+    }
+
+    protected function verify()
+    {
+        $this->sign['verify_set'] = explode(',', $this->sign['verify_set']);
+        if (!in_array(2, $this->sign['verify_set'])) {
+            return;
+        }
+        if (!$this->field->sign) {
+            Dever::error('签名验证失败');
+        }
+        if ($this->sign['verify_col']) {
+            $this->sign['col'] = $this->sign['verify_col'];
+        }
+        $sign = new Sign($this->field, $this->sign);
+        $sign->check($this->field->sign);
+    }
+
+    protected function parse()
+    {
+        if ($this->config['type'] == 2) {
+            $this->body = Dever::json_decode($this->body);
+        } elseif ($this->config['type'] == 3) {
+            $this->body = (array) simplexml_load_string($this->body);
+        } else {
+            if (strstr($this->body, ',')) {
+                $this->body = explode(',', $this->body);
+            } elseif (strstr($this->body, ' ')) {
+                $this->body = explode(' ', $this->body);
+            } elseif (strstr($this->body, '|')) {
+                $this->body = explode('|', $this->body);
+            } else {
+                $this->body = explode("\n", $this->body);
+            }
+        }
+    }
+
+    protected function status()
+    {
+        $status = 2;
+        if (!$this->config['code']) {
+            $status = 1;
+        }
+        if ($this->config['code'] && isset($this->body[$this->config['code']])) {
+            $code = $this->body[$this->config['code']];
+            $code = Dever::db('response_code', 'api')->find(array('platform_id' => $this->config['id'], 'value' => $code));
+            if ($code && $code['type'] == 1) {
+                $status = 1;
+            }
+        }
+        return $status;
+    }
+
+    protected function msg()
+    {
+        $msg = 'ok';
+        if ($this->config['msg'] && isset($this->body[$this->config['msg']])) {
+            $msg = $this->config['msg'];
+        }
+        return $msg;
+    }
+
+    protected function data()
+    {
+        $data = $this->body;
+        if ($this->config['data']) {
+            if (strstr($this->config['data'], ',')) {
+                $temp = explode(',', $this->config['data']);
+                foreach ($temp as $k => $v) {
+                    if (isset($this->body[$v])) {
+                        $data = $this->body[$v];
+                        break;
+                    }
+                }
+            } elseif (strstr($this->config['data'], '.')) {
+                $temp = explode('.', $this->config['data']);
+                $data = isset($this->body[$temp[0]][$temp[1]]) ? $this->body[$temp[0]][$temp[1]] : (isset($this->body[$temp[0]]) ? $this->body[$temp[0]] : false);
+            } else {
+                $data = $this->body[$this->config['data']] ?? $this->body;
+            }
+        }
+        return $data;
+    }
+
+    protected function handle($data)
+    {
+        $result = array();
+        $body = Dever::db($this->type . '_response_body', 'api')->select(array($this->type . '_id' => $this->type_id));
+        if (!$body) {
+            $body = Dever::db('platform_response_body', 'api')->select(array('platform_id' => $this->config['id']));
+        }
+        if ($body) {
+            foreach ($data as $k => $v) {
+                $this->field->set($k, $v);
+            }
+            $source = array();
+            $dest = array();
+            foreach ($body as $k => $v) {
+                $temp = $this->convert($data, $v['value'], $v['key'], $v['type']);
+                if ($temp) {
+                    $result = array_replace_recursive($result, $temp);
+                }
+            }
+        }
+        if ($result) {
+            $result = $this->value($result);
+        } else {
+            $result = $data;
+        }
+        $this->save($result);
+        return $result;
+    }
+
+    protected function convert($array, $source, $dest, $type = -1)
+    {
+        $source = explode('.', $source);
+        $dest = explode('.', $dest);
+        $extracted = $this->extracted($array, $source, $type);
+        return $this->transform($extracted, $dest);
+    }
+
+    protected function extracted(&$array, $source, $type = '')
+    {
+        $current = array_shift($source);
+        if (substr($current, -2) == '[]') {
+            $current = substr($current, 0, -2);
+            $result = [];
+            if (isset($array[$current]) && is_array($array[$current])) {
+                foreach ($array[$current] as $item) {
+                    $sub = $this->extracted($item, $source, $type);
+                    if ($sub !== null) {
+                        $result[] = $sub;
+                    }
+                }
+            }
+            return $result;
+        } else {
+            $result = '';
+            if (isset($array[$current])) {
+                if (empty($source)) {
+                    $result = $array[$current];
+                } else {
+                    return $this->extracted($array[$current], $source, $type);
+                }
+            } elseif ($this->field->$current) {
+                $result = $this->field->$current;
+            } else {
+                $result = $current;
+            }
+            if ($type) {
+                $result .= '||' . $type;
+            }
+            return $result;
+        }
+        return null;
+    }
+
+    protected function transform($value, $dest)
+    {
+        $current = array_shift($dest);
+        if (substr($current, -2) == '[]') {
+            $current = substr($current, 0, -2);
+            $result = [];
+            $result[$current] = [];
+            foreach ($value as $item) {
+                $result[$current][] = $this->transform($item, $dest);
+            }
+            return $result;
+        } else {
+            if (empty($dest)) {
+                return [$current => $value];
+            } else {
+                return [$current => $this->transform($value, $dest)];
+            }
+        }
+    }
+
+    protected function value($data)
+    {
+        if (!is_array($data)) {
+            return $data;
+        }
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                $temp = explode('||', $v);
+                $this->field->set($k, $temp[0]);
+            }
+        }
+        foreach ($data as $k => $v) {
+            if (is_array($v)) {
+                if (isset($v[0])) {
+                    foreach ($v as $k1 => $v1) {
+                        $data[$k][$k1] = $this->value($v1);
+                    }
+                } else {
+                    $data[$k] = $this->value($v, $key);
+                }
+            } else {
+                $temp = explode('||', $v);
+                if (empty($temp[1])) {
+                    $temp[1] = -1;
+                }
+                if (strstr($temp[0], 'sign-')) {
+                    $temp[0] = str_replace('sign-', '', $temp[0]);
+                    $this->sign['col'] = $temp[0];
+                    $sign = new Sign($this->field, $this->sign);
+                    $temp[0] = $sign->get();
+                }
+                $data[$k] = $this->field->value($temp[0], $temp[1], false);
+                $this->field->set($k, $data[$k]);
+            }
+        }
+        return $data;
+    }
+
+    protected function save($data)
+    {
+        $save = Dever::db($this->type . '_save', 'api')->select(array($this->type . '_id' => $this->type_id));
+        if ($save) {
+            $table = array();
+            foreach ($save as $k => $v) {
+                if (!isset($table[$v['table']])) {
+                    $table[$v['table']] = array
+                    (
+                        'total' => 0,
+                        'data' => array(),
+                        'where' => array(),
+                    );
+                }
+                if (strstr($v['value'], '.')) {
+                    $v['value'] = explode('.', $v['value']);
+                    $v['value'] = $this->extracted($data, $v['value']);
+                    $table[$v['table']]['total'] = count($v['value']);
+                } else {
+                    if (isset($data[$v['value']])) {
+                        $v['value'] = $data[$v['value']];
+                    }
+                }
+                if ($v['type'] == 3) {
+                    # 转时间戳
+                    foreach ($v['value'] as $k1 => $v1) {
+                        $v['value'][$k1] = strtotime($v1);
+                    }
+                }
+                $table[$v['table']]['data'][$v['key']] = $v['value'];
+                if ($v['type'] == 2) {
+                    $table[$v['table']]['where'][$v['key']] = $v['value'];
+                }
+            }
+            if ($table) {
+                foreach ($table as $k => $v) {
+                    $update = array();
+                    foreach ($v['data'] as $k1 => $v1) {
+                        for ($i = 0; $i < $v['total']; $i++) {
+                            $update[$i]['data'][$k1] = (is_array($v1) && isset($v1[$i])) ? $v1[$i] : $v1;
+                        }
+                    }
+                    foreach ($v['where'] as $k1 => $v1) {
+                        for ($i = 0; $i < $v['total']; $i++) {
+                            $update[$i]['where'][$k1] = (is_array($v1) && isset($v1[$i])) ? $v1[$i] : $v1;
+                        }
+                    }
+                    foreach ($update as $k1 => $v1) {
+                        $id = $this->saveData($k, $v1['where'], $v1['data']);
+                        if ($k == 'api/platform_cert' && $this->field->cert_table) {
+                            if (!$this->field->cert_data) {
+                                $this->field->cert_data = array();
+                            }
+                            $cert = $this->field->cert_data + array
+                            (
+                                'platform_cert_id' => $id,
+                            );
+                            $v1['where'] += $cert;
+                            $v1['data'] += $cert;
+                            $this->saveData($this->field->cert_table, $v1['where'], $v1['data']);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    protected function saveData($table, $where, $data)
+    {
+        if ($where) {
+            $info = Dever::db($table)->find($where);
+            if ($info) {
+                Dever::db($table)->update($info['id'], $data);
+                $id = $info['id'];
+            } else {
+                $id = Dever::db($table)->insert($data);
+            }
+        } else {
+            $id = Dever::db($table)->insert($data);
+        }
+        return $id;
+    }
+
+    protected function filter($data)
+    {
+        return preg_replace("/<!--[^\!\[]*?(?<!\/\/)-->/","",$data);
+    }
+}

+ 145 - 0
lib/Platform/Sign.php

@@ -0,0 +1,145 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Sign
+{
+    public function __construct($field, $config)
+    {
+        $this->field = $field;
+        $this->config = $config;
+        if ($this->config['sort'] == 3) {
+            ksort($this->field->body);
+        }
+    }
+
+    public function get()
+    {
+        if ($this->config['method'] == -1) {
+            return false;
+        }
+        $this->create();
+        if ($this->config['sort'] == 2) {
+            ksort($this->info);
+        }
+        $this->split();
+        $this->toString();
+        $this->encrypt();
+        $this->after();
+        $this->field->setSign($this->info);
+        return $this->info;
+    }
+
+    public function check($sign)
+    {
+        if ($this->config['method'] == -1) {
+            return false;
+        }
+        if ($this->config['verify_type'] == 2 && $this->config['method'] > 0) {
+            $this->create();
+            if ($this->config['sort'] == 2) {
+                ksort($this->info);
+            }
+            $this->split();
+            $this->toString();
+            $check = $this->field->ssl->decrypt($this->config['method'], $sign, $this->info);
+        } else {
+            $check = $sign == $this->get();
+        }
+        if (!$check) {
+            Dever::error('签名验证失败');
+        }
+    }
+
+    protected function create()
+    {
+        $this->info = array();
+        if ($this->config['col']) {
+            $col = explode('+', $this->config['col']);
+            foreach ($col as $k => $v) {
+                if ($v == 'body') {
+                    $this->info = array_merge($this->field->body, $this->info);
+                } else {
+                    $k = $v;
+                    if (strstr($v, '=')) {
+                        $t = explode('=', $v);
+                        $v = $t[1];
+                        $k = $t[0];
+                    }
+                    $this->info[$k] = $this->field->value($v);
+                }
+            }
+        } else {
+            $this->info = $this->field->body;
+        }
+    }
+
+    protected function split()
+    {
+        if (strstr($this->config['split'], '\\')) {
+            $this->config['split'] = preg_replace_callback(
+                '/\\\\([nrtf])/', // 匹配 \n, \r, \t, \f 等特殊字符
+                function ($matches) {
+                    $map = [
+                        'n' => "\n",
+                        'r' => "\r",
+                        't' => "\t",
+                        'f' => "\f"
+                    ];
+                    return $map[$matches[1]]; // 直接从映射中获取替换值
+                },
+                $this->config['split']
+            );
+        }
+    }
+
+    protected function toString()
+    {
+        $string = '';
+        foreach ($this->info as $k => $v) {
+            if ($this->config['empty'] == 2 && !$v) {
+                continue;
+            }
+            if ($this->config['encode'] == 2 && strstr($v, 'http')) {
+                $v = urlencode($v);
+                if (isset($this->field->body[$k])) {
+                    $this->field->body[$k] = $v;
+                }
+            }
+            if ($this->config['type'] == 1) {
+                $string .= $v;
+            } elseif ($this->config['type'] == 2) {
+                $string .= $k . '=' . $v;
+            } elseif ($this->config['type'] == 3) {
+                $string .= $k . $v;
+            }
+            
+            $string .= "{$this->config['split']}";
+        }
+        if ($this->config['split_type'] == 1) {
+            $this->info = rtrim($string, $this->config['split']);
+        } else {
+            $this->info = $string;
+        }
+    }
+
+    protected function encrypt()
+    {
+        if ($this->config['method'] == -2) {
+            $this->info = md5($this->info);
+        } elseif ($this->config['method'] == -3) {
+            $this->info = hash("sha256", $this->info);
+        } elseif ($this->config['method'] == -4) {
+            $this->info = sha1($this->info);
+        } else {
+            $this->info = $this->field->ssl->encrypt($this->config['method'], $this->info);
+        }
+    }
+
+    protected function after()
+    {
+        if ($this->config['after'] == 2) {
+            $this->info = strtoupper($this->info);
+        } elseif ($this->config['after'] == 2) {
+            $this->info = strtolower($this->info);
+        }
+    }
+}

+ 127 - 0
lib/Platform/Ssl.php

@@ -0,0 +1,127 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Ssl
+{
+    public function __construct($field)
+    {
+        $this->field = $field;
+    }
+
+    public function encrypt($id, $value)
+    {
+        $config = $this->config($id, 1, $value);
+        if ($config) {
+            if ($config['type'] == 1) {
+                # 非对称
+                openssl_public_encrypt($config['value'], $value, $config['cert'], $config['option']);
+            } elseif ($config['type'] == 2 && $config['cipher_algo']) {
+                # 对称
+                $value = openssl_encrypt($config['value'], $config['cipher_algo'], $config['cert'], $config['option'], $config['iv'], $config['tag'], $config['aad'], $config['tag_len']);
+            } elseif ($config['type'] == 3 && $config['cipher_algo']) {
+                # 签名
+                openssl_sign($config['value'], $value, $config['cert'], $config['cipher_algo']);
+            }
+
+            if ($config['after'] == 2) {
+                $value = base64_encode($value);
+            }
+        }
+        
+        return $value;
+    }
+
+    public function decrypt($id, $value, $data = '')
+    {
+        if (is_array($value)) {
+            $value = Dever::json_encode($value);
+        }
+        $config = $this->config($id, 2, $value);
+        if ($config) {
+            if ($config['type'] == 1) {
+                # 非对称
+                openssl_public_decrypt($config['value'], $value, $config['cert'], $config['option']);
+            } elseif ($config['type'] == 2 && $config['cipher_algo']) {
+                # 对称
+                $value = openssl_decrypt($config['value'], $config['cipher_algo'], $config['cert'], $config['option'], $config['iv'], $config['tag'], $config['aad']);
+            } elseif ($config['type'] == 3 && $config['cipher_algo']) {
+                # 签名验证
+                $value = openssl_verify($data, $config['value'], $config['cert'], $config['cipher_algo']);
+            }
+        }
+        
+        return $value;
+    }
+
+    protected function config($id, $type, $value)
+    {
+        $config = Dever::db('platform_ssl', 'api')->find($id);
+        if (!$config) {
+            return false;
+        }
+        $config['value'] = $value;
+        $key = $type == 1 ? 'encrypt' : 'decrypt';
+        $this->cert($config, $key);
+        if (!$config['cert']) {
+            return false;
+        }
+        if ($type == 2 && $config['after'] == 2) {
+            $config['value'] = base64_decode($config['value']);
+        }
+        # 对称加密需要特殊处理一下
+        if ($config['type'] == 2) {
+            if (!$config['option']) {
+                $config['option'] = 'OPENSSL_NO_PADDING';
+            }
+            $config['option'] = constant($config['option']);
+            if ($config['option'] === null) {
+                $config['option'] = OPENSSL_NO_PADDING;
+            }
+
+            $config['iv'] = $this->field->{$config['iv']} ?? $config['iv'];
+            $config['aad'] = $this->field->{$config['aad']} ?? $config['aad'];
+            if ($config['tag_len']) {
+                $config['tag'] = substr($config['value'], -$config['tag_len']);
+                $config['value'] = substr($config['value'], 0, -$config['tag_len']);
+            }
+            if (!$config['tag']) {
+                $config['tag'] = null;
+            }
+        }
+        return $config;
+    }
+
+    protected function cert(&$config, $key)
+    {
+        $config['cert_type'] = $config[$key . '_cert_type'];
+        $config['cert'] = $config[$key . '_cert'];
+        $config['cert_id'] = $config[$key . '_cert_id'];
+        
+        if ($config['cert_type'] == 3) {
+            # 公钥
+            $config['cert'] = $this->field->{$config['cert']} ?? $config['cert'];
+        } else {
+            $cert = Dever::db('platform_cert', 'api')->find($config['cert_id']);
+            $cert_list = Dever::db('platform_cert', 'api')->select(array('type' => $cert['type']), array('order' => 'edate desc'));
+            # 此处为了自动切换新证书
+            if ($cert_list[0]['id'] != $cert['id']) {
+                $cert = $cert_list[0];
+            }
+            # 如果有自定义的cert
+            if ($this->field->cert && isset($this->field->cert[$cert['id']])) {
+                $cert = $this->field->cert[$cert['id']];
+            }
+            $this->field->setNumber($cert['number']);
+            if ($config['cert_type'] == 2) {
+                $key = 'private';
+                $method = 'openssl_get_privatekey';
+            } else {
+                $key = 'public';
+                $method = 'openssl_x509_read';
+            }
+            if ($cert[$key]) {
+                $config['cert'] = $cert[$key];
+                $config['cert'] = $method($config['cert']);
+            }
+        }
+    }
+}

+ 37 - 0
lib/Spec.php

@@ -0,0 +1,37 @@
+<?php namespace Api\Lib;
+use Dever;
+class Spec
+{
+    # 获取规格数据
+    public function manage($api_id)
+    {
+        $result = array();
+        if ($api_id) {
+            $result = Dever::db('spec', 'api')->select(array('api_id' => $api_id));
+            if ($result) {
+                foreach ($result as $k => $v) {
+                    $result[$k]['type'] = 'show';
+                    $result[$k]['width'] = '100';
+                    $result[$k]['show'] = true;
+                    $result[$k]['fixed'] = true;
+                    $result[$k]['key'] = $v['name'];
+                    $value = Dever::db('spec_value', 'api')->select(array('api_id' => $api_id, 'spec_id' => $v['id']));
+                    if ($value) {
+                        foreach ($value as $k1 => $v1) {
+                            $value[$k1]['parent'] = $result[$k]['key'];
+                            $value[$k1]['name'] = $v1['value'];
+                            $value[$k1]['key'] = $v1['value'];
+                            if ($v1['is_checked'] == 1) {
+                                $value[$k1]['checked'] = true;
+                            } else {
+                                $value[$k1]['checked'] = false;
+                            }
+                        }
+                    }
+                    $result[$k]['value'] = $value;
+                }
+            }
+        }
+        return $result;
+    }
+}

+ 242 - 0
manage/api.php

@@ -0,0 +1,242 @@
+<?php
+$platform = include('platform.php');
+$config = array
+(
+    'list' => array
+    (
+        'field'      => array
+        (
+            'id',
+            'name',
+            'uri',
+            'env_type',
+            'cate' => array
+            (
+                'show' => 'Dever::call("content/cate.getInfo", array("api", "{cate}"))',
+            ),
+            'platform_id',
+            'status' => array
+            (
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+        ),
+        'data_button' => array
+        (
+            '设置' => 'edit',
+            '删除' => 'delete',
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', 'name,env_type,cate,platform_id,uri'),
+        ),
+        'search' => array
+        (
+            'platform_id',
+            'cate' => array
+            (
+                'type' => 'cascader',
+                'option'    => 'Dever::call("content/cate.getList", array("api"))',
+            ),
+            'name',
+            'uri',
+            'status',
+        ),
+    ),
+    'update' => array
+    (
+        'desc' => $platform['update']['desc'],
+        'end' => 'content/info.update',
+        'tab' => array
+        (
+            '基本设置' => 'name,env_type,cate,sign_col,uri,api/api_uri',
+            '价格设置' => 'spec_type,api/sku,api/sku#',
+            '请求参数' => 'method,post_method,api/api_request_header,api/api_request_body',
+            '响应参数' => 'api/api_response_header,api/api_response_body',
+            
+            '输入输出' => 'api/api_request_input,api/api_request_output',
+            '存储设置' => 'api/api_save',
+            '回调设置' => 'notify_type,notify_success,notify_error,api/api_notify_code',
+        ),
+        'field'    => array
+        (
+            'name',
+            'env_type' => 'radio',
+            'cate' => array
+            (
+                'type' => 'cascader',
+                'option'    => 'Dever::call("content/cate.getList", array("api"))',
+            ),
+            'platform_id' => array
+            (
+                'desc' => '【提交后不能更改】',
+            ),
+            'sign_col' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+                'desc' => '按顺序做加密,用+号隔开,为空则所有字段均参与加密,这里填写后,将替换平台中的签名加密参数',
+            ),
+            'uri',
+            'api/api_uri' => array
+            (
+                'name' => '接口地址生成',
+                'where'  => array('api_id' => 'id'),
+                'desc' => '如果需要动态生成接口地址,这里填写参数即可,同样支持变量',
+            ),
+
+            'method' => array
+            (
+                'type' => 'radio',
+                'control' => true,
+            ),
+            'post_method' => array
+            (
+                'type' => 'radio',
+                'show' => false,
+            ),
+            'api/api_request_input' => array
+            (
+                'name' => '参数输入',
+                'where'  => array('api_id' => 'id'),
+                'desc' => '[默认值/可选项:可以多行输入,默认值为第一行,其他行为可选项]',
+            ),
+            'api/api_request_output' => array
+            (
+                'name' => '参数输出',
+                'where'  => array('api_id' => 'id'),
+            ),
+            'api/api_request_body' => array
+            (
+                'name' => '请求体',
+                'where'  => array('api_id' => 'id'),
+            ),
+            'api/api_request_header' => array
+            (
+                'name' => '请求头',
+                'where'  => array('api_id' => 'id'),
+            ),
+
+            'api/api_response_body' => array
+            (
+                'name' => '响应体',
+                'desc' => '填写后,平台中的标准响应体将失效,并且只保留填写后的响应体,格式:data[].name,不是列表则为data.name',
+                'where'  => array('api_id' => 'id'),
+            ),
+
+            'api/api_response_header' => array
+            (
+                'name' => '响应头',
+                'desc' => '填写后,平台中的标准响应头将失效,不填写不保留响应头,格式:data[].name,不是列表则为data.name',
+                'where'  => array('api_id' => 'id'),
+            ),
+
+            'api/api_save' => array
+            (
+                'name' => '存储设置',
+                'desc' => '用于将响应数据保存到数据表中,该数据表最好有api_id(int)和request_id(varchar)字段,用于区分是哪个接口哪次请求,当然也可以没有',
+                'where'  => array('api_id' => 'id'),
+            ),
+
+            'notify_type' => array
+            (
+                'type' => 'radio',
+                'control' => true,
+            ),
+            'notify_success' => array
+            (
+                'desc' => '填写回调成功后,返回给渠道的信息',
+            ),
+            'notify_error' => array
+            (
+                'desc' => '填写回调失败后,返回给渠道的信息,如果填写500,则会返回HTTP Status Code 500,默认返回HTTP Status Code 200',
+            ),
+            'notify_sign_col' => array
+            (
+                'desc' => '回调签名参数,不填写则使用接口的回调签名参数',
+            ),
+            'api/api_notify_code' => array
+            (
+                'name' => '回调状态码',
+                'where'  => array('api_id' => 'id'),
+            ),
+
+            'spec_type' => array
+            (
+                'type' => 'radio',
+                'control' => true,
+            ),
+            'api/sku' => array
+            (
+                'name' => '单规格设置',
+                'where'  => array('api_id' => 'id', 'key' => '-1'),
+                # 默认值,如果有默认值则无法添加和删除
+                'default' => array
+                (
+                    # 默认值
+                    array
+                    (
+                        'price' => '',
+                        'num' => '',
+                        'day_num' => '',
+                    ),
+                ),
+            ),
+
+            'api/sku#' => array
+            (
+                'name' => '多规格设置',
+                'where' => array('api_id' => 'id', 'key' => array('!=', '-1')),
+                'type' => 'sku',
+                # 设置规格表名
+                'spec' => 'api/spec',
+                # 设置规格表关联字段
+                'spec_field' => 'api_id',
+                # 获取规格数据的接口
+                'spec_data' => 'api/spec.manage',
+            ),
+        ),
+
+        'control' => array
+        (
+            'post_method' => array
+            (
+                'method' => 2,
+            ),
+            'notify_success' => array
+            (
+                'notify_type' => 1,
+            ),
+            'notify_error' => array
+            (
+                'notify_type' => 1,
+            ),
+            'api/api_notify_code' => array
+            (
+                'notify_type' => 1,
+            ),
+            /*
+            'api/api_notify' => array
+            (
+                'notify_type' => 1,
+            ),*/
+
+            'api/sku' => array
+            (
+                'spec_type' => 1,
+            ),
+
+            'api/sku#' => array
+            (
+                'spec_type' => 2,
+            ),
+        ),
+    ),
+);
+$id = Dever::input('id');
+if (!$id) {
+    unset($config['update']['tab']);
+}
+return $config;

+ 13 - 0
manage/api_notify_code.php

@@ -0,0 +1,13 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'key',
+            'value',
+            'type',
+        ),
+    ),
+);

+ 2 - 0
manage/api_request_body.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 2 - 0
manage/api_request_header.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 35 - 0
manage/api_request_input.php

@@ -0,0 +1,35 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'option' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'type',
+            'match' => array
+            (
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{match}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+        ),
+        'drag' => 'sort',
+    ),
+);

+ 26 - 0
manage/api_request_output.php

@@ -0,0 +1,26 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'data' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+        ),
+        'drag' => 'sort',
+    ),
+);

+ 21 - 0
manage/api_response.php

@@ -0,0 +1,21 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'type',
+        ),
+    ),
+);

+ 2 - 0
manage/api_response_body.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 2 - 0
manage/api_response_header.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 22 - 0
manage/api_save.php

@@ -0,0 +1,22 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'table',
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'type',
+        ),
+    ),
+);

+ 14 - 0
manage/api_uri.php

@@ -0,0 +1,14 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'key',
+            'value',
+            'type',
+        ),
+        'drag' => 'sort',
+    ),
+);

+ 64 - 0
manage/app.php

@@ -0,0 +1,64 @@
+<?php
+return array
+(
+    'list' => array
+    (
+        'field'      => array
+        (
+            'name',
+            'key',
+            'sort' => 'input',
+            'status' => array
+            (
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+            'cdate',
+        ),
+        'button' => array
+        (
+            '新增' => 'fastadd',
+        ),
+        'data_button' => array
+        (
+            '编辑' => 'fastedit',
+            '功能' => array('route', array
+            (
+                'path' => 'api_manage/app_func',
+                'param' => array
+                (
+                    'set' => array('app_id' => 'id', 'menu' => 'api_manage/app', 'parent' => 'api_manage/app'),
+                ),
+            )),
+        ),
+        'search'    => array
+        (
+            'name',
+            'key',
+            'status',
+        ),
+    ),
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name' => array
+            (
+                'rules' => true,
+            ),
+            'key' => array
+            (
+                'desc' => '如果为空,将自动按照名称拼音生成',
+            ),
+            'desc' => 'textarea',
+            'status' => array
+            (
+                'type' => 'radio',
+            ),
+        ),
+        'check' => 'key',
+        'start' => 'content/cate.updateKey',
+    ),
+);

+ 74 - 0
manage/app_func.php

@@ -0,0 +1,74 @@
+<?php
+$app_id = Dever::input('set')['app_id'] ?? 0;
+return array
+(
+    'list' => array
+    (
+        'where' => array('app_id' => $app_id),
+        'field'      => array
+        (
+            'id',
+            'name',
+            'key',
+            'type',
+            'status' => array
+            (
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+            'cdate',
+        ),
+        'data_button' => array
+        (
+            '编辑' => array('edit', array('app_id' => $app_id)),
+        ),
+        'button' => array
+        (
+            '新增' => array('add', array('app_id' => $app_id)),
+        ),
+        'search' => array
+        (
+            'app_id' => 'hidden',
+            'name',
+            'key',
+            'type',
+        ),
+    ),
+    'update' => array
+    (
+        'end' => 'api/app.update',
+        'tab' => array
+        (
+            '基本设置' => 'app_id,name,key,type,desc,cron_time',
+            '接口设置' => 'api/app_func_work',
+        ),
+        'field'    => array
+        (
+            'app_id' => 'hidden',
+            'name',
+            'type',
+            'key' => array
+            (
+                'desc' => '如果为空,将自动按照名称拼音生成',
+            ),
+            'desc' => 'textarea',
+            'status' => array
+            (
+                'type' => 'radio',
+            ),
+            'cron_time' => array
+            (
+                'type' => 'text',
+                'desc' => '直接输入秒数,如60,就是间隔60秒执行一次,为0则不定时执行',
+            ),
+            'api/app_func_work' => array
+            (
+                'name' => '功能接口',
+                'desc' => '设置功能包含的接口',
+                'where'  => array('app_func_id' => 'id'),
+            ),
+        ),
+    ),
+);

+ 35 - 0
manage/app_func_work.php

@@ -0,0 +1,35 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'cate' => array
+            (
+                'rules' => true,
+                'type' => 'cascader',
+                'option'    => 'Dever::call("content/cate.getList", array("api"))',
+                'remote'    => 'api/cate.getApi',
+                # 无需默认值
+                'remote_default' => false,
+            ),
+            'api_id' => array
+            (
+                'rules' => true,
+                'type' => 'select',
+                'placeholder' => '选择接口',
+            ),
+            /*
+            'status' => array
+            (
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),*/
+        ),
+        'drag' => 'sort',
+    ),
+);

+ 3 - 0
manage/cate.php

@@ -0,0 +1,3 @@
+<?php
+$config = include(DEVER_PROJECT_PATH . 'src/resource/content/manage/cate.php');
+return $config;

+ 82 - 0
manage/core.php

@@ -0,0 +1,82 @@
+<?php
+return array
+(
+    'menu' => array
+    (
+        'connect' => array
+        (
+            'name' => '连接',
+            'icon' => 'contacts-line',
+            'sort' => '10',
+            'module' => 'platform',
+            'app' => 'sector',
+        ),
+
+        'api_manage' => array
+        (
+            'parent' => 'connect',
+            'name' => '接口',
+            'icon' => 'compasses-line',
+            'sort' => '1',
+        ),
+
+        'api' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '接口管理',
+            'icon'      => 'amazon-line',
+            'sort'      => '1',
+        ),
+
+        'cate' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '分类管理',
+            'icon'      => 'folder-2-line',
+            'sort'      => '2',
+        ),
+
+        'platform' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '平台管理',
+            'icon'      => 'tools-line',
+            'sort'      => '3',
+        ),
+
+        'platform_cert' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '平台证书管理',
+            'icon'      => 'tools-line',
+            'sort'      => '4',
+            'show'      => 3,
+        ),
+
+        'platform_ssl' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '平台加密管理',
+            'icon'      => 'tools-line',
+            'sort'      => '5',
+            'show'      => 3,
+        ),
+
+        'app' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '应用管理',
+            'icon'      => 'file-list-2-line',
+            'sort'      => '6',
+        ),
+
+        'app_func' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '应用功能管理',
+            'icon'      => 'file-list-2-line',
+            'sort'      => '7',
+            'show'      => 3,
+        ),
+    ),
+);

+ 175 - 0
manage/platform.php

@@ -0,0 +1,175 @@
+<?php
+$config = array
+(
+    'source' => 'api/platform',
+    'list' => array
+    (
+        'field'      => array
+        (
+            'id',
+            'name',
+            'host',
+            //'method',
+        ),
+        'data_button' => array
+        (
+            '设置' => 'edit',
+            '证书' => array('route', array
+            (
+                'path' => 'api_manage/platform_cert',
+                'param' => array
+                (
+                    'set' => array('platform_id' => 'id', 'menu' => 'api_manage/platform', 'parent' => 'api_manage/platform'),
+                ),
+            )),
+            '加解密' => array('route', array
+            (
+                'path' => 'api_manage/platform_ssl',
+                'param' => array
+                (
+                    'set' => array('platform_id' => 'id', 'menu' => 'api_manage/platform', 'parent' => 'api_manage/platform'),
+                ),
+            )),
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', 'name,host'),
+        ),
+        'search' => array
+        (
+            'name',
+        ),
+    ),
+    'update' => array
+    (
+        'desc' => "所有参数定义后均可以直接使用,也支持函数,参数值可以是变量、函数、字符串,如果函数中或者字符串中需要增加变量或者常量,请用{}隔开,默认常量:method请求方式,host主机域名,uri请求路径,sign签名,time秒时间戳,timestamp毫秒时间戳,nonce随机值,notify请求回调地址,order_num请求订单号,aad签名附加数据,body请求体参数,body_json请求体参数(json格式)",
+        'tab' => array
+        (
+            '基本设置' => 'name,host,method,post_method,api/platform_setting',
+            '标准请求' => 'api/platform_request_header,api/platform_request_body',
+            '标准响应' => 'api/platform_response_header,api/platform_response_body',
+            '响应体状态' => 'response_type,response_data,response_msg,response_code,api/platform_response_code',
+            //'字段转换' => 'api/platform_convert',
+            '签名设置' => 'sign_method,sign_name,sign_col,sign_verify_col,sign_type,sign_split,sign_split_type,sign_sort,sign_encode,sign_empty,sign_after,sign_verify_set,sign_verify_type',
+        ),
+        'field'    => array
+        (
+            'name',
+            'host',
+            'method' => array
+            (
+                'type' => 'radio',
+                'control' => true,
+            ),
+            'post_method' => array
+            (
+                'type' => 'radio',
+            ),
+
+            'api/platform_setting' => array
+            (
+                'name' => '参数设置',
+                'desc' => '设置对接平台需要的参数',
+                'where'  => array('platform_id' => 'id'),
+            ),
+
+            'api/platform_request_body' => array
+            (
+                'name' => '请求体设置',
+                'desc' => '设置平台标准请求体',
+                'where'  => array('platform_id' => 'id'),
+            ),
+            'api/platform_request_header' => array
+            (
+                'name' => '请求头设置',
+                'desc' => '设置平台标准请求头',
+                'where'  => array('platform_id' => 'id'),
+            ),
+
+            'api/platform_response_body' => array
+            (
+                'name' => '标准响应体',
+                'desc' => '设置平台标准响应体,只保留填写后的响应体,格式:data[].name,不是列表则为data.name',
+                'where'  => array('platform_id' => 'id'),
+            ),
+            'api/platform_response_header' => array
+            (
+                'name' => '标准响应头',
+                'desc' => '设置平台标准响应头,不填写不保留响应头,格式:data[].name,不是列表则为data.name',
+                'where'  => array('platform_id' => 'id'),
+            ),
+
+            'api/platform_convert' => array
+            (
+                'name' => '字段转换',
+                'where'  => array('platform_id' => 'id'),
+                'desc' => '设置之后,所有平台过来的字段,都将按照这个转换规则进行转换',
+            ),
+
+            'response_type' => array
+            (
+                'type' => 'radio',
+                //'control' => true,
+            ),
+            'response_data',
+            'response_msg',
+            'response_code',
+            'api/platform_response_code' => array
+            (
+                'name' => '响应状态码',
+                'desc' => '设置标准的响应状态码,也可以只设置成功值,其他值均为失败',
+                'where'  => array('platform_id' => 'id'),
+            ),
+
+            'sign_name',
+            'sign_method' => 'radio',
+            'sign_col' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+                'desc' => '按顺序做加密,用+号隔开,为空则所有参数均参与签名',
+            ),
+            'sign_verify_col' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+                'desc' => '同上,为空则与签名参数相同',
+            ),
+            'sign_type' => 'radio',
+            'sign_split',
+            'sign_split_type' => 'radio',
+            'sign_sort' => 'radio',
+            'sign_encode' => array
+            (
+                'type' => 'radio',
+                'desc' => '【如果参数中包含有特殊字符,是否进行转码】',
+            ),
+            'sign_empty' => array
+            (
+                'type' => 'radio',
+                'desc' => '【如果参数中有空值,是否参与签名】',
+            ),
+            'sign_after' => 'radio',
+            'sign_verify_type' => array
+            (
+                'type' => 'radio',
+                'desc' => '【选择对签名解签,必须选择可以解签的签名加密方式】',
+            ),
+            'sign_verify_set' => 'checkbox',
+        ),
+
+        'control' => array
+        (
+            'post_method' => array
+            (
+                'method' => 2,
+            ),
+        ),
+    ),
+);
+$id = Dever::input('id');
+if (!$id) {
+    $config['update']['desc'] = '';
+    unset($config['update']['tab']);
+}
+return $config;

+ 75 - 0
manage/platform_cert.php

@@ -0,0 +1,75 @@
+<?php
+$platform_id = Dever::input('set')['platform_id'] ?? 0;
+return array
+(
+    'list' => array
+    (
+        'where' => array('platform_id' => $platform_id),
+        'field'      => array
+        (
+            'id',
+            'name',
+            'type',
+            'number',
+            'cdate',
+        ),
+        'data_button' => array
+        (
+            '编辑' => 'fastedit',
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', array('platform_id' => $platform_id)),
+        ),
+        'search' => array
+        (
+            'platform_id' => 'hidden',
+            'name',
+            'number',
+        ),
+    ),
+    'update' => array
+    (
+        'field'    => array
+        (
+            'platform_id' => 'hidden',
+            'name',
+            'type' => array
+            (
+                'desc' => '手动输入即可,用以区分不同类别的证书',
+            ),
+            'number',
+            'public' => array
+            (
+                'type' => 'textarea',
+                //'autosize' => array('minRows' => 2),
+            ),
+            'private' => array
+            (
+                'type' => 'textarea',
+                //'autosize' => array('minRows' => 2),
+            ),
+            /*
+            'public' => array
+            (
+                'type' => 'upload',
+                'upload' => 8,
+                'yun' => true,
+                'limit' => 1,
+                'multiple' => false,
+                'tip' => '',
+                'style' => 'list',
+            ),
+            'private' => array
+            (
+                'type' => 'upload',
+                'upload' => 8,
+                'yun' => true,
+                'limit' => 1,
+                'multiple' => false,
+                'tip' => '',
+                'style' => 'list',
+            ),*/
+        ),
+    ),
+);

+ 12 - 0
manage/platform_convert.php

@@ -0,0 +1,12 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'before',
+            'after',
+        ),
+    ),
+);

+ 21 - 0
manage/platform_request_body.php

@@ -0,0 +1,21 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'type',
+        ),
+    ),
+);

+ 2 - 0
manage/platform_request_header.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 2 - 0
manage/platform_response_body.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 12 - 0
manage/platform_response_code.php

@@ -0,0 +1,12 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'value',
+            'type',
+        ),
+    ),
+);

+ 2 - 0
manage/platform_response_header.php

@@ -0,0 +1,2 @@
+<?php
+return include('platform_request_body.php');

+ 25 - 0
manage/platform_setting.php

@@ -0,0 +1,25 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'key' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+        ),
+    ),
+);

+ 143 - 0
manage/platform_ssl.php

@@ -0,0 +1,143 @@
+<?php
+$platform_id = Dever::input('set')['platform_id'] ?? 0;
+if (!$platform_id) {
+    $platform_id = Dever::input('field')['platform_id'] ?? 0;
+}
+return array
+(
+    'list' => array
+    (
+        'where' => array('platform_id' => $platform_id),
+        'field'      => array
+        (
+            'id',
+            'name',
+            'type',
+            'cdate',
+        ),
+        'data_button' => array
+        (
+            '编辑' => array('fastedit', array('platform_id' => $platform_id)),
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', array('platform_id' => $platform_id)),
+        ),
+        'search' => array
+        (
+            'platform_id' => 'hidden',
+            'name',
+        ),
+    ),
+    'update' => array
+    (
+        'tab' => array
+        (
+            '基本设置' => 'name,type,cipher_algo,option,iv,tag_len,aad,after',
+            '加密设置' => 'encrypt_cert_type,encrypt_cert,encrypt_cert_id',
+            '解密设置' => 'decrypt_cert_type,decrypt_cert,decrypt_cert_id',
+        ),
+
+        'field'    => array
+        (
+            'platform_id' => 'hidden',
+            'name',
+            'type' => 'radio',
+            'cipher_algo' => array
+            (
+                'desc' => '直接填写密码学方式的值,如aes-256-cbc',
+            ),
+            'option' => array
+            (
+                'desc' => '直接输入填充模式的常量即可,如:OPENSSL_NO_PADDING'
+            ),
+            'iv' => array
+            (
+                'desc' => '支持变量,参考平台设置中的变量说明',
+            ),
+            'tag' => array
+            (
+                'desc' => '支持变量,参考平台设置中的变量说明',
+            ),
+            'tag_len',
+            'aad' => array
+            (
+                'desc' => '支持变量,参考平台设置中的变量说明',
+            ),
+            'after' => 'radio',
+
+            'encrypt_cert_type' => 'radio',
+            'encrypt_cert' => array
+            (
+                'type' => 'text',
+                'desc' => '这里支持平台参数',
+            ),
+            'encrypt_cert_id' => array
+            (
+                'type' => 'select',
+                'option'     => 'Dever::call("api/cert.list", array('.$platform_id.'))',
+            ),
+
+            'decrypt_cert_type' => 'radio',
+            'decrypt_cert' => array
+            (
+                'type' => 'text',
+                'desc' => '这里支持平台参数',
+            ),
+            'decrypt_cert_id' => array
+            (
+                'type' => 'select',
+                'option'     => 'Dever::call("api/cert.list", array('.$platform_id.'))',
+            ),
+        ),
+
+        'control' => array
+        (
+            'cipher_algo' => array
+            (
+                'type' => array(2,3)
+            ),
+
+            'option' => array
+            (
+                'type' => array(1,2)
+            ),
+
+            'iv' => array
+            (
+                'type' => 2,
+            ),
+            
+            'tag' => array
+            (
+                'type' => 2,
+            ),
+            'aad' => array
+            (
+                'type' => 2,
+            ),
+            'tag_len' => array
+            (
+                'type' => 2,
+            ),
+
+            'encrypt_cert' => array
+            (
+                'encrypt_cert_type' => 3,
+            ),
+            'encrypt_cert_id' => array
+            (
+                'encrypt_cert_type' => array(1,2),
+            ),
+
+            'decrypt_cert' => array
+            (
+                'decrypt_cert_type' => 3,
+            ),
+            'decrypt_cert_id' => array
+            (
+                'decrypt_cert_type' => array(1,2),
+            ),
+        ),
+    ),
+);

+ 30 - 0
manage/sku.php

@@ -0,0 +1,30 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'key' => array
+            (
+                'type' => 'hidden',
+                'remote' => 'api/manage.keyToField',
+            ),
+            'price' => array
+            (
+                'type' => 'text',
+                'rules' => true,
+            ),
+            'num' => array
+            (
+                'type' => 'text',
+                'rules' => true,
+            ),
+            'day_num' => array
+            (
+                'type' => 'text',
+                'rules' => true,
+            ),
+        ),
+    ),
+);

+ 146 - 0
table/api.php

@@ -0,0 +1,146 @@
+<?php
+return array
+(
+    'name' => '接口配置',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台',
+            'type'      => 'int(11)',
+            'value'     => 'api/platform',
+        ),
+
+        'name' => array
+        (
+            'name'      => '接口名称',
+            'type'      => 'varchar(150)',
+        ),
+
+        'cate' => array
+        (
+            'name'      => '分类',
+            'type'      => 'varchar(800)',
+        ),
+
+        'cate_parent_id' => array
+        (
+            'name'      => '父级分类',
+            'type'      => 'int(11)',
+        ),
+
+        'cate_child_id' => array
+        (
+            'name'      => '子分类',
+            'type'      => 'int(11)',
+        ),
+
+        'uri' => array
+        (
+            'name'      => '接口地址',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'sign_col' => array
+        (
+            'name'      => '签名加密参数',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'method' => array
+        (
+            'name'      => '请求方式',
+            'type'      => 'tinyint(1)',
+            'default'   => '-1',
+            'value'     => array
+            (
+                -1 => '使用平台标准请求方式',
+                1 => 'get',
+                2 => 'post',
+            ),
+        ),
+
+        'post_method' => array
+        (
+            'name'      => '请求头设置',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '普通表单:application/x-www-form-urlencoded',
+                2 => '文件表单:multipart/form-data',
+                3 => 'JSON:application/json',
+            ),
+        ),
+
+        'notify_type' => array
+        (
+            'name'      => '是否有回调',
+            'type'      => 'tinyint(1)',
+            'default'   => '2',
+            'value'     => array
+            (
+                1 => '有回调',
+                2 => '无回调',
+            ),
+        ),
+
+        'notify_success' => array
+        (
+            'name'      => '回调成功响应',
+            'type'      => 'varchar(500)',
+        ),
+
+        'notify_error' => array
+        (
+            'name'      => '回调失败响应',
+            'type'      => 'varchar(500)',
+        ),
+
+        'notify_sign_col' => array
+        (
+            'name'      => '签名加密参数',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'spec_type' => array
+        (
+            'name'      => '规格类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '单规格',
+                2 => '多规格',
+            ),
+        ),
+
+        'env_type' => array
+        (
+            'name'      => '运行环境',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '通用',
+                2 => 'h5',
+                3 => 'jsapi',
+                4 => 'app',
+                5 => '小程序',
+                6 => '二维码',
+            ),
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '展示',
+                2 => '不展示',
+            ),
+        ),
+    ),
+);

+ 32 - 0
table/api_log.php

@@ -0,0 +1,32 @@
+<?php
+return array
+(
+    'name' => 'api日志',
+    'store' => 'log',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'request_id' => array
+        (
+            'name'      => '请求id',
+            'type'      => 'varchar(200)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '数据表字段名',
+            'type'      => 'varchar(150)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '响应参数名/参数值',
+            'type'      => 'varchar(800)',
+        ),
+    ),
+);

+ 38 - 0
table/api_notify_code.php

@@ -0,0 +1,38 @@
+<?php
+return array
+(
+    'name' => '回调参数配置',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '状态码标识',
+            'type'      => 'varchar(150)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '状态码值',
+            'type'      => 'varchar(150)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '状态码类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '成功',
+                2 => '失败',
+                3 => '其他',
+            ),
+        ),
+    ),
+);

+ 13 - 0
table/api_request_body.php

@@ -0,0 +1,13 @@
+<?php
+$config = include('platform_request_body.php');
+unset($config['struct']['platform_id']);
+$config['struct'] += array
+(
+    'api_id' => array
+    (
+        'name'      => '接口id',
+        'type'      => 'int(11)',
+    ),
+);
+$config['name'] = '接口请求体参数配置';
+return $config;

+ 13 - 0
table/api_request_header.php

@@ -0,0 +1,13 @@
+<?php
+$config = include('platform_request_body.php');
+unset($config['struct']['platform_id']);
+$config['struct'] += array
+(
+    'api_id' => array
+    (
+        'name'      => '接口id',
+        'type'      => 'int(11)',
+    ),
+);
+$config['name'] = '接口请求头参数配置';
+return $config;

+ 70 - 0
table/api_request_input.php

@@ -0,0 +1,70 @@
+<?php
+return array
+(
+    'name' => '输入参数配置',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '参数描述',
+            'type'      => 'varchar(150)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '参数名',
+            'type'      => 'varchar(150)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '单行输入',
+                2 => '多行输入',
+                3 => '单选',
+                4 => '多选',
+                5 => '选择框',
+                11 => '图片上传',
+                12 => '视频上传',
+                13 => '音频上传',
+                14 => '文件上传',
+            ),
+        ),
+
+        'option' => array
+        (
+            'name'      => '默认值/可选项',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'match' => array
+        (
+            'name'      => '必填',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '必填',
+                2 => '选填',
+            ),
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 39 - 0
table/api_request_output.php

@@ -0,0 +1,39 @@
+<?php
+return array
+(
+    'name' => '输出参数配置',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '模块名称',
+            'type'      => 'varchar(150)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '模块标识',
+            'type'      => 'varchar(150)',
+        ),
+
+        'data' => array
+        (
+            'name'      => '包含数据',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 14 - 0
table/api_response.php

@@ -0,0 +1,14 @@
+<?php
+$config = include('platform_request_body.php');
+unset($config['struct']['platform_id']);
+$config['struct']['value']['name'] = '转换参数名';
+$config['struct'] += array
+(
+    'api_id' => array
+    (
+        'name'      => '接口id',
+        'type'      => 'int(11)',
+    ),
+);
+$config['name'] = '接口响应参数配置';
+return $config;

+ 14 - 0
table/api_response_body.php

@@ -0,0 +1,14 @@
+<?php
+$config = include('platform_request_body.php');
+unset($config['struct']['platform_id']);
+//$config['struct']['value']['name'] = '转换参数名';
+$config['struct'] += array
+(
+    'api_id' => array
+    (
+        'name'      => '接口id',
+        'type'      => 'int(11)',
+    ),
+);
+$config['name'] = '接口响应体参数配置';
+return $config;

+ 14 - 0
table/api_response_header.php

@@ -0,0 +1,14 @@
+<?php
+$config = include('platform_request_body.php');
+unset($config['struct']['platform_id']);
+//$config['struct']['value']['name'] = '转换参数名';
+$config['struct'] += array
+(
+    'api_id' => array
+    (
+        'name'      => '接口id',
+        'type'      => 'int(11)',
+    ),
+);
+$config['name'] = '接口响应头参数配置';
+return $config;

+ 45 - 0
table/api_save.php

@@ -0,0 +1,45 @@
+<?php
+return array
+(
+    'name' => 'api数据存储定义',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'table' => array
+        (
+            'name'      => '数据表表名',
+            'type'      => 'varchar(200)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '数据表字段名',
+            'type'      => 'varchar(150)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '响应参数名/参数值',
+            'type'      => 'varchar(800)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '普通字段',
+                2 => '条件字段',
+                3 => '时间戳字段',
+            ),
+        ),
+    ),
+);

+ 48 - 0
table/api_uri.php

@@ -0,0 +1,48 @@
+<?php
+return array
+(
+    'name' => '接口地址参数',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口id',
+            'type'      => 'int(11)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '参数名',
+            'type'      => 'varchar(150)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '参数值',
+            'type'      => 'varchar(150)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '参数位置',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '接口路径:value形式',
+                2 => '接口路径:key/value形式',
+                3 => '接口路径:key=value形式',
+                4 => '接口参数:value形式',
+                5 => '接口参数:key=value形式',
+            ),
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 44 - 0
table/app.php

@@ -0,0 +1,44 @@
+<?php
+return array
+(
+    'name' => '应用表',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'name' => array
+        (
+            'name'      => '应用名称',
+            'type'      => 'varchar(32)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '应用标识',
+            'type'      => 'varchar(80)',
+        ),
+
+        'desc' => array
+        (
+            'name'      => '应用描述',
+            'type'      => 'varchar(800)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '上架',
+                2 => '下架',
+            ),
+        ),
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 83 - 0
table/app_func.php

@@ -0,0 +1,83 @@
+<?php
+return array
+(
+    'name' => '应用功能表',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'app_id' => array
+        (
+            'name'      => '应用id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '功能名称',
+            'type'      => 'varchar(32)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '功能标识',
+            'type'      => 'varchar(80)',
+        ),
+
+        'desc' => array
+        (
+            'name'      => '功能描述',
+            'type'      => 'varchar(800)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '单接口-按需执行某一接口',
+                2 => '工作流-按顺序执行所有接口',
+                3 => '工作组-同时执行所有接口'
+            ),
+        ),
+
+        'cron_date' => array
+        (
+            'name'      => '定时执行时间',
+            'type'      => 'int(11)',
+        ),
+
+        'cron_time' => array
+        (
+            'name'      => '定时执行间隔',
+            'type'      => 'int(11)',
+            'default'   => '0',
+        ),
+
+        'desc' => array
+        (
+            'name'      => '功能描述',
+            'type'      => 'varchar(800)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '上架',
+                2 => '下架',
+            ),
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 45 - 0
table/app_func_work.php

@@ -0,0 +1,45 @@
+<?php
+return array
+(
+    'name' => '应用功能工作表',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'app_func_id' => array
+        (
+            'name'      => '功能id',
+            'type'      => 'int(11)',
+        ),
+
+        'cate' => array
+        (
+            'name'      => '分类',
+            'type'      => 'varchar(800)',
+        ),
+
+        'api_id' => array
+        (
+            'name'      => '接口',
+            'type'      => 'int(11)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '上架',
+                2 => '下架',
+            ),
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 19 - 0
table/app_platform.php

@@ -0,0 +1,19 @@
+<?php
+return array
+(
+    'name' => '应用与平台关联表',
+    'struct' => array
+    (
+        'app_id' => array
+        (
+            'name'      => '应用id',
+            'type'      => 'int(11)',
+        ),
+
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+    ),
+);

+ 4 - 0
table/cate.php

@@ -0,0 +1,4 @@
+<?php
+$config = include(DEVER_PROJECT_PATH . '/src/resource/content/table/cate.php');
+$config['name'] = '接口分类表';
+return $config;

+ 224 - 0
table/platform.php

@@ -0,0 +1,224 @@
+<?php
+$encrypt = array
+(
+    -1 => '无签名',
+    -2 => 'md5',
+    -3 => 'sha256',
+    -4 => 'sha1',
+);
+$id = Dever::input('id');
+if ($id) {
+    $info = Dever::db('platform_ssl', 'api')->select(['platform_id' => $id]);
+    if ($info) {
+        foreach ($info as $k => $v) {
+            $encrypt[$v['id']] = $v['name'];
+        }
+    }
+}
+
+return array
+(
+    'name' => '平台表',
+    'struct' => array
+    (
+        'name' => array
+        (
+            'name'      => '平台名称',
+            'type'      => 'varchar(32)',
+        ),
+
+        'host' => array
+        (
+            'name'      => '主机域名',
+            'type'      => 'varchar(500)',
+        ),
+
+        'method' => array
+        (
+            'name'      => '请求方式',
+            'type'      => 'tinyint(1)',
+            'default'   => '2',
+            'value'     => array
+            (
+                1 => 'get',
+                2 => 'post',
+            ),
+        ),
+
+        'post_method' => array
+        (
+            'name'      => '请求头设置',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '普通表单:application/x-www-form-urlencoded',
+                2 => '文件表单:multipart/form-data',
+                3 => 'JSON:application/json',
+            ),
+        ),
+
+        'response_type' => array
+        (
+            'name'      => '响应数据类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '2',
+            'value'     => array
+            (
+                //1 => '无标准响应',
+                2 => 'JSON',
+                3 => 'XML',
+            ),
+        ),
+
+        'response_data' => array
+        (
+            'name'      => '数据字段',
+            'type'      => 'varchar(100)',
+        ),
+
+        'response_msg' => array
+        (
+            'name'      => '信息字段',
+            'type'      => 'varchar(100)',
+        ),
+
+        'response_code' => array
+        (
+            'name'      => '状态码字段',
+            'type'      => 'varchar(100)',
+        ),
+
+        'sign_name' => array
+        (
+            'name'      => '签名名称',
+            'type'      => 'varchar(100)',
+            //'default'   => 'sign',
+        ),
+
+        'sign_method' => array
+        (
+            'name'      => '签名加密方式',
+            'type'      => 'int(11)',
+            'default'   => '-1',
+            'value'     => $encrypt,
+        ),
+
+        'sign_col' => array
+        (
+            'name'      => '签名参数',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'sign_verify_col' => array
+        (
+            'name'      => '验签参数',
+            'type'      => 'varchar(1000)',
+        ),
+
+        'sign_verify_type' => array
+        (
+            'name'      => '验签类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '2',
+            'value'     => array
+            (
+                1 => '生成新签名做对比',
+                2 => '对签名解签',
+            ),
+        ),
+
+        'sign_verify_set' => array
+        (
+            'name'      => '验签设置',
+            'type'      => 'varchar(50)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '回调验签',
+                2 => '响应验签',
+            ),
+        ),
+
+        'sign_type' => array
+        (
+            'name'      => '签名形式',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => 'value形式',
+                2 => 'key=value形式',
+                3 => 'keyvalue形式',
+            ),
+        ),
+
+        'sign_split' => array
+        (
+            'name'      => '签名分隔符',
+            'type'      => 'varchar(30)',
+        ),
+
+        'sign_split_type' => array
+        (
+            'name'      => '分隔符处理',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '删除尾部分隔符',
+                2 => '不删除',
+            ),
+        ),
+
+        'sign_sort' => array
+        (
+            'name'      => '签名排序',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '按照签名参数排序',
+                2 => '按照签名参数首字母正序排序',
+                3 => '按照请求体首字母正序排序',
+            ),
+        ),
+
+        'sign_encode' => array
+        (
+            'name'      => '签名转码',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '不处理',
+                2 => 'urlencode编码',
+            ),
+        ),
+
+        'sign_empty' => array
+        (
+            'name'      => '签名空值',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '参与加密',
+                2 => '不参与加密',
+            ),
+        ),
+
+        'sign_after' => array
+        (
+            'name'      => '加密后处理',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '不处理',
+                2 => '转大写',
+                3 => '转小写',
+            ),
+        ),
+    ),
+);

+ 50 - 0
table/platform_cert.php

@@ -0,0 +1,50 @@
+<?php
+return array
+(
+    'name' => '平台证书配置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '证书名称',
+            'type'      => 'varchar(50)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '证书类型',
+            'type'      => 'varchar(50)',
+        ),
+
+        'number' => array
+        (
+            'name'      => '证书序列号',
+            'type'      => 'varchar(800)',
+        ),
+
+        'public' => array
+        (
+            'name'      => '公钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'private' => array
+        (
+            'name'      => '私钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'edate' => array
+        (
+            'name'      => '过期时间',
+            'type'      => 'int(11)',
+        ),
+    ),
+);

+ 25 - 0
table/platform_convert.php

@@ -0,0 +1,25 @@
+<?php
+return array
+(
+    'name' => '参数转换配置',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'before' => array
+        (
+            'name'      => '转换前字段',
+            'type'      => 'varchar(150)',
+        ),
+
+        'after' => array
+        (
+            'name'      => '转换后字段',
+            'type'      => 'varchar(150)',
+        ),
+    ),
+);

+ 55 - 0
table/platform_request_body.php

@@ -0,0 +1,55 @@
+<?php
+$type = array
+(
+    -1 => '字符串',
+    -2 => '数值',
+    //-3 => 'JSON',
+    -4 => '时间戳',
+    -5 => '时间格式:yyyy-MM-dd HH:mm:ss',
+    -6 => '时间格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE',
+);
+$id = Dever::input('id');
+if ($id) {
+    $api = Dever::db('api', 'api')->find($id);
+    if ($api) {
+        $info = Dever::db('platform_ssl', 'api')->select(['platform_id' => $api['platform_id']]);
+        if ($info) {
+            foreach ($info as $k => $v) {
+                $type[$v['id']] = $v['name'];
+            }
+        }
+    }
+}
+return array
+(
+    'name' => '请求体通用参数配置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '参数名',
+            'type'      => 'varchar(150)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '参数值',
+            'type'      => 'varchar(150)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '参数类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '-1',
+            'value'     => $type,
+        ),
+    ),
+);

+ 4 - 0
table/platform_request_header.php

@@ -0,0 +1,4 @@
+<?php
+$config = include('platform_request_body.php');
+$config['name'] = '请求头通用参数配置';
+return $config;

+ 5 - 0
table/platform_response_body.php

@@ -0,0 +1,5 @@
+<?php
+$config = include('platform_request_body.php');
+//$config['struct']['value']['name'] = '转换参数名';
+$config['name'] = '响应体通用参数配置';
+return $config;

+ 31 - 0
table/platform_response_code.php

@@ -0,0 +1,31 @@
+<?php
+return array
+(
+    'name' => '响应状态码列表',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '返回码值',
+            'type'      => 'varchar(150)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '参数类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '成功',
+                2 => '失败',
+            ),
+        ),
+    ),
+);

+ 5 - 0
table/platform_response_header.php

@@ -0,0 +1,5 @@
+<?php
+$config = include('platform_request_body.php');
+//$config['struct']['value']['name'] = '转换参数名';
+$config['name'] = '响应体通用参数配置';
+return $config;

+ 32 - 0
table/platform_setting.php

@@ -0,0 +1,32 @@
+<?php
+return array
+(
+    'name' => '平台配置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '参数描述',
+            'type'      => 'varchar(800)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '参数名',
+            'type'      => 'varchar(800)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '参数值',
+            'type'      => 'varchar(800)',
+        ),
+    ),
+);

+ 134 - 0
table/platform_ssl.php

@@ -0,0 +1,134 @@
+<?php
+return array
+(
+    'name' => '平台加解密',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'platform_id' => array
+        (
+            'name'      => '平台id',
+            'type'      => 'int(11)',
+        ),
+
+        'name' => array
+        (
+            'name'      => '名称',
+            'type'      => 'varchar(50)',
+        ),
+
+        'type' => array
+        (
+            'name'      => '算法',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '非对称',
+                2 => '对称',
+                3 => '签名',
+            ),
+        ),
+
+        'cipher_algo' => array
+        (
+            'name'      => '密码学方式',
+            'type'      => 'varchar(50)',
+        ),
+
+        'option' => array
+        (
+            'name'      => '填充模式',
+            'type'      => 'varchar(30)',
+            'default'   => 'OPENSSL_NO_PADDING',
+        ),
+
+        # 对称加密特有
+        'iv' => array
+        (
+            'name'      => '初始化向量',
+            'type'      => 'varchar(50)',
+        ),
+
+        'tag' => array
+        (
+            'name'      => '验证标签',
+            'type'      => 'varchar(50)',
+        ),
+
+        'tag_len' => array
+        (
+            'name'      => '标签长度',
+            'type'      => 'tinyint(1)',
+            'default'   => '16',
+        ),
+
+        'aad' => array
+        (
+            'name'      => '附加验证数据',
+            'type'      => 'varchar(50)',
+        ),
+
+        'after' => array
+        (
+            'name'      => '数据处理',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '不处理',
+                2 => '转base64',
+            ),
+        ),
+
+        'encrypt_cert_type' => array
+        (
+            'name'      => '加密密钥类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '公钥',
+                2 => '私钥',
+                3 => '文本',
+            ),
+        ),
+
+        'encrypt_cert' => array
+        (
+            'name'      => '加密密钥文本',
+            'type'      => 'varchar(50)',
+        ),
+
+        'encrypt_cert_id' => array
+        (
+            'name'      => '加密证书',
+            'type'      => 'int(11)',
+        ),
+
+        'decrypt_cert_type' => array
+        (
+            'name'      => '解密密钥类型',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+            'value'     => array
+            (
+                1 => '公钥',
+                2 => '私钥',
+                3 => '文本',
+            ),
+        ),
+
+        'decrypt_cert' => array
+        (
+            'name'      => '解密密钥文本',
+            'type'      => 'varchar(50)',
+        ),
+
+        'decrypt_cert_id' => array
+        (
+            'name'      => '解密证书',
+            'type'      => 'int(11)',
+        ),
+    ),
+);

+ 44 - 0
table/sku.php

@@ -0,0 +1,44 @@
+<?php
+return array
+(
+    'name' => '接口规格设置',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口ID',
+            'type'      => 'int(11)',
+        ),
+
+        'key' => array
+        (
+            'name'      => '规格ID',
+            'type'      => 'varchar(500)',
+        ),
+
+        'price' => array
+        (
+            'name'      => '售价',
+            'type'      => 'decimal(11,2)',
+        ),
+
+        'num' => array
+        (
+            'name'      => '总次数',
+            'type'      => 'int(11)',
+        ),
+
+        'day_num' => array
+        (
+            'name'      => '每天限制次数',
+            'type'      => 'int(11)',
+        ),
+
+        'state' => array
+        (
+            'name'      => '数据状态',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 32 - 0
table/spec.php

@@ -0,0 +1,32 @@
+<?php
+return array
+(
+    'name' => '接口规格设置',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口ID',
+            'type'      => 'int(11)',
+        ),
+        'name' => array
+        (
+            'name'      => '规格名称',
+            'type'      => 'varchar(200)',
+        ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+        'state' => array
+        (
+            'name'      => '数据状态',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+        ),
+    ),
+);

+ 47 - 0
table/spec_value.php

@@ -0,0 +1,47 @@
+<?php
+return array
+(
+    'name' => '接口规格值设置',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'api_id' => array
+        (
+            'name'      => '接口ID',
+            'type'      => 'int(11)',
+        ),
+        'spec_id' => array
+        (
+            'name'      => '规格ID',
+            'type'      => 'int(11)',
+        ),
+        'value' => array
+        (
+            'name'      => '规格值',
+            'type'      => 'varchar(500)',
+        ),
+        'is_checked' => array
+        (
+            'name'      => '是否选中',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '选中',
+                2 => '未选中',
+            )
+        ),
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
+        'state' => array
+        (
+            'name'      => '数据状态',
+            'type'      => 'tinyint(1)',
+            'default'   => '1',
+        ),
+    ),
+);