rabin il y a 6 mois
Parent
commit
b9bcd4d110

+ 0 - 17
api/Cate.php

@@ -1,17 +0,0 @@
-<?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;
-        }
-    }
-}

+ 24 - 0
api/Manage.php

@@ -40,4 +40,28 @@ class Manage extends Auth
             return $result;
         }
     }
+
+    # 根据平台获取接口
+    public function getApi($value = false)
+    {
+        if ($value) {
+            $where['platform_id'] = $value;
+            $result['api_id']['value'] = '';
+            $result['api_id']['option'] = Dever::db('api', 'api')->select($where);
+            return $result;
+        }
+    }
+
+    # 根据应用获取平台
+    public function getAppPlatform()
+    {
+        return Dever::load('common', 'manage')->cascader(2, function($level, $parent) {
+            if ($level == 1) {
+                $data = Dever::db('app', 'api')->select([]);
+            } elseif ($level == 2) {
+                $data = Dever::load('app', 'api')->getPlatform($parent);
+            }
+            return $data;
+        });
+    }
 }

+ 98 - 162
api/Notify.php

@@ -1,219 +1,155 @@
 <?php namespace Api\Api;
 use Dever;
 use Api\Lib\Api;
+use Api\Lib\Platform\Sign;
+use Api\Lib\Platform\Value;
 class Notify extends Api
 {
     public function common()
     {
+        $input = Dever::input();
         $file = file_get_contents("php://input");
         if ($file) {
-            $file = json_decode($file, true);
+            $file = Dever::json_decode($file);
             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();
+        Dever::log($input, 'api_notify');
         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) {
+            $data = explode('|', $s);
+            $api_id = $data[0];
+            if (!$api_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');
+            if (isset($data[1])) {
+                $method = $data[1];
+                unset($data[0]);
+                unset($data[1]);
+                $param = array_values($data);
             }
-            $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');
-                }
-            }
+        $state = $this->setting($api_id);
+        if (!$state) {
+            $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');
+        if ($this->info['notify_type'] == 2) {
+            $this->error('error');
         }
-        $this->connect['appsecret'] = $channel['appsecret'];
+        $body = $this->body($input);
+        $this->header();
+        $this->verify();
 
-        $code = Dever::db('api_notify_code', 'api')->select(array('api_id' => $api_id));
+        # 判断是否成功
+        $status = $this->status($body);
 
-        $status = 0;
-        if ($code) {
-            foreach ($code as $k => $v) {
-                if (isset($input[$v['key']]) && $input[$v['key']] == $v['value']) {
-                    $status = $v['type'];
-                }
+        if ($status < 3 && isset($method)) {
+            $param[] = $status;
+            $param[] = $body;
+            $msg = Dever::call($method, $param);
+            if ($msg) {
+                $this->error($msg);
             }
         }
-        $data = $input;
-        $data['status'] = $status;
-        $data = $this->service($data);
 
-        $msg = '';
+        # 返回给上游信息
         if ($status == 1) {
-            $msg = 'ok';
+            echo $this->info['notify_success'];die;
         } 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();
+            $this->error('error');
+        }
+    }
 
-            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);
+    protected function body($body)
+    {
+        $config = Dever::db('api_notify_body', 'api')->select(array('api_id' => $this->info['id']));
+        $value = new Value($this->field, $this->sign);
+        $result = $value->get($config, $body);
+        if ($result) {
+            foreach ($config as $k => $v) {
+                if (isset($body[$v['value']])) {
+                    $value = $this->field->value($body[$v['value']], $v['type'], false);
+                    $this->field->set($v['key'], $value);
                 }
-            } else {
-                Dever::load('order', 'seller')->notify($order, $msg, $update);
             }
-            echo $this->info['notify_success'];die;
         }
-        $this->error('error');
+        return $result;
     }
 
-    private function error($msg)
+    protected function header()
     {
-        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;
+        $header = getallheaders();
+        $config = Dever::db('platform_response_header', 'api')->select(array('platform_id' => $this->platform['id']));
+        if ($config) {
+            foreach ($config as $k => $v) {
+                if (isset($header[$v['value']])) {
+                    $value = $this->field->value($header[$v['value']], $v['type'], false);
+                    $this->field->set($v['key'], $value);
+                }
             }
         }
-        echo $msg;die;
     }
 
-    # 生成回调
-    public function callback()
+    protected function verify()
     {
-        //$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');
+        $this->sign['verify_set'] = explode(',', $this->sign['verify_set']);
+        if (!in_array(1, $this->sign['verify_set'])) {
+            return;
         }
-        $file = file_get_contents("php://input");
-        if ($file) {
-            $file = json_decode($file, true);
-            if ($file) {
-                $input = array_merge($file, $input);
+        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 status($body)
+    {
+        # 1成功 2失败 3不做任何操作
+        $status = 3;
+        $config = Dever::db('api_notify_code', 'api')->select(array('api_id' => $this->info['id']));
+        if ($config) {
+            foreach ($config as $k => $v) {
+                if (isset($body[$v['key']]) && $body[$v['key']] == $v['value']) {
+                    $status = $v['type'];
+                }
             }
         }
-        $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');
+        return $status;
+    }
+
+    protected function error($msg)
+    {
+        if ($this->info && $this->info['notify_error']) {
+            $temp = explode("\n", $this->info['notify_error']);
+            if (!isset($temp[1])) {
+                $temp[1] = 500;
+            }
+            $this->code($temp[1]);
+            echo $this->info['notify_error'];die;
         }
-        $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');
+        echo $msg;die;
+    }
+
+    protected function code($code)
+    {
+        if ($code == 500) {
+            header("HTTP/1.1 500 Internal Server Error");
+            header("Status: 500 Internal Server Error");
         }
-        $this->load($input, $connect_id, $api_id, $order);
     }
 }

+ 29 - 0
api/Task.php

@@ -0,0 +1,29 @@
+<?php namespace Api\Api;
+use Dever;
+class Task
+{
+    # 定时更新功能
+    public function func()
+    {
+        $where['status'] = 1;
+        $where['cron_time'] = array('>', '0');
+        $data = Dever::db('app_func', 'api')->select($where);
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $account = Dever::db('account', 'api')->find(array('app_id' => $v['app_id']));
+                if ($account) {
+                    Dever::load('account', 'api')->run($account, $v);
+                }
+            }
+        }
+    }
+
+    # 单独执行某个接口
+    # 仅命令行执行
+    public function api_cmd(){}
+    public function api()
+    {
+        $param = Dever::input();
+        return Dever::load('api', 'api')->run($param['api_id'], $param);
+    }
+}

+ 0 - 11
api/Test.php

@@ -1,11 +0,0 @@
-<?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);
-    }
-}

