rabin 7 ماه پیش
والد
کامیت
6c3dc26bae
84فایلهای تغییر یافته به همراه560 افزوده شده و 3971 حذف شده
  1. 0 23
      src/channel/api/api/Manage.php
  2. 0 208
      src/channel/api/api/Notify.php
  3. 0 11
      src/channel/api/api/Test.php
  4. 0 5
      src/channel/api/index.php
  5. 0 23
      src/channel/api/lib/Api.php
  6. 0 10
      src/channel/api/lib/Cert.php
  7. 0 547
      src/channel/api/lib/Platform - 副本.php
  8. 0 159
      src/channel/api/lib/Platform.php
  9. 0 137
      src/channel/api/lib/Platform/Field.php
  10. 0 49
      src/channel/api/lib/Platform/Request.php
  11. 0 314
      src/channel/api/lib/Platform/Response.php
  12. 0 145
      src/channel/api/lib/Platform/Sign.php
  13. 0 118
      src/channel/api/lib/Platform/Ssl.php
  14. 0 37
      src/channel/api/lib/Spec.php
  15. 0 244
      src/channel/api/manage/api.php
  16. 0 13
      src/channel/api/manage/api_notify_code.php
  17. 0 2
      src/channel/api/manage/api_request_body.php
  18. 0 2
      src/channel/api/manage/api_request_header.php
  19. 0 35
      src/channel/api/manage/api_request_input.php
  20. 0 26
      src/channel/api/manage/api_request_output.php
  21. 0 21
      src/channel/api/manage/api_response.php
  22. 0 2
      src/channel/api/manage/api_response_body.php
  23. 0 2
      src/channel/api/manage/api_response_header.php
  24. 0 22
      src/channel/api/manage/api_save.php
  25. 0 14
      src/channel/api/manage/api_uri.php
  26. 0 3
      src/channel/api/manage/cate.php
  27. 0 56
      src/channel/api/manage/core.php
  28. 0 175
      src/channel/api/manage/platform.php
  29. 0 75
      src/channel/api/manage/platform_cert.php
  30. 0 12
      src/channel/api/manage/platform_convert.php
  31. 0 21
      src/channel/api/manage/platform_request_body.php
  32. 0 2
      src/channel/api/manage/platform_request_header.php
  33. 0 2
      src/channel/api/manage/platform_response_body.php
  34. 0 12
      src/channel/api/manage/platform_response_code.php
  35. 0 2
      src/channel/api/manage/platform_response_header.php
  36. 0 25
      src/channel/api/manage/platform_setting.php
  37. 0 143
      src/channel/api/manage/platform_ssl.php
  38. 0 30
      src/channel/api/manage/sku.php
  39. 0 142
      src/channel/api/table/api.php
  40. 0 32
      src/channel/api/table/api_log.php
  41. 0 38
      src/channel/api/table/api_notify_code.php
  42. 0 13
      src/channel/api/table/api_request_body.php
  43. 0 13
      src/channel/api/table/api_request_header.php
  44. 0 70
      src/channel/api/table/api_request_input.php
  45. 0 39
      src/channel/api/table/api_request_output.php
  46. 0 14
      src/channel/api/table/api_response.php
  47. 0 14
      src/channel/api/table/api_response_body.php
  48. 0 14
      src/channel/api/table/api_response_header.php
  49. 0 44
      src/channel/api/table/api_save.php
  50. 0 48
      src/channel/api/table/api_uri.php
  51. 0 4
      src/channel/api/table/cate.php
  52. 0 224
      src/channel/api/table/platform.php
  53. 0 44
      src/channel/api/table/platform_cert.php
  54. 0 25
      src/channel/api/table/platform_convert.php
  55. 0 52
      src/channel/api/table/platform_request_body.php
  56. 0 4
      src/channel/api/table/platform_request_header.php
  57. 0 5
      src/channel/api/table/platform_response_body.php
  58. 0 31
      src/channel/api/table/platform_response_code.php
  59. 0 5
      src/channel/api/table/platform_response_header.php
  60. 0 32
      src/channel/api/table/platform_setting.php
  61. 0 134
      src/channel/api/table/platform_ssl.php
  62. 0 44
      src/channel/api/table/sku.php
  63. 0 32
      src/channel/api/table/spec.php
  64. 0 47
      src/channel/api/table/spec_value.php
  65. 17 22
      src/place/api/Data.php
  66. 25 0
      src/place/api/Tool.php
  67. 12 6
      src/place/lib/Core.php
  68. 25 0
      src/place/table/openid.php
  69. 8 6
      src/resource/content/api/Data.php
  70. 39 0
      src/resource/content/api/Member.php
  71. 24 0
      src/resource/content/api/Value.php
  72. 50 26
      src/resource/content/lib/Cate.php
  73. 56 9
      src/resource/content/lib/Info.php
  74. 141 0
      src/resource/content/lib/Value.php
  75. 1 1
      src/resource/content/manage/cate.php
  76. 2 2
      src/resource/content/manage/info.php
  77. 2 2
      src/resource/content/table/cate.php
  78. 32 0
      src/resource/content/table/collect.php
  79. 33 0
      src/resource/content/table/down.php
  80. 1 1
      src/resource/content/table/info.php
  81. 87 0
      src/resource/content/table/order.php
  82. 3 3
      src/resource/content/table/price.php
  83. 1 1
      src/resource/func/table/info.php
  84. 1 1
      src/resource/goods/table/info.php

+ 0 - 23
src/channel/api/api/Manage.php

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

+ 0 - 208
src/channel/api/api/Notify.php

@@ -1,208 +0,0 @@
-<?php namespace Api\Api;
-use Dever;
-use Api\Lib\Func\Api;
-class Notify extends Api
-{
-    public function common()
-    {
-        //$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);
-    }
-}

+ 0 - 11
src/channel/api/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);
-    }
-}

+ 0 - 5
src/channel/api/index.php

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

+ 0 - 23
src/channel/api/lib/Api.php

@@ -1,23 +0,0 @@
-<?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();
-    }
-
-    # 生成回调
-    protected function createNotify($order_num)
-    {
-        $encode = \Dever\Helper\Str::encode($this->info['id'] . '|' . $order_num);
-        return Dever::url('api/notify.common', array('s' => $encode));
-    }
-}

+ 0 - 10
src/channel/api/lib/Cert.php

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

+ 0 - 547
src/channel/api/lib/Platform - 副本.php

@@ -1,547 +0,0 @@
-<?php namespace Api\Lib;
-use Dever;
-class Platform
-{
-    protected $platform;
-    protected $info;
-    protected $field;
-
-    # 设置基本信息
-    protected function setting($id, $field = array())
-    {
-        $this->info = Dever::db($this->type, 'api')->find($id);
-        if (!$this->info) {
-            return false;
-        }
-
-        $this->field = $field;
-        $this->platform = Dever::db('platform', 'api')->find($this->info['platform_id']);
-        if (!$this->platform) {
-            return false;
-        }
-        $this->field['host'] = $this->platform['host'];
-        $this->field['uri'] = $this->info['uri'];
-        $this->field['time'] = time();
-        $this->field['timestamp'] = \Dever\Helper\Secure::timestamp();
-        $this->field['nonce'] = \Dever\Helper\Secure::nonce();
-        $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']];
-                }
-                $this->field[$v['key']] = $v['value'];
-            }
-        }
-        return $this;
-    }
-
-    # 发起请求
-    protected function curl($url = false)
-    {
-        if (!$url) {
-            $url = $this->url();
-        }
-        $header = $body = array();
-        $method = 'get';
-        $json = false;
-        if ($this->info['method'] == -1) {
-            $this->info['method'] = $this->platform['method'];
-            $this->info['post_method'] = $this->platform['post_method'];
-        }
-        if ($this->info['post_method'] == 2) {
-            $method = 'file';
-        } elseif ($this->info['method'] == 2) {
-            $method = 'post';
-        }
-        $this->field['method'] = $method;
-        if ($this->info['post_method'] == 3) {
-            $json = true;
-        }
-        # 标准请求体
-        $this->request($body, 'platform_request_body', array('platform_id' => $this->platform['id']));
-        if (method_exists($this, 'requestBody')) {
-            $this->requestBody($body);
-        }
-        $this->field['body'] = $body;
-        $this->field['body_json'] = $body ? Dever::json_encode($body) : '';
-        $sign = '';
-        $this->sign($body, $sign);
-        # 标准请求头
-        $this->request($header, 'platform_request_header', array('platform_id' => $this->platform['id']));
-        if (method_exists($this, 'requestHeader')) {
-            $this->requestHeader($header);
-        }
-        $this->field['header'] = $header;
-        
-        $response = Dever::curl($url, $body, $method, $json, $header)->result();
-        $test = Dever::input('test');
-        if ($test && $test == 1) {
-            $result = array
-            (
-                'url' => $url,
-                'header' => $header,
-                'method' => $method,
-                'json' => $json,
-                'sign' => $sign,
-                'body' => $body,
-                'response' => $response,
-            );
-            echo Dever::json_encode($result);die;
-        }
-        $response = $this->response($response);
-        $response['request'] = $body;
-        return $response;
-    }
-
-    # 处理url
-    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->value(array(), $v['key'], $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['uri'] = $this->info['uri'];
-        return $this->platform['host'] . $this->info['uri'];
-    }
-
-    # 获取请求参数
-    protected function request(&$data, $table, $where)
-    {
-        $request = Dever::db($table, 'api')->select($where);
-        if ($request) {
-            foreach ($request as $k => $v) {
-                $value = $this->value($data, $v['key'], $v['value'], $v['type']);
-                if ($value) {
-                    $data[$v['key']] = $value;
-                    $this->field[$v['key']] = $value;
-                }
-            }
-        }
-    }
-
-    # 数据响应格式处理
-    protected function response($response)
-    {
-        if ($this->platform['response_type'] == 1) {
-            $response = $this->filter($response);
-            return array
-            (
-                'status' => 1,
-                'msg' => 'ok',
-                'response' => false,
-                'request' => array(),
-                'data' => $response,
-            );
-        }
-        if ($this->platform['response_type'] == 2) {
-            $response = Dever::json_decode($response);
-        } elseif ($this->platform['response_type'] == 3) {
-            $response = (array) simplexml_load_string($response);
-        } else {
-            if (strstr($response, ',')) {
-                $response = explode(',', $response);
-            } elseif (strstr($response, ' ')) {
-                $response = explode(' ', $response);
-            } elseif (strstr($response, '|')) {
-                $response = explode('|', $response);
-            } else {
-                $response = explode("\n", $response);
-            }
-        }
-        $msg = 'no';
-        $status = 2;
-        if ($this->platform['response_code'] && isset($response[$this->platform['response_code']])) {
-            $code = $response[$this->platform['response_code']];
-            $code = Dever::db('response_code', 'api')->find(array('platform_id' => $this->platform['id'], 'value' => $code));
-            if ($code && $code['type'] == 1) {
-                $status = 1;
-            }
-        }
-        if ($this->platform['response_msg'] && isset($response[$this->platform['response_msg']])) {
-            $msg = $this->platform['response_msg'];
-        }
-        
-        $data = $response;
-        if ($this->platform['response_data']) {
-            if (strstr($this->platform['response_data'], ',')) {
-                $temp = explode(',', $this->platform['response_data']);
-                foreach ($temp as $k => $v) {
-                    if (isset($response[$v])) {
-                        $data = $response[$v];
-                        break;
-                    }
-                }
-            } elseif (strstr($this->platform['response_data'], '.')) {
-                $temp = explode('.', $this->platform['response_data']);
-                $data = isset($response[$temp[0]][$temp[1]]) ? $response[$temp[0]][$temp[1]] : (isset($response[$temp[0]]) ? $response[$temp[0]] : false);
-            } else {
-                $data = $response[$this->platform['response_data']] ?? $response;
-            }
-        }
-        
-        if ($data) {
-            if (method_exists($this, 'responseHandle')) {
-                $this->responseHandle($data);
-            }
-        }
-        return array
-        (
-            'status' => $status,
-            'msg' => $msg,
-            'response' => $response,
-            'request' => array(),
-            'data' => $data,
-        );
-    }
-
-    protected function sign(&$body, &$string)
-    {
-        if ($this->platform['sign_method'] == -1) {
-            return;
-        }
-        if ($this->platform['sign_sort'] == 3) {
-            ksort($body);
-        }
-        $this->field['sign_name'] = $this->platform['sign_name'];
-        $sign = array();
-        if ($this->info['sign_col']) {
-            $this->col($this->info['sign_col'], $body, $sign);
-        } elseif ($this->platform['sign_col']) {
-            $this->col($this->platform['sign_col'], $body, $sign);
-        } else {
-            $sign = $body;
-        }
-
-        if ($this->platform['sign_sort'] == 2) {
-            ksort($sign);
-        }
-        $split = $this->platform['sign_split'];
-        if (strstr($split, '\\')) {
-            $split = preg_replace_callback(
-                '/\\\\([nrtf])/', // 匹配 \n, \r, \t, \f 等特殊字符
-                function ($matches) {
-                    $map = [
-                        'n' => "\n",
-                        'r' => "\r",
-                        't' => "\t",
-                        'f' => "\f"
-                    ];
-                    return $map[$matches[1]]; // 直接从映射中获取替换值
-                },
-                $split
-            );
-        }
-
-        $string = '';
-        foreach ($sign as $k => $v) {
-            if ($this->platform['sign_empty'] == 2 && !$v) {
-                continue;
-            }
-            if ($this->platform['sign_encode'] == 2 && strstr($v, 'http')) {
-                $v = urlencode($v);
-                if (isset($body[$k])) {
-                    $body[$k] = $v;
-                }
-            }
-            if ($this->platform['sign_type'] == 1) {
-                $string .= $v;
-            } elseif ($this->platform['sign_type'] == 2) {
-                $string .= $k . '=' . $v;
-            } elseif ($this->platform['sign_type'] == 3) {
-                $string .= $k . $v;
-            }
-            
-            $string .= "{$split}";
-        }
-
-        $sign = rtrim($string, $this->platform['sign_split']);
-        if ($this->platform['sign_method'] == -2) {
-            $sign = md5($sign);
-        } elseif ($this->platform['sign_method'] == -3) {
-            $sign = hash("sha256", $sign);
-        } elseif ($this->platform['sign_method'] == -4) {
-            $sign = sha1($sign);
-        } else {
-            $sign = $this->encrypt($this->platform['sign_method'], $sign);
-        }
-
-        if ($this->platform['sign_after'] == 2) {
-            $sign = strtoupper($sign);
-        } elseif ($this->platform['sign_after'] == 2) {
-            $sign = strtolower($sign);
-        }
-        if ($this->platform['sign_name']) {
-            $body[$this->platform['sign_name']] = $sign;
-        }
-        $this->field['sign'] = $sign;
-        return $sign;
-    }
-
-    protected function col($col, $body, &$sign)
-    {
-        $col = explode('+', $col);
-        foreach ($col as $k => $v) {
-            if ($v == 'body') {
-                $sign = array_merge($body, $sign);
-            } else {
-                $k = $v;
-                if (strstr($v, '=')) {
-                    $t = explode('=', $v);
-                    $v = $t[1];
-                    $k = $t[0];
-                }
-                $sign[$k] = $this->value($body, $v, $v, 1);
-            }
-        }
-    }
-
-    protected function value($data, $key, $value, $type = 1)
-    {
-        $value = trim($value);
-        if ($this->field && isset($this->field[$value])) {
-            $value = $this->field[$value];
-        } elseif ($value == 'notify') {
-            $value = $this->createNotify($this->field['order_num'] ?? '');
-        } elseif ($value == 'token') {
-            $value = $this->token(1, 'token');
-        } elseif ($value == 'ticket') {
-            $value = $this->token(2, 'ticket');
-        } elseif (strstr($value, 'key=') && strstr($value, '&')) {
-            parse_str($value, $temp);
-            $k = $temp['key'];
-            unset($temp['key']);
-            if (isset($this->field[$k]) && isset($temp[$this->field[$k]])) {
-                $value = $temp[$this->field[$k]];
-            }
-        } elseif ($a = strstr($value, '{') || strstr($value, '(')) {
-            if ($a) {
-                $field = $this->field;
-                $func = function ($r) use($field) {
-                    return $this->value($field, $r[1], $r[1]);
-                };
-                $value = preg_replace_callback('/{(.*?)}/', $func, $value);
-            }
-            $value = '$value = '.$value.';';
-            eval($value);
-        }
-
-        if (!$value) {
-            $key = trim($key);
-            return Dever::input($key);
-        }
-        if (is_array($value)) {
-            $value = Dever::json_encode($value);
-        }
-        if ($type == 1 || $type == 100) {
-            $value = (string) $value;
-        } elseif ($type == 2 || $type == 200) {
-            $value = (float) $value;
-        } elseif ($type == 3 && is_array($value)) {
-            $value = Dever::json_encode($value);
-        } elseif ($type == 4) {
-            $value = $this->encrypt($value);
-        } elseif ($type == 300 && is_array($value)) {
-            $value = Dever::json_decode($value);
-        } elseif ($type == 400) {
-            $value = $this->decrypt($value);
-        }
-
-        return $value;
-    }
-
-    protected function service($data)
-    {
-        # 转换处理
-        $convert = Dever::db('convert', 'api')->select(array('platform_id' => $this->platform['id']));
-
-        $param = array();
-        if ($convert && is_array($data)) {
-            if (isset($data[0])) {
-                foreach ($data as $k1 => $v1) {
-                    foreach ($convert as $k => $v) {
-                        if (isset($data[$k1][$v['before']])) {
-                            $param[$k1][$v['after']] = $data[$k1][$v['before']];
-                        }
-                    }
-                }
-            } else {
-                foreach ($convert as $k => $v) {
-                    if (isset($data[$v['before']])) {
-                        $param[$v['after']] = $data[$v['before']];
-                    }
-                }
-            }
-        } else {
-            $param = $data;
-        }
-
-        # 具体业务处理,这里先不做
-        //Dever::load('channel/lib/service')->act($this->channel['id'], $this->info['service_id'], $this->type, $this->info['id'], $param);
-        return $param;
-    }
-
-    protected function token($id = 1, $type = 'token')
-    {
-        return '';
-        $db = Dever::db($type, 'api');
-        $data['platform_id'] = $connect['id'];
-        $data['api_id'] = $api['id'];
-        $info = $db->find($data);
-        if ($info && time() - $info['mdate'] >= $info['expires']) {
-            
-        } elseif ($info) {
-            return $info['value'];
-        }
-        $result = $this->init()->curl();
-        if (isset($result[$type])) {
-            $data['value'] = $result[$type];
-            $data['expires'] = '7200';
-            if (isset($result['expires'])) {
-                $data['expires'] = $result['expires'];
-            }
-            if ($info) {
-                $data['where_id'] = $info['id'];
-                $db->update($data);
-            } else {
-                $db->insert($data);
-            }
-            return $result[$type];
-        }
-        return '';
-    }
-
-    protected function encrypt($ssl_id, $value)
-    {
-        $ssl = $this->ssl($ssl_id, 1, $value);
-        if ($ssl) {
-            if ($ssl['type'] == 1) {
-                # 非对称
-                openssl_public_encrypt($ssl['value'], $value, $ssl['cert'], $ssl['option']);
-            } elseif ($ssl['type'] == 2 && $ssl['cipher_algo']) {
-                # 对称
-                $value = openssl_encrypt($ssl['value'], $ssl['cipher_algo'], $ssl['cert'], $ssl['option'], $ssl['iv'], $ssl['tag'], $ssl['aad'], $ssl['tag_len']);
-            } elseif ($ssl['type'] == 3 && $ssl['cipher_algo']) {
-                # 签名
-                openssl_sign($ssl['value'], $value, $ssl['cert'], $ssl['cipher_algo']);
-            }
-
-            if ($ssl['after'] == 2) {
-                $value = base64_encode($value);
-            }
-        }
-        
-        return $value;
-    }
-
-    protected function decrypt($ssl_id, $value)
-    {
-        if (is_array($value)) {
-            $value = Dever::json_encode($value);
-        }
-        $ssl = $this->ssl($ssl_id, 2, $value);
-        if ($ssl) {
-            if ($ssl['after'] == 2) {
-                $value = Dever::base64_decode($value);
-            }
-            if ($ssl['type'] == 1) {
-                # 非对称
-                openssl_public_decrypt($ssl['value'], $value, $ssl['key'], $ssl['option']);
-            } elseif ($ssl['type'] == 2 && $ssl['cipher_algo']) {
-                # 对称
-                $value = openssl_decrypt($ssl['value'], $ssl['cipher_algo'], $ssl['key'], $ssl['option'], $ssl['iv'], $ssl['tag'], $ssl['aad'], $ssl['tag_len']);
-            } elseif ($ssl['type'] == 3 && $ssl['cipher_algo']) {
-                # 签名验证
-                $value = openssl_verify($ssl['value'], $value, $ssl['key'], $ssl['cipher_algo']);
-            }
-        }
-        
-        return $value;
-    }
-
-    protected function ssl($ssl_id, $type, $value)
-    {
-        $ssl = Dever::db('platform_ssl', 'api')->find($ssl_id);
-        if (!$ssl) {
-            return false;
-        }
-        $ssl['value'] = $value;
-        $key = $type == 1 ? 'encrypt' : 'decrypt';
-        $ssl['cert_type'] = $ssl[$key . '_cert_type'];
-        $ssl['cert'] = $ssl[$key . '_cert'];
-        $ssl['cert_id'] = $ssl[$key . '_cert_id'];
-        
-        if ($ssl['cert_type'] == 3) {
-            # 公钥
-            $ssl['cert'] = $this->field[$ssl['cert']] ?? $ssl['cert'];
-        } else {
-            $cert = Dever::db('platform_cert', 'api')->find($ssl['cert_id']);
-            $this->field['serial_no'] = $cert['number'];
-            if ($ssl['cert_type'] == 2) {
-                $key = 'private';
-                $method = 'openssl_get_privatekey';
-            } else {
-                $key = 'public';
-                $method = 'openssl_x509_read';
-            }
-            $ssl['cert'] = str_replace(Dever::host() . 'data/', Dever::data(), $cert[$key]);
-            $ssl['cert'] = $method(file_get_contents($ssl['cert']));
-        }
-        if (!$ssl['cert']) {
-            return false;
-        }
-        # 对称加密需要特殊处理一下
-        if ($ssl['type'] == 2) {
-            if (!$ssl['option']) {
-                $ssl['option'] = 'OPENSSL_NO_PADDING';
-            }
-            $ssl['option'] = constant($ssl['option']);
-            if ($padding === null) {
-                $ssl['option'] = OPENSSL_NO_PADDING;
-            }
-
-            $ssl['iv'] = $this->field[$ssl['iv']] ?? $ssl['iv'];
-            $ssl['aad'] = $this->field[$ssl['aad']] ?? $ssl['aad'];
-            if ($ssl['tag_len']) {
-                $ssl['tag'] = substr($ssl['value'], -$ssl['tag_len']);
-                $ssl['value'] = substr($ssl['value'], 0, -$ssl['tag_len']);
-            }
-            if (!$ssl['tag']) {
-                $ssl['tag'] = null;
-            }
-        }
-        return $ssl;
-    }
-
-    protected function filter($data)
-    {
-        return preg_replace("/<!--[^\!\[]*?(?<!\/\/)-->/","",$data);
-    }
-}