+ 1 - 1
index.php

@@ -2,4 +2,4 @@
 define('DEVER_APP_NAME', 'api');
 define('DEVER_APP_LANG', '接口管理');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
-include(DEVER_APP_PATH . '../../../boot.php');
+include(DEVER_APP_PATH . '../../boot.php');

+ 66 - 0
lib/Account.php

@@ -0,0 +1,66 @@
+<?php namespace Api\Lib;
+use Dever;
+# 官方平台账户
+class Account
+{
+    public function update($db, $data)
+    {
+        if (isset($data['app_platform']) && $data['app_platform']) {
+            $app_platform = $data['app_platform'];
+            if (is_string($app_platform)) {
+                $app_platform = explode(',', $app_platform);
+            }
+            $data['app_id'] = $app_platform[0];
+            $data['platform_id'] = $app_platform[1] ?? 0;
+            if (!$data['platform_id']) {
+                Dever::error('请选择平台');
+            }
+        }
+        return $data;
+    }
+
+    public function run($account, $func, $param = array(), $env = 1, $method = 'run')
+    {
+        if (!is_array($account)) {
+            $account = Dever::db('account', 'api')->find(array('key' => $account));
+        }
+        if (!$account) {
+            Dever::error('账户无效');
+        }
+        if (!is_array($func)) {
+            $func = Dever::db('app_func', 'api')->find(array('app_id' => $account['app_id'], 'key' => $func));
+        }
+        if (!$func) {
+            Dever::error('功能无效');
+        }
+        $api = Dever::load('app', 'api')->getApi($func['id'], $env);
+        if (!$api) {
+            Dever::error('接口无效');
+        }
+        $param['account_project'] = 'api';
+        $param['account_id'] = $account['id'];
+        $result = array();
+        if ($func['type'] == 1) {
+            # 仅执行第一个
+            $result = Dever::load('api', 'api')->$method($api[0], $param);
+            $result['account_id'] = $account['id'];
+            $result['api_id'] = $api[0]['id'];
+        } elseif ($func['type'] == 2) {
+            # 同步执行
+            foreach ($api as $k => $v) {
+                $result = Dever::load('api', 'api')->$method($v, $param);
+                if ($result) {
+                    $param = array_merge($result, $param);
+                }
+            }
+        } elseif ($func['type'] == 3) {
+            # 异步执行
+            $result = true;
+            foreach ($api as $k => $v) {
+                $param['api_id'] = $v['id'];
+                \Dever\Helper\Cmd::run('task.api', $param, 'api');
+            }
+        }
+        return $result;
+    }
+}

+ 7 - 3
lib/Api.php

@@ -25,9 +25,13 @@ class Api extends Platform
     }
 
     # 生成回调
-    protected function createNotify($order_num)
+    protected function createNotify($field)
     {
-        $encode = \Dever\Helper\Str::encode($this->info['id'] . '|' . $order_num);
-        return Dever::url('api/notify.common', array('s' => $encode), false, 'src/channel/api/');
+        $encode = $this->info['id'];
+        if (isset($field['notify'])) {
+            $encode .= '|' . $field['notify'];
+        }
+        $encode = \Dever\Helper\Str::encode($encode);
+        return Dever::url('api/notify.common', array('s' => $encode), false, 'package/api/');
     }
 }

+ 28 - 71
lib/App.php

@@ -20,25 +20,20 @@ class App
         }
     }
 
-    public function getPlatform($key)
+    public function getPlatform($app)
     {
-        $info = Dever::db('app', 'api')->find(array('key' => $key));
-
-        if ($info) {
-            $set['join'] = array
+        $set['join'] = array
+        (
+            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();
+                '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' => $app), $set);
+        return $platform;
     }
 
     public function getSetting($platform_id)
@@ -57,61 +52,23 @@ class App
         return $info['name'];
     }
 
-    public function getApi($app_key, $key, $platform_id, $env = 1)
+    public function getApi($func_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;
+        $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;
+        if ($env) {
+            $where['api.env_type'] = $env;
         }
+        return Dever::db('app_func_work', 'api')->select($where, $set);
     }
 }

+ 16 - 14
lib/Platform.php

@@ -55,23 +55,25 @@ class Platform
 
     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']);
+        if (isset($field['account_project']) && isset($field['account_id'])) {
+            $setting = Dever::db('account_setting', $field['account_project'])->select(array('account_id' => $field['account_id']));
+            if ($setting) {
+                foreach ($setting as $k => $v) {
+                    $info = Dever::db('platform_setting', 'api')->find($v['platform_setting_id']);
+                    if ($info) {
+                        $v['key'] = $info['key'];
+                        if (isset($field[$v['key']])) {
+                            $v['value'] = $field[$v['key']];
+                        }
+                        $field[$v['key']] = $v['value'];
+                    }
                 }
             }
         }
+        $this->field = new Field($field);
+        $this->field->setHost($this->platform['host']);
+        $this->field->setUri($this->info['uri']);
+        $this->field->setNotify($this->createNotify($field));
     }
 
     # 发起请求

+ 17 - 28
lib/Platform/Response.php

@@ -144,24 +144,8 @@ class Response
         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;
-        }
+        $value = new Value($this->field, $this->sign);
+        $result = $value->get($body, $data);
         $this->save($result);
         return $result;
     }
@@ -317,17 +301,22 @@ class Response
                     }
                     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();
+                        if ($id && $k == 'platform_cert') {
+                            # 这个比较特殊
+                            $project = $this->field->account_project;
+                            $account_id = $this->field->account_id;
+                            if ($project && $account_id) {
+                                $cert = array
+                                (
+                                    'account_id' => $account_id,
+                                    'platform_cert_id' => $id,
+                                );
+                                $v1['where'] += $cert;
+                                $v1['data'] += $cert;
+                                $this->saveData($project . '/account_cert', $v1['where'], $v1['data']);
                             }
-                            $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']);
+                        } else {
+                            $this->saveData($k, $v1['where'], $v1['data']);
                         }
                     }
                 }