+ 0 - 159
src/channel/api/lib/Platform.php

@@ -1,159 +0,0 @@
-<?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 = 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'];
-        }
-    }
-
-    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']];
-                }
-                $this->field->set($v['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 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'];
-    }
-}

+ 0 - 137
src/channel/api/lib/Platform/Field.php

@@ -1,137 +0,0 @@
-<?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);
-            }
-        } else {
-            if ($state) {
-                $value = $this->ssl->encrypt($type, $value);
-            } else {
-                $value = $this->ssl->decrypt($type, $value);
-            }
-        }
-        return $value;
-    }
-}

+ 0 - 49
src/channel/api/lib/Platform/Request.php

@@ -1,49 +0,0 @@
-<?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) {
-                    $data[$v['key']] = $value;
-                    $this->field->set($v['key'], $value);
-                }
-            }
-        }
-    }
-}

+ 0 - 314
src/channel/api/lib/Platform/Response.php

@@ -1,314 +0,0 @@
-<?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['key']])) {
-                    $value = $this->field->value($this->header[$v['key']], $v['type'], false);
-                    $this->field->set($v['value'], $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) {
-            $source = array();
-            $dest = array();
-            foreach ($body as $k => $v) {
-                $temp = $this->convert($data, $v['key'], $v['value'], $v['type']);
-                if ($temp) {
-                    $result = array_replace_recursive($result, $temp);
-                }
-            }
-        }
-        $result = $this->value($result);
-        $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 {
-            if (isset($array[$current])) {
-                if (empty($source)) {
-                    $result = $array[$current];
-                    if ($type) {
-                        $result .= '||' . $type;
-                    }
-                    return $result;
-                } else {
-                    return $this->extracted($array[$current], $source, $type);
-                }
-            }
-        }
-        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;
-                }
-                $data[$k] = $this->field->value($temp[0], $temp[1], false);
-            }
-        }
-        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']];
-                    }
-                }
-                $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) {
-                        if ($v1['where']) {
-                            $info = Dever::db($k)->find($v1['where']);
-                            if ($info) {
-                                Dever::db($k)->update($info['id'], $v1['data']);
-                            } else {
-                                Dever::db($k)->insert($v1['data']);
-                            }
-                        } else {
-                            Dever::db($k)->insert($v1['data']);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    protected function filter($data)
-    {
-        return preg_replace("/<!--[^\!\[]*?(?<!\/\/)-->/","",$data);
-    }
-}

+ 0 - 145
src/channel/api/lib/Platform/Sign.php

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

+ 0 - 118
src/channel/api/lib/Platform/Ssl.php

@@ -1,118 +0,0 @@
-<?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']);
-            $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']);
-            }
-        }
-    }
-}

+ 0 - 37
src/channel/api/lib/Spec.php

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

+ 0 - 244
src/channel/api/manage/api.php

@@ -1,244 +0,0 @@
-<?php
-$config = array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'id',
-            'name',
-            'type',
-            'uri',
-            '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,type,cate,platform_id,uri'),
-        ),
-        'search' => array
-        (
-            'cate' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("content/cate.getList", array("api"))',
-            ),
-            'platform_id',
-            'type',
-            'name',
-            'uri',
-            'status',
-        ),
-    ),
-    'update' => array
-    (
-        'tab' => array
-        (
-            '基本设置' => 'name,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',
-            'type' => array
-            (
-                'type' => 'radio',
-                //'control' => true,
-            ),
-            '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;

+ 0 - 13
src/channel/api/manage/api_notify_code.php

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

+ 0 - 2
src/channel/api/manage/api_request_body.php

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

+ 0 - 2
src/channel/api/manage/api_request_header.php

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

+ 0 - 35
src/channel/api/manage/api_request_input.php

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

+ 0 - 26
src/channel/api/manage/api_request_output.php

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

+ 0 - 21
src/channel/api/manage/api_response.php

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

+ 0 - 2
src/channel/api/manage/api_response_body.php

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

+ 0 - 2
src/channel/api/manage/api_response_header.php

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

+ 0 - 22
src/channel/api/manage/api_save.php

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

+ 0 - 14
src/channel/api/manage/api_uri.php

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

+ 0 - 3
src/channel/api/manage/cate.php

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

+ 0 - 56
src/channel/api/manage/core.php

@@ -1,56 +0,0 @@
-<?php
-return array
-(
-    'menu' => array
-    (
-        'api_manage' => array
-        (
-            'parent' => 'channel',
-            '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,
-        ),
-    ),
-);

+ 0 - 175
src/channel/api/manage/platform.php

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

+ 0 - 75
src/channel/api/manage/platform_cert.php

@@ -1,75 +0,0 @@
-<?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',
-            ),*/
-        ),
-    ),
-);