+ 1 - 1
lib/Platform/Sign.php

@@ -6,7 +6,7 @@ class Sign
     {
         $this->field = $field;
         $this->config = $config;
-        if ($this->config['sort'] == 3) {
+        if (isset($this->config['sort']) && $this->config['sort'] == 3) {
             ksort($this->field->body);
         }
     }

+ 10 - 8
lib/Platform/Ssl.php

@@ -100,15 +100,17 @@ class Ssl
             # 公钥
             $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 = false;
+            #$set = Dever::db('platform_cert', 'api')->find($config['cert_id']);
+            # 获取账户里的cert
+            $project = $this->field->account_project;
+            $account_id = $this->field->account_id;
+            if ($project && $account_id) {
+                $cert = Dever::db('account_cert', $project)->find(array('account_id' => $account_id, 'platform_cert_id' => $config['cert_id']), array('order' => 'edate desc'));
             }
-            # 如果有自定义的cert
-            if ($this->field->cert && isset($this->field->cert[$cert['id']])) {
-                $cert = $this->field->cert[$cert['id']];
+            if (!$cert) {
+                $config['cert'] = false;
+                return $config;
             }
             $this->field->setNumber($cert['number']);
             if ($config['cert_type'] == 2) {

+ 136 - 0
lib/Platform/Value.php

@@ -0,0 +1,136 @@
+<?php namespace Api\Lib\Platform;
+use Dever;
+class Value
+{
+    public function __construct($field, $sign)
+    {
+        $this->field = $field;
+        $this->sign = $sign;
+    }
+
+    public function get($config, $data)
+    {
+        $result = array();
+        if ($config) {
+            foreach ($data as $k => $v) {
+                $this->field->set($k, $v);
+            }
+            $source = array();
+            $dest = array();
+            foreach ($config 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;
+        }
+        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;
+    }
+}

+ 19 - 0
lib/Util.php

@@ -0,0 +1,19 @@
+<?php namespace Api\Lib;
+use Dever;
+class Util
+{
+    # 生成订单号
+    public function createNumber($prefix, $table)
+    {
+        $number = \Dever\Helper\Str::order($prefix);
+        $state = Dever::db($table)->find(array('number' => $number));
+        if (!$state) {
+            return $number;
+        } else {
+            return $this->createNumber($prefix, $table);
+        }
+    }
+
+    # 获取openid
+    
+}

+ 74 - 0
manage/account.php

@@ -0,0 +1,74 @@
+<?php
+return array
+(
+    'list' => array
+    (
+        'field'      => array
+        (
+            'id',
+            'name',
+            'key',
+            'app_id' => array
+            (
+                'show' => 'Dever::call("api/app-find", "{app_id}")["name"]',
+            ),
+            'platform_id' => array
+            (
+                'show' => 'Dever::call("api/platform-find", "{platform_id}")["name"]',
+            ),
+            'cdate',
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', 'name,key,app_platform'),
+        ),
+        'data_button' => array
+        (
+            '设置' => array('edit', 'name,key,api/account_setting'),
+            '证书' => array('route', array
+            (
+                'path' => 'api_manage/account_cert',
+                'param' => array
+                (
+                    'set' => array('account_id' => 'id', 'menu' => 'api_manage/account', 'parent' => 'api_manage/account'),
+                ),
+            )),
+        ),
+        'search' => array
+        (
+            'name',
+            'key',
+            'app_platform' => array
+            (
+                'type' => 'cascader',
+                'remote'    => 'api/manage.getAppPlatform',
+            ),
+        ),
+    ),
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name' => array
+            (
+                'rules' => true,
+            ),
+            'key',
+            'app_platform' => array
+            (
+                'desc' => '【提交后不能更改】',
+                'rules' => true,
+                'type' => 'cascader',
+                'remote'    => 'api/manage.getAppPlatform',
+                'remote_default' => false,
+            ),
+            'api/account_setting' => array
+            (
+                'name' => '参数配置',
+                'where'  => array('account_id' => 'id'),
+            ),
+        ),
+        'check' => 'key',
+        'start' => array('manage/common.updateKey', 'api/account.update'),
+    ),
+);

+ 66 - 0
manage/account_cert.php

@@ -0,0 +1,66 @@
+<?php
+$account_id = Dever::input('set')['account_id'] ?? 0;
+if (!$account_id) {
+    $account_id = Dever::input('field')['account_id'] ?? 0;
+}
+$account = Dever::db('account', 'api')->find($account_id);
+return array
+(
+    'list' => array
+    (
+        'where' => array('account_id' => $account_id),
+        'field'      => array
+        (
+            'id',
+            'platform_cert_id' => array
+            (
+                'show' => 'Dever::call("api/app.getCertName", "{platform_cert_id}")',
+            ),
+            'number',
+            'cdate',
+        ),
+        'data_button' => array
+        (
+            '编辑' => array('fastedit', array('account_id' => $account_id)),
+        ),
+        'button' => array
+        (
+            '新增' => array('fastadd', array('account_id' => $account_id)),
+        ),
+        'search' => array
+        (
+            'account_id' => 'hidden',
+            'number',
+        ),
+    ),
+    'update' => array
+    (
+        'desc' => '有的证书会自动同步,无需手动添加,如微信支付的平台证书',
+        'field'    => array
+        (
+            'account_id' => 'hidden',
+            'platform_cert_id' => array
+            (
+                'rules' => true,
+                'type' => 'select',
+                'option'     => 'Dever::call("api/app.getCert", '.$account['platform_id'].')',
+                //'remote' => 'api/manage.getCertName',
+                //'remote_default' => false,
+            ),
+            'number' => array
+            (
+                'rules' => true,
+            ),
+            'public' => array
+            (
+                'rules' => true,
+                'type' => 'textarea',
+            ),
+            'private' => array
+            (
+                'rules' => true,
+                'type' => 'textarea',
+            ),
+        ),
+    ),
+);

+ 27 - 0
manage/account_setting.php

@@ -0,0 +1,27 @@
+<?php
+$account_id = Dever::input('set')['account_id'] ?? 0;
+if (!$account_id) {
+    $account_id = Dever::input('field')['account_id'] ?? 0;
+}
+$account = Dever::db('account', 'api')->find($account_id);
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'platform_setting_id' => array
+            (
+                'type' => 'select',
+                'option'     => 'Dever::call("api/app.getSetting", '.$account['platform_id'].')',
+                //'remote' => 'api/manage.getSettingName',
+                //'remote_default' => false,
+            ),
+            'value' => array
+            (
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+            ),
+        ),
+    ),
+);