+ 0 - 12
src/channel/api/manage/platform_convert.php

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

+ 0 - 21
src/channel/api/manage/platform_request_body.php

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

+ 0 - 2
src/channel/api/manage/platform_request_header.php

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

+ 0 - 2
src/channel/api/manage/platform_response_body.php

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

+ 0 - 12
src/channel/api/manage/platform_response_code.php

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

+ 0 - 2
src/channel/api/manage/platform_response_header.php

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

+ 0 - 25
src/channel/api/manage/platform_setting.php

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

+ 0 - 143
src/channel/api/manage/platform_ssl.php

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

+ 0 - 30
src/channel/api/manage/sku.php

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

+ 0 - 142
src/channel/api/table/api.php

@@ -1,142 +0,0 @@
-<?php
-return array
-(
-    'name' => '接口配置',
-    'struct' => array
-    (
-        'platform_id' => array
-        (
-            'name'      => '平台',
-            'type'      => 'int(11)',
-            'value'     => 'api/platform',
-        ),
-
-        'cate' => array
-        (
-            'name'      => '分类',
-            'type'      => 'varchar(100)',
-        ),
-
-        'cate_parent_id' => array
-        (
-            'name'      => '父级分类',
-            'type'      => 'int(11)',
-        ),
-
-        'cate_child_id' => array
-        (
-            'name'      => '子分类',
-            'type'      => 'int(11)',
-        ),
-
-        'name' => array
-        (
-            'name'      => '接口名称',
-            'type'      => 'varchar(150)',
-        ),
-
-        'type' => array
-        (
-            'name'      => '接口类型',
-            'type'      => 'tinyint(1)',
-            'default'   => '1',
-            'value'     => array
-            (
-                1 => '查询',
-                2 => '提交',
-            ),
-        ),
-
-        '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 => '多规格',
-            ),
-        ),
-
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '展示',
-                2 => '不展示',
-            ),
-        ),
-    ),
-);

+ 0 - 32
src/channel/api/table/api_log.php

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

+ 0 - 38
src/channel/api/table/api_notify_code.php

@@ -1,38 +0,0 @@
-<?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 => '其他',
-            ),
-        ),
-    ),
-);

+ 0 - 13
src/channel/api/table/api_request_body.php

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

+ 0 - 13
src/channel/api/table/api_request_header.php

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

+ 0 - 70
src/channel/api/table/api_request_input.php

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

+ 0 - 39
src/channel/api/table/api_request_output.php

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

+ 0 - 14
src/channel/api/table/api_response.php

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

+ 0 - 14
src/channel/api/table/api_response_body.php

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

+ 0 - 14
src/channel/api/table/api_response_header.php

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

+ 0 - 44
src/channel/api/table/api_save.php

@@ -1,44 +0,0 @@
-<?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 => '条件字段',
-            ),
-        ),
-    ),
-);

+ 0 - 48
src/channel/api/table/api_uri.php

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

+ 0 - 4
src/channel/api/table/cate.php

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

+ 0 - 224
src/channel/api/table/platform.php

@@ -1,224 +0,0 @@
-<?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 => '转小写',
-            ),
-        ),
-    ),
-);

+ 0 - 44
src/channel/api/table/platform_cert.php

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

+ 0 - 25
src/channel/api/table/platform_convert.php

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

+ 0 - 52
src/channel/api/table/platform_request_body.php

@@ -1,52 +0,0 @@
-<?php
-$type = array
-(
-    -1 => '字符串',
-    -2 => '数值',
-    //3 => 'JSON',
-);
-$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,
-        ),
-    ),
-);

+ 0 - 4
src/channel/api/table/platform_request_header.php

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

+ 0 - 5
src/channel/api/table/platform_response_body.php

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

+ 0 - 31
src/channel/api/table/platform_response_code.php

@@ -1,31 +0,0 @@
-<?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 => '失败',
-            ),
-        ),
-    ),
-);

+ 0 - 5
src/channel/api/table/platform_response_header.php

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

+ 0 - 32
src/channel/api/table/platform_setting.php

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

+ 0 - 134
src/channel/api/table/platform_ssl.php

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

+ 0 - 44
src/channel/api/table/sku.php

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

+ 0 - 32
src/channel/api/table/spec.php

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

+ 0 - 47
src/channel/api/table/spec_value.php

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

+ 17 - 22
src/place/api/Data.php

@@ -54,31 +54,26 @@ class Data extends Core
         return $data;
     }
 
-    # 根据身份码获取入口
-    public function code()
-    {
-        $code = Dever::input('code');
-        if (!$code) {
-            Dever::error('请输入身份码');
-        }
-        $code = Dever::db('code', 'place')->find(array('code' => $code));
-        if (!$code) {
-            Dever::error('身份码错误');
-        }
-        return $this->entry($code['sector_id'], $code['module_id'], $code['user_id'], $code['place_id']);
-    }
-
-    # 登录或者注册
+    # 验证码登录或者注册
+    public function login_commit(){};
     public function login()
     {
-        $mobile = Dever::input('mobile');
-        if (!$mobile) {
-            Dever::error('请输入手机号');
+        $account = Dever::input('account', 'is_string', '账户信息');
+        $env = Dever::input('env');
+        if ($env == 3 || $env == 5) {
+            # 如果是jsapi,也需要获取openid
+            $openid = Dever::db('util', 'api')->openid();
         }
-        $code = Dever::input('code');
-        if (!$code) {
-            Dever::error('请输入验证码');
+        if ($env == 5) {
+            # 如果是小程序,需要获取openid
+            $param['code'] = Dever::input('applet_code', 'is_string', '登录信息');
+            $data = Dever::load('account', 'api')->run($account, 'openid', $param, $env);
+            if (isset($data['openid'])) {
+
+            }
         }
+        $mobile = Dever::input('mobile', 'is_numeric', '手机号');
+        $code = Dever::input('code', 'is_numeric', '验证码');
         $where['mobile'] = $mobile;
         $member = Dever::db('member', 'place')->find($where);
         if ($member) {
@@ -91,6 +86,6 @@ class Data extends Core
             $data['agent_id'] = -1;
             $id = Dever::db('member', 'place')->insert($data);
         }
-        return array('token' => Secure::login($id));
+        return array('t' => Secure::login($id));
     }
 }

+ 25 - 0
src/place/api/Tool.php

@@ -0,0 +1,25 @@
+<?php namespace Place\Api;
+use Dever;
+use Dever\Helper\Secure;
+class Tool
+{
+    # 根据身份码获取入口
+    public function code()
+    {
+        $code = Dever::input('code');
+        if (!$code) {
+            Dever::error('请输入身份码');
+        }
+        $code = Dever::db('code', 'place')->find(array('code' => $code));
+        if (!$code) {
+            Dever::error('身份码错误');
+        }
+        return array('p' => $this->entry($code['sector_id'], $code['module_id'], $code['user_id'], $code['place_id']));
+    }
+
+    public function entry($sector_id, $module_id, $user_id, $place_id)
+    {
+        $entry = Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
+        return $entry;
+    }
+}

+ 12 - 6
src/place/lib/Core.php

@@ -27,6 +27,7 @@ class Core
         if (!$this->place) {
             Dever::error('信息有误');
         }
+        $this->place['content'] = htmlspecialchars_decode($this->place['content']);
 
         # 切换数据库
         $module = Dever::db('system_module', 'manage')->find(array('key' => 'sector_place'));
@@ -38,7 +39,7 @@ class Core
         $this->member = array();
         $t = Dever::input('t');
         if ($this->login && !$t) {
-            Dever::error('请先登录');
+            $this->showLogin();
         }
         if ($t) {
             if ($t = Secure::checkLogin($t)) {
@@ -46,7 +47,7 @@ class Core
                     $this->member = Dever::db('member', 'place')->find($t['uid'], array('col' => 'id,name,cash,vip_id,agent_id'));
                 }
                 if ($this->login && !$this->member) {
-                    Dever::error('请先登录');
+                    $this->showLogin();
                 }
             }
         }