+ 30 - 21
manage/api.php

@@ -1,19 +1,18 @@
 <?php
+$platform_id = Dever::input('set')['platform_id'] ?? 0;
 $platform = include('platform.php');
 $config = array
 (
     'list' => array
     (
+        'where' => array('platform_id' => $platform_id),
         'field'      => array
         (
-            'id',
+            //'id',
+            'sort' => 'input',
             'name',
             'uri',
             'env_type',
-            'cate' => array
-            (
-                'show' => 'Dever::call("content/cate.getInfo", array("api", "{cate}"))',
-            ),
             'platform_id',
             'status' => array
             (
@@ -30,15 +29,14 @@ $config = array
         ),
         'button' => array
         (
-            '新增' => array('fastadd', 'name,env_type,cate,platform_id,uri'),
+            '新增' => array('fastadd', array('platform_id' => $platform_id, 'field' => 'name,env_type,platform_id,uri')),
         ),
         'search' => array
         (
-            'platform_id',
-            'cate' => array
+            'platform_id' => array
             (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("content/cate.getList", array("api"))',
+                'type' => 'hidden',
+                'default' => $platform_id,
             ),
             'name',
             'uri',
@@ -48,27 +46,21 @@ $config = array
     'update' => array
     (
         'desc' => $platform['update']['desc'],
-        'end' => 'content/info.update',
         'tab' => array
         (
-            '基本设置' => 'name,env_type,cate,sign_col,uri,api/api_uri',
+            '基本设置' => 'name,env_type,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',
+            '回调设置' => 'notify_type,notify_sign_col,notify_success,notify_error,api/api_notify_body,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' => '【提交后不能更改】',
@@ -147,15 +139,24 @@ $config = array
             ),
             'notify_success' => array
             (
-                'desc' => '填写回调成功后,返回给渠道的信息',
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+                'desc' => '回调成功后,返回给上游的信息',
             ),
             'notify_error' => array
             (
-                'desc' => '填写回调失败后,返回给渠道的信息,如果填写500,则会返回HTTP Status Code 500,默认返回HTTP Status Code 200',
+                'type' => 'textarea',
+                'autosize' => array('minRows' => 2),
+                'desc' => '回调失败后,返回给上游的信息,默认应答状态码为500,可以换行输入应答状态码',
             ),
             'notify_sign_col' => array
             (
-                'desc' => '回调签名参数,不填写则使用接口的回调签名参数',
+                'desc' => '填写参与回调签名的参数,不填写则使用平台设置的签名参数',
+            ),
+            'api/api_notify_body' => array
+            (
+                'name' => '回调参数设置',
+                'where'  => array('api_id' => 'id'),
             ),
             'api/api_notify_code' => array
             (
@@ -213,10 +214,18 @@ $config = array
             (
                 'notify_type' => 1,
             ),
+            'api/api_notify_body' => array
+            (
+                'notify_type' => 1,
+            ),
             'api/api_notify_code' => array
             (
                 'notify_type' => 1,
             ),
+            'notify_sign_col' => array
+            (
+                'notify_type' => 1,
+            ),
             /*
             'api/api_notify' => array
             (

+ 2 - 0
manage/api_notify_body.php

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

+ 1 - 8
manage/app.php

@@ -5,8 +5,8 @@ return array
     (
         'field'      => array
         (
+            'id',
             'name',
-            'key',
             'sort' => 'input',
             'status' => array
             (
@@ -36,7 +36,6 @@ return array
         'search'    => array
         (
             'name',
-            'key',
             'status',
         ),
     ),
@@ -48,17 +47,11 @@ return array
             (
                 'rules' => true,
             ),
-            'key' => array
-            (
-                'desc' => '如果为空,将自动按照名称拼音生成',
-            ),
             'desc' => 'textarea',
             'status' => array
             (
                 'type' => 'radio',
             ),
         ),
-        'check' => 'key',
-        'start' => 'content/cate.updateKey',
     ),
 );

+ 7 - 2
manage/app_func.php

@@ -41,8 +41,8 @@ return array
         'end' => 'api/app.update',
         'tab' => array
         (
-            '基本设置' => 'app_id,name,key,type,desc,cron_time',
-            '接口设置' => 'api/app_func_work',
+            '基本设置' => 'app_id,name,key,desc,cron_date,cron_time',
+            '接口设置' => 'type,api/app_func_work',
         ),
         'field'    => array
         (
@@ -58,6 +58,11 @@ return array
             (
                 'type' => 'radio',
             ),
+            'cron_date' => array
+            (
+                'type' => 'date',
+                'date_type' => 'datetime',
+            ),
             'cron_time' => array
             (
                 'type' => 'text',

+ 3 - 4
manage/app_func_work.php

@@ -5,12 +5,11 @@ return array
     (
         'field'    => array
         (
-            'cate' => array
+            'platform_id' => array
             (
                 'rules' => true,
-                'type' => 'cascader',
-                'option'    => 'Dever::call("content/cate.getList", array("api"))',
-                'remote'    => 'api/cate.getApi',
+                'type' => 'select',
+                'remote'    => 'api/manage.getApi',
                 # 无需默认值
                 'remote_default' => false,
             ),

+ 0 - 3
manage/cate.php

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

+ 32 - 22
manage/core.php

@@ -5,43 +5,36 @@ return array
     (
         'connect' => array
         (
-            'name' => '接',
+            'name' => '接',
             'icon' => 'contacts-line',
             'sort' => '10',
             'module' => 'platform',
-            'app' => 'sector',
+            'app' => 'api',
         ),
 
         'api_manage' => array
         (
             'parent' => 'connect',
-            'name' => '接口',
+            'name' => '核心设置',
             'icon' => 'compasses-line',
             'sort' => '1',
         ),
 
-        'api' => array
+        'platform' => array
         (
             'parent'    => 'api_manage',
-            'name'      => '接口管理',
-            'icon'      => 'amazon-line',
-            'sort'      => '1',
+            'name'      => '平台管理',
+            'icon'      => 'tools-line',
+            'sort'      => '3',
         ),
 
-        'cate' => array
+        'platform_api' => array
         (
             'parent'    => 'api_manage',
-            'name'      => '分类管理',
-            'icon'      => 'folder-2-line',
-            'sort'      => '2',
-        ),
-
-        'platform' => array
-        (
-            'parent'    => 'api_manage',
-            'name'      => '平台管理',
+            'name'      => '平台接口管理',
             'icon'      => 'tools-line',
-            'sort'      => '3',
+            'sort'      => '4',
+            'show'      => 3,
         ),
 
         'platform_cert' => array
@@ -49,7 +42,7 @@ return array
             'parent'    => 'api_manage',
             'name'      => '平台证书管理',
             'icon'      => 'tools-line',
-            'sort'      => '4',
+            'sort'      => '5',
             'show'      => 3,
         ),
 
@@ -58,7 +51,7 @@ return array
             'parent'    => 'api_manage',
             'name'      => '平台加密管理',
             'icon'      => 'tools-line',
-            'sort'      => '5',
+            'sort'      => '6',
             'show'      => 3,
         ),
 
@@ -67,7 +60,7 @@ return array
             'parent'    => 'api_manage',
             'name'      => '应用管理',
             'icon'      => 'file-list-2-line',
-            'sort'      => '6',
+            'sort'      => '7',
         ),
 
         'app_func' => array
@@ -75,7 +68,24 @@ return array
             'parent'    => 'api_manage',
             'name'      => '应用功能管理',
             'icon'      => 'file-list-2-line',
-            'sort'      => '7',
+            'sort'      => '8',
+            'show'      => 3,
+        ),
+
+        'account' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '账户管理',
+            'icon'      => 'contacts-line',
+            'sort'      => '9',
+        ),
+
+        'account_cert' => array
+        (
+            'parent'    => 'api_manage',
+            'name'      => '账户证书',
+            'icon'      => 'contacts-line',
+            'sort'      => '10',
             'show'      => 3,
         ),
     ),

+ 8 - 0
manage/platform.php

@@ -30,6 +30,14 @@ $config = array
                     'set' => array('platform_id' => 'id', 'menu' => 'api_manage/platform', 'parent' => 'api_manage/platform'),
                 ),
             )),
+            '接口' => array('route', array
+            (
+                'path' => 'api_manage/api',
+                'param' => array
+                (
+                    'set' => array('platform_id' => 'id', 'menu' => 'api_manage/platform', 'parent' => 'api_manage/platform'),
+                ),
+            )),
         ),
         'button' => array
         (

+ 0 - 34
manage/platform_cert.php

@@ -10,7 +10,6 @@ return array
             'id',
             'name',
             'type',
-            'number',
             'cdate',
         ),
         'data_button' => array
@@ -25,7 +24,6 @@ return array
         (
             'platform_id' => 'hidden',
             'name',
-            'number',
         ),
     ),
     'update' => array
@@ -38,38 +36,6 @@ return 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',
-            ),*/
         ),
     ),
 );

+ 1 - 5
manage/platform_setting.php

@@ -15,11 +15,7 @@ return array
                 'type' => 'textarea',
                 'autosize' => array('minRows' => 2),
             ),
-            'value' => array
-            (
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 2),
-            ),
         ),