@@ -54,15 +55,20 @@ class Core
             if ($this->place['type'] >= 2 && !$this->member) {
                 Dever::error('您没有权限');
             }
+            /*
             if ($this->member && $this->member['entry_type'] <= 2) {
                 Dever::error('您没有权限');
-            }
+            }*/
+        }
+        if (!$this->member) {
+            $this->member['id'] = -1;
         }
+        $this->member['score'] = $this->place['score'];
+        $this->member['score_per'] = $this->place['score_per'];
     }
 
-    public function entry($sector_id, $module_id, $user_id, $place_id)
+    protected function showLogin()
     {
-        $entry = Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
-        return $entry;
+        Dever::error('请先登录', 300);
     }
 }

+ 25 - 0
src/place/table/openid.php

@@ -0,0 +1,25 @@
+<?php
+return array
+(
+    'name' => 'openid表',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户ID',
+        ),
+
+        'openid'        => array
+        (
+            'type'      => 'varchar(60)',
+            'name'      => 'openid',
+        ),
+    ),
+);

+ 8 - 6
src/resource/content/api/Data.php

@@ -8,21 +8,23 @@ class Data extends Core
     {
         $data['place'] = $this->place;
         $data['member'] = $this->member;
-        $data['cate'] = Dever::load('cate', 'content')->getList();
-        $data['content'] = Dever::load('info', 'content')->getList(Dever::input('cate'));
+        $data = Dever::load('cate', 'content')->getAll($data);
+        $data['list'] = Dever::load('info', 'content')->getList($this->member, $data['cate_id']);
         return $data;
     }
 
     # 详情
     public function view()
     {
-        $data['content'] = Dever::load('info', 'content')->getOne();
+        $data['place'] = $this->place;
+        $data['member'] = $this->member;
+        $data['info'] = Dever::load('info', 'content')->getOne($this->member);
         # 分类下其他内容
-        $data['cate_content'] = Dever::load('info', 'content')->getList($data['content']['cdate'], $data['content']['id']);
+        $data['cate'] = Dever::load('info', 'content')->getList($this->member, $data['info']['cdate'], $data['info']['id'], 6);
         # 最新内容
-        $data['new_content'] = Dever::load('info', 'content')->getList(false, $data['content']['id']);
+        $data['new'] = Dever::load('info', 'content')->getList($this->member, false, $data['info']['id'], 6);
         # 获取评论
-        $data['review'] = Dever::load('review', 'content')->getList($data['content']['id']);
+        $data['review'] = Dever::load('review', 'content')->getList($data['info']['id']);
         return $data;
     }
 }

+ 39 - 0
src/resource/content/api/Member.php

@@ -0,0 +1,39 @@
+<?php namespace Content\Api;
+use Dever;
+use Place\Lib\Core;
+class Member extends Core
+{
+    protected $login = true;
+    protected $entry = true;
+
+    # 我的信息
+    public function info()
+    {
+        $data['member'] = $this->member;
+        return $data;
+    }
+
+    # 更新我的信息
+    public function update()
+    {
+        $update = array();
+        $name = Dever::input('name');
+        if ($name) {
+            $this->member['name'] = $update['name'] = $name;
+        }
+        $avatar = Dever::input('avatar');
+        if ($avatar) {
+            $this->member['avatar'] = $update['avatar'] = $avatar;
+        }
+        if ($update) {
+            Dever::db('member', 'place')->update($this->member['id'], $update);
+        }
+        return $this->member;
+    }
+
+    # 修改密码
+    public function pwd()
+    {
+        $code = Dever::input('code', 'is_string', '验证码');
+    }
+}

+ 24 - 0
src/resource/content/api/Value.php

@@ -0,0 +1,24 @@
+<?php namespace Content\Api;
+use Dever;
+use Place\Lib\Core;
+class Value extends Core
+{
+    protected $login = true;
+    protected $entry = true;
+
+    # 获取附件
+    public function list()
+    {
+        $data['info'] = Dever::load('value', 'content')->getInfo($this->member);
+        return $data;
+    }
+
+    # 购买附件
+    public function buy()
+    {
+        $account = Dever::input('account', 'is_string', '账户', 'wechat');
+        $env = Dever::input('env', 'is_numeric', '运行环境', 3);
+        $info = Dever::load('value', 'content')->getInfo($this->member);
+        return Dever::load('value', 'content')->getPay($this->member, $info, $account, $env); 
+    }
+}

+ 50 - 26
src/resource/content/lib/Cate.php

@@ -2,17 +2,60 @@
 use Dever;
 class Cate
 {
-    # 获取分类列表
-    public function getList($type = 'content')
+    # 获取所有分类信息
+    public function getAll($data, $type = 'content')
     {
-        $where = array('parent_id' => 0, 'status' => 1);
+        $data['cate_parent'] = $this->getData(0, $type);
+        $data['cate_child'] = array();
+        $data['cate_id'] = Dever::input('cate_id');
+        if ($data['cate_id']) {
+            $cate = Dever::db('cate', $type)->find($data['cate_id']);
+            $data['cate'] = $cate;
+            if ($cate) {
+                $cate['name'] = '全部';
+                if ($cate['parent_id'] <= 0) {
+                    $parent_id = $cate['id'];
+                } else {
+                    $parent_id = $cate['parent_id'];
+                }
+                if ($data['cate_parent']) {
+                    foreach ($data['cate_parent'] as &$v) {
+                        $v['selected'] = 2;
+                        if ($v['id'] == $parent_id) {
+                            $v['selected'] = 1;
+                        }
+                    }
+                }
+                $data['cate_child'][] = array('id' => $parent_id, 'name' => '全部');
+                $data['cate_child'] = array_merge($data['cate_child'], $this->getData($parent_id, $type));
+                if ($data['cate_child']) {
+                    foreach ($data['cate_child'] as &$v) {
+                        $v['selected'] = 2;
+                        if ($v['id'] == $cate['id']) {
+                            $v['selected'] = 1;
+                        }
+                    }
+                }
+            }
+        }
+        return $data;
+    }
+
+    public function getData($parent_id, $type = 'content')
+    {
+        $where = array('parent_id' => $parent_id, 'status' => 1);
         $set = array('col' => 'id,name,cdate,parent_id,`desc`');
-        $cate = Dever::db('cate', $type)->select($where, $set);
+        $data = Dever::db('cate', $type)->select($where, $set);
+        return $data;
+    }
+
+    # 获取带有子分类的分类列表
+    public function getList($type = 'content')
+    {
+        $cate = $this->getData(0, $type);
         $result = array();
         foreach ($cate as $k => $v) {
-            $child_where = array('parent_id' => $v['id'], 'status' => 1);
-            $child = Dever::db('cate', $type)->select($child_where, $set);
-            $v['children'] = $child;
+            $v['children'] = $this->getData($v['id'], $type);
             $result[] = $v;
         }
         return $result;
@@ -32,23 +75,4 @@ class Cate
         }
         return $result;
     }
-
-    public function updateKey($db, $data)
-    {
-        if ($data['name'] && !$data['key']) {
-            if (Dever::project('pinyin')) {
-                $where;
-                if (isset($data['id']) && $data['id']) {
-                    $where['id'] = array('!=', $data['id']);
-                }
-                $data['key'] = Dever::load('convert', 'pinyin')->getPinyinFirst($data['name']);
-
-                # 检查是否存在
-                $info = $db->
-
-                echo $data['key'];die;
-            }
-            
-        }
-    }
 }

+ 56 - 9
src/resource/content/lib/Info.php

@@ -5,15 +5,18 @@ class Info
     public function update($db, $data)
     {
         if ($data['cate']) {
+            $data['cate'] = explode(',', $data['cate']);
             $update['cate_parent_id'] = $data['cate'][0];
             if (isset($data['cate'][1])) {
-                $update['cate_child_id'] = $data['cate'][0];
+                $update['cate_child_id'] = $data['cate'][1];
+            } else {
+                $update['cate_child_id'] = 0;
             }
             $db->update(array('id' => $data['id']), $update);
         }
     }
 
-    public function getList($cate = false, $id = false, $num = 10)
+    public function getList($member, $cate = false, $id = false, $num = 10)
     {
         $where = array('status' => 1);
         if ($cate) {
@@ -27,11 +30,11 @@ class Info
         if ($times) {
             $where['times_id'] = $times;
         }
-        $name = Dever::input('name');
+        $name = Dever::input('search');
         if ($name) {
             $where['name'] = array('like', $name);
         }
-        $set['col'] = 'id,name,cdate,pic';
+        $set['col'] = 'id,name,cdate,pic,price';
         if ($id) {
             $set['limit'] = '0,6';
             $where['id'] = array('!=', $id);
@@ -41,13 +44,13 @@ class Info
         $info = Dever::db('info', 'content')->select($where, $set);
         $result = array();
         foreach ($info as $k => $v) {
-            $v = $this->getInfo($v);
+            $v = $this->getInfo($v, $member);
             $result[] = $v;
         }
         return $result;
     }
 
-    public function getOne()
+    public function getOne($member)
     {
         $id = Dever::input('id');
         $where = array('status' => 1);
@@ -56,14 +59,58 @@ class Info
         if (!$info) {
             Dever::alert('内容不存在');
         }
-        $info = $this->getInfo($info);
-        $info['value'] = Dever::db('value', 'content')->select(array('info_id' => $info['id']));
+        $info = $this->getInfo($info, $member);
         return $info;
     }
 
-    private function getInfo($info)
+    private function getInfo($info, $member)
     {
+        unset($info['password']);
         $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
+        if (isset($info['content'])) {
+            $info['button'] = '下载';
+            if ($member['id'] && $member['id'] > 0) {
+                $info['price_vip'] = array('name' => '会员', 'status' => 2, 'data' => array());
+                $price = Dever::db('price', 'content')->select(array('type' => 1, 'info_id' => $info['id']));
+                if ($price) {
+                    foreach ($price as &$v) {
+                        $vip = Dever::db('vip', 'place')->find($v['type_id']);
+                        if ($vip) {
+                            $v['name'] = $vip['name'];
+                            $v['price_text'] = $this->getPrice($v['price'], $member['score']);
+                            $info['price_vip']['status'] = 1;
+                            $info['price_vip']['data'][] = $v;
+                        }
+                    }
+                }
+                $info['price_agent'] = array('name' => '代理', 'status' => 2, 'data' => array());
+                $price = Dever::db('price', 'content')->select(array('type' => 2, 'info_id' => $info['id']));
+                if ($price) {
+                    foreach ($price as &$v) {
+                        $vip = Dever::db('agent', 'place')->find($v['type_id']);
+                        if ($vip) {
+                            $v['name'] = $vip['name'];
+                            $v['price_text'] = $this->getPrice($v['price'], $member['score']);
+                            $info['price_agent']['status'] = 1;
+                            $info['price_agent']['data'][] = $v;
+                        }
+                    }
+                }
+                
+            }
+            $info['content'] = htmlspecialchars_decode($info['content']);
+        }
+        $info['price_text'] = $this->getPrice($info['price'], $member['score']);
         return $info;
     }
+
+    public function getPrice($price, $score)
+    {
+        if ($price > 0) {
+            $price = $price . $score;
+        } else {
+            $price = '免费';
+        }
+        return $price;
+    }
 }

+ 141 - 0
src/resource/content/lib/Value.php

@@ -0,0 +1,141 @@
+<?php namespace Content\Lib;
+use Dever;
+class Value
+{
+    public function getInfo($member)
+    {
+        $id = Dever::input('id');
+        $where = array('status' => 1);
+        $where['id'] = $id;
+        $info = Dever::db('info', 'content')->find($where);
+        if (!$info) {
+            Dever::alert('内容不存在');
+        }
+
+        $password = Dever::input('password');
+        if ($password) {
+            if ($info['password'] && $password == $info['password']) {
+                $result['status'] = 1;
+            } else {
+                Dever::error('密码输入错误');
+            }
+        } else {
+            $result = $this->getPrice($member, $info);
+        }
+        
+        if ($result['status'] == 1) {
+            $result['value'] = Dever::db('value', 'content')->select(array('info_id' => $info['id']));
+        }
+        return $result;
+    }
+
+    # 获取价格
+    public function getPrice($member, $info)
+    {
+        $result = array();
+        $result['id'] = $info['id'];
+        $result['name'] = $info['name'];
+        $result['status'] = 2;
+        $order = Dever::db('order', 'content')->find(array('info_id' => $info['id'], 'uid' => $member['id'], 'status' => 2));
+        if ($order) {
+            $result['status'] = 1;
+        } else {
+            if ($info['price'] > 0) {
+                if ($member['vip_id'] > 0) {
+                    $vip_price = 0;
+                    $price = Dever::db('price', 'content')->select(array('type' => 1, 'info_id' => $info['id']));
+                    if ($price) {
+                        foreach ($price as &$v) {
+                            if ($v['type_id'] == $member['vip_id']) {
+                                $vip_price = $v['price'];
+                                break;
+                            } elseif ($v['type_id'] <= 0) {
+                                $vip_price = $v['price'];
+                            }
+                        }
+                        if ($vip_price < $info['price']) {
+                            $info['price'] = $vip_price;
+                        }
+                    }
+                }
+                if ($member['agent_id'] > 0) {
+                    $agent_price = 0;
+                    $price = Dever::db('price', 'content')->select(array('type' => 2, 'info_id' => $info['id']));
+                    if ($price) {
+                        foreach ($price as &$v) {
+                            if ($v['type_id'] == $member['agent_id']) {
+                                $agent_price = $v['price'];
+                                break;
+                            } elseif ($v['type_id'] <= 0) {
+                                $agent_price = $v['price'];
+                            }
+                        }
+                        if ($agent_price < $info['price']) {
+                            $info['price'] = $agent_price;
+                        }
+                    }
+                }
+            }
+
+            if ($info['price'] <= 0) {
+                $result['status'] = 1;
+            } else {
+                $result['password'] = 2;
+                if ($info['password']) {
+                    $result['password'] = 1;
+                }
+                $result['status'] = 2;
+                $result['price'] = $info['price'];
+                $result['price_text'] = Dever::load('info', 'content')->getPrice($info['price'], $member['score']);
+                $result['button'] = '购买';
+            }
+        }
+        return $result;
+    }
+
+    # 下单
+    public function getPay($member, $info, $account = 'wechat', $env = 3)
+    {
+        # 支付账户
+        $account = 'pay_' . $account;
+        # 下单
+        $order = array
+        (
+            'uid' => $member['id'],
+            'username' => $member['name'],
+            'openid' => true,
+            'order_num' => Dever::load('util', 'api')->createNumber('C', 'content/order'),
+            'cash' => ($info['price']/$member['score_per'])*100,#每个人的积分换算公式可能不一样
+            'name' => $info['name'],
+            'time_expire' => time() + 3600,
+        );
+        # 设置支付成功的回调信息,多个参数用|隔开
+        $param['notify'] = 'content/value.paySuccess|' . $order['order_num'];
+        $data = Dever::load('account', 'api')->run($account, 'order', $order, $env);
+        if ($data) {
+            $order['info_id'] = $info['id'];
+            $order['account_id'] = $data[0]['account_id'];
+            $order['api_id'] = $data[0]['api_id'];
+            $data['order_id'] = Dever::db('order', 'content')->insert($order);
+        }
+        return $data;
+    }
+
+    # 支付成功
+    public function paySuccess($order_num, $status, $body)
+    {
+        $order = Dever::db('order', 'content')->find(array('order_num' => $order_num));
+        if ($order && $order['status'] == 1) {
+            if ($status == 1) {
+                $update['status'] = 2;
+            } else {
+                $update['status'] = 3;
+            }
+            $update['pdate'] = time();
+            $state = Dever::db('order', 'content')->update($order['id'], $update);
+            if (!$state && $order['project_id']) {
+                return '订单更新失败';
+            }
+        }
+    }
+}

+ 1 - 1
src/resource/content/manage/cate.php

@@ -55,6 +55,6 @@ return array
             'sort',
         ),
         'check' => 'key',