+        'drag' => 'sort',
     ),
 );

+ 49 - 0
table/account.php

@@ -0,0 +1,49 @@
+<?php
+return array
+(
+    'name' => '账户管理',
+    'struct' => array
+    (
+        'name'      => array
+        (
+            'type'      => 'varchar(60)',
+            'name'      => '账户名称',
+        ),
+
+        'key'       => array
+        (
+            'type'      => 'varchar(60)',
+            'name'      => '账户标识',
+        ),
+
+        'app_platform'       => array
+        (
+            'type'      => 'varchar(500)',
+            'name'      => '应用与平台',
+        ),
+
+        'app_id'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '应用',
+        ),
+
+        'platform_id'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '平台',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '上架',
+                2 => '下架',
+            ),
+        ),
+    ),
+);

+ 45 - 0
table/account_cert.php

@@ -0,0 +1,45 @@
+<?php
+
+return array
+(
+    'name' => '账户证书设置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'platform_cert_id' => array
+        (
+            'name'      => '证书名',
+            'type'      => 'int(11)',
+        ),
+
+        'number' => array
+        (
+            'name'      => '证书序列号',
+            'type'      => 'varchar(800)',
+        ),
+
+        'public' => array
+        (
+            'name'      => '公钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'private' => array
+        (
+            'name'      => '私钥内容',
+            'type'      => 'varchar(3000)',
+        ),
+
+        'edate' => array
+        (
+            'name'      => '过期时间',
+            'type'      => 'int(11)',
+        ),
+    ),
+);

+ 27 - 0
table/account_setting.php

@@ -0,0 +1,27 @@
+<?php
+
+return array
+(
+    'name' => '账户设置',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'platform_setting_id' => array
+        (
+            'name'      => '参数描述',
+            'type'      => 'int(11)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '参数值',
+            'type'      => 'varchar(3000)',
+        ),
+    ),
+);

+ 11 - 21
table/api.php

@@ -2,6 +2,7 @@
 return array
 (
     'name' => '接口配置',
+    'order' => 'sort asc',
     'struct' => array
     (
         'platform_id' => array
@@ -17,24 +18,6 @@ return array
             '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'      => '接口地址',
@@ -87,13 +70,13 @@ return array
 
         'notify_success' => array
         (
-            'name'      => '回调成功响应',
+            'name'      => '应答成功报文',
             'type'      => 'varchar(500)',
         ),
 
         'notify_error' => array
         (
-            'name'      => '回调失败响应',
+            'name'      => '应答失败报文',
             'type'      => 'varchar(500)',
         ),
 
@@ -127,7 +110,7 @@ return array
                 3 => 'jsapi',
                 4 => 'app',
                 5 => '小程序',
-                6 => '二维码',
+                6 => 'pc',
             ),
         ),
 
@@ -142,5 +125,12 @@ return array
                 2 => '不展示',
             ),
         ),