-        'start' => 'content/cate.updateKey',
+        'start' => 'manage/common.updateKey',
     ),
 );

+ 2 - 2
src/resource/content/manage/info.php

@@ -107,9 +107,9 @@ return array
             ),
             'content/price' => array
             (
-                'name' => '会员',
+                'name' => '会员设置',
                 'where'  => array('info_id' => 'id'),
-                'desc' => '按照会员和代理等级,设置专享后,仅该等级的会员或代理可以下载',
+                'desc' => '可以按照会员和代理等级设置,设置专享后,仅该等级的会员或代理可以下载',
             ),
         ),
         'end' => 'content/info.update',

+ 2 - 2
src/resource/content/table/cate.php

@@ -47,10 +47,10 @@ return array
     ),
     'default' => array
     (
-        'field' => 'name,cdate',
+        'field' => 'name,`key`,cdate',
         'value' => array
         (
-            '"默认分类",' . DEVER_TIME,
+            '"默认分类","default",' . DEVER_TIME,
         ),
         'num' => 1,
     ),

+ 32 - 0
src/resource/content/table/collect.php

@@ -0,0 +1,32 @@
+<?php
+return array
+(
+    'name' => '内容收藏表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => array
+    (
+        'info_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '内容',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '状态',
+            'default'   => '1',
+            'value'         => array
+            (
+                1 => '收藏',
+                2 => '取消收藏',
+            ),
+        ),
+    ),
+);

+ 33 - 0
src/resource/content/table/down.php

@@ -0,0 +1,33 @@
+<?php
+return array
+(
+    'name' => '内容下载表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => array
+    (
+        'info_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '内容',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '下载类型',
+            'default'   => '1',
+            'value'         => array
+            (
+                1 => '免费',
+                2 => '密码',
+                3 => '购买',
+            ),
+        ),
+    ),
+);

+ 1 - 1
src/resource/content/table/info.php

@@ -27,7 +27,7 @@ return array
         'cate' => array
         (
             'name'      => '分类',
-            'type'      => 'varchar(100)',
+            'type'      => 'varchar(800)',
         ),
 
         'cate_parent_id' => array

+ 87 - 0
src/resource/content/table/order.php

@@ -0,0 +1,87 @@
+<?php
+return array
+(
+    'name' => '内容支付订单表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => array
+    (
+        'account_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '账户',
+        ),
+
+        'api_id'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '接口',
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '内容',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+
+        'username'      => array
+        (
+            'type'      => 'varchar(200)',
+            'name'      => '用户名称',
+        ),
+
+        'openid'        => array
+        (
+            'type'      => 'varchar(200)',
+            'name'      => '第三方用户ID',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar(800)',
+            'name'      => '订单名称',
+        ),
+
+        'order_num'        => array
+        (
+            'type'      => 'varchar(600)',
+            'name'      => '订单号',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal(11,2)',
+            'name'      => '订单金额',
+        ),
+
+        'time_expire'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '过期时间',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'value'         => array
+            (
+                1 => '待支付',
+                2 => '已支付',
+                3 => '支付失败',
+            ),
+        ),
+
+        'pdate'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '付款时间',
+        ),
+    ),
+);

+ 3 - 3
src/resource/content/table/price.php

@@ -40,11 +40,11 @@ return array
         (
             'name'      => '专享状态',
             'type'      => 'tinyint(1)',
-            'default'   => 1,
+            'default'   => 2,
             'value'     => array
             (
-                1 => '专享',
-                2 => '专享',
+                1 => '专享',
+                2 => '专享',
             ),
         ),
     ),

+ 1 - 1
src/resource/func/table/info.php

@@ -34,7 +34,7 @@ return array
         'cate' => array
         (
             'name'      => '分类',
-            'type'      => 'varchar(100)',
+            'type'      => 'varchar(800)',
         ),
 
         'cate_parent_id' => array

+ 1 - 1
src/resource/goods/table/info.php

@@ -21,7 +21,7 @@ return array
         'cate' => array
         (
             'name'      => '分类',
-            'type'      => 'varchar(100)',
+            'type'      => 'varchar(800)',
         ),
 
         'cate_parent_id' => array