+
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ),
     ),
 );

+ 13 - 0
table/api_notify_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;

+ 2 - 1
table/api_notify_code.php

@@ -2,6 +2,7 @@
 return array
 (
     'name' => '回调参数配置',
+    'order' => 'id asc',
     'struct' => array
     (
         'api_id' => array
@@ -31,7 +32,7 @@ return array
             (
                 1 => '成功',
                 2 => '失败',
-                3 => '其他',
+                3 => '无状态',
             ),
         ),
     ),

+ 1 - 6
table/app.php

@@ -11,12 +11,6 @@ return array
             'type'      => 'varchar(32)',
         ),
 
-        'key' => array
-        (
-            'name'      => '应用标识',
-            'type'      => 'varchar(80)',
-        ),
-
         'desc' => array
         (
             'name'      => '应用描述',
@@ -34,6 +28,7 @@ return array
                 2 => '下架',
             ),
         ),
+        
         'sort' => array
         (
             'name'      => '排序',

+ 1 - 1
table/app_func.php

@@ -31,7 +31,7 @@ return array
 
         'type' => array
         (
-            'name'      => '类型',
+            'name'      => '执行方式',
             'type'      => 'tinyint(1)',
             'default'   => 1,
             'value'     => array

+ 4 - 3
table/app_func_work.php

@@ -11,10 +11,11 @@ return array
             'type'      => 'int(11)',
         ),
 
-        'cate' => array
+        'platform_id' => array
         (
-            'name'      => '分类',
-            'type'      => 'varchar(800)',
+            'name'      => '平台',
+            'type'      => 'int(11)',
+            'value'     => 'api/platform',
         ),
 
         'api_id' => array

+ 0 - 4
table/cate.php

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

+ 0 - 24
table/platform_cert.php

@@ -22,29 +22,5 @@ return 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)',
-        ),
     ),
 );

+ 5 - 4
table/platform_setting.php

@@ -2,7 +2,7 @@
 return array
 (
     'name' => '平台配置',
-    'order' => 'id asc',
+    'order' => 'sort asc, id asc',
     'struct' => array
     (
         'platform_id' => array
@@ -23,10 +23,11 @@ return array
             'type'      => 'varchar(800)',
         ),
 
-        'value' => array
+        'sort' => array
         (
-            'name'      => '参数值',
-            'type'      => 'varchar(800)',
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
         ),
     ),
 );