rabin 1 month ago
parent
commit
556f4f79c6

+ 3 - 3
api/Manage.php

@@ -7,14 +7,14 @@ class Manage extends Auth
     public function keyToField($project, $key)
     {
         if ($key != -1) {
-            $result = array();
+            $result = [];
             $array = explode(',', $key);
-            $result['key']['set'] = array();
+            $result['key']['set'] = [];
             foreach ($array as $k => $v) {
                 $value = Dever::db('spec_value', $project)->find($v);
                 if ($value) {
                     $spec = Dever::db('spec', $project)->find($value['spec_id']);
-                    $result['key']['set']['s_' . $spec['id']] = array($spec['name'], $value['value']);
+                    $result['key']['set']['s_' . $spec['id']] = [$spec['name'], $value['value']];
                 }
             }
             return $result;

+ 5 - 5
api/Notify.php

@@ -48,7 +48,7 @@ class Notify extends Api
         if ($this->info['notify'] == 2) {
             $this->error('error');
         }
-        $this->notify = Dever::db('api_notify', 'api')->find(array('api_id' => $api_id));
+        $this->notify = Dever::db('api_notify', 'api')->find(['api_id' => $api_id]);
         if (!$this->notify) {
             $this->error('error');
         }
@@ -78,7 +78,7 @@ class Notify extends Api
 
     protected function body($body)
     {
-        $config = Dever::db('api_notify_body', 'api')->select(array('api_id' => $this->info['id']));
+        $config = Dever::db('api_notify_body', 'api')->select(['api_id' => $this->info['id']]);
         $result = Value::load($this->field)->get($config, $body);
         if ($result) {
             foreach ($config as $k => $v) {
@@ -94,7 +94,7 @@ class Notify extends Api
     protected function header()
     {
         $header = getallheaders();
-        $config = Dever::db('platform_response_header', 'api')->select(array('platform_id' => $this->platform['id']));
+        $config = Dever::db('platform_response_header', 'api')->select(['platform_id' => $this->platform['id']]);
         if ($config) {
             foreach ($config as $k => $v) {
                 if (isset($header[$v['value']])) {
@@ -103,7 +103,7 @@ class Notify extends Api
                 }
             }
         }
-        $config = Dever::db('api_response_header', 'api')->select(array('api_id' => $this->info['id']));
+        $config = Dever::db('api_response_header', 'api')->select(['api_id' => $this->info['id']]);
         if ($config) {
             foreach ($config as $k => $v) {
                 if (isset($header[$v['value']])) {
@@ -127,7 +127,7 @@ class Notify extends Api
     {
         # 1成功 2失败 3不做任何操作
         $status = 3;
-        $config = Dever::db('api_notify_code', 'api')->select(array('api_id' => $this->info['id']));
+        $config = Dever::db('api_notify_code', 'api')->select(['api_id' => $this->info['id']]);
         if ($config) {
             foreach ($config as $k => $v) {
                 if (isset($body[$v['key']]) && $body[$v['key']] == $v['value']) {

+ 2 - 2
api/Task.php

@@ -6,11 +6,11 @@ class Task
     public function func()
     {
         $where['status'] = 1;
-        $where['cron_time'] = array('>', '0');
+        $where['cron_time'] = ['>', '0'];
         $data = Dever::db('app_func', 'api')->select($where);
         if ($data) {
             foreach ($data as $k => $v) {
-                $account = Dever::db('account', 'api')->find(array('app_id' => $v['app_id']));
+                $account = Dever::db('account', 'api')->find(['app_id' => $v['app_id']]);
                 if ($account) {
                     Dever::load('account', 'api')->run($account, $v);
                 }

+ 4 - 4
lib/Account.php

@@ -19,16 +19,16 @@ class Account
         return $data;
     }
 
-    public function run($account, $func, $param = array(), $env = 1, $method = 'run', $project = 'api')
+    public function run($account, $func, $param = [], $env = 1, $method = 'run', $project = 'api')
     {
         if (!is_array($account)) {
-            $account = Dever::db('account', 'api')->find(array('key' => $account));
+            $account = Dever::db('account', 'api')->find(['key' => $account]);
         }
         if (!$account) {
             Dever::error('账户无效');
         }
         if (!is_array($func)) {
-            $func = Dever::db('app_func', 'api')->find(array('app_id' => $account['app_id'], 'key' => $func));
+            $func = Dever::db('app_func', 'api')->find(['app_id' => $account['app_id'], 'key' => $func]);
         }
         if (!$func) {
             Dever::error('功能无效');
@@ -39,7 +39,7 @@ class Account
         }
         $param['account_project'] = $project;
         $param['account_id'] = $account['id'];
-        $result = array();
+        $result = [];
         if ($func['type'] == 1) {
             # 仅执行第一个
             $result = Dever::load('api', 'api')->$method($api[0], $param);

+ 3 - 3
lib/Api.php

@@ -5,7 +5,7 @@ class Api extends Platform
     public $type = 'api';
 
     # 执行某个接口
-    public function run($id, $param = array())
+    public function run($id, $param = [])
     {
         $state = $this->setting($id, $param);
         if (!$state) {
@@ -15,7 +15,7 @@ class Api extends Platform
     }
 
     # 跳转
-    public function jump($id, $param = array())
+    public function jump($id, $param = [])
     {
         $state = $this->setting($id, $param);
         if (!$state) {
@@ -32,6 +32,6 @@ class Api extends Platform
             $encode .= '|' . $field['notify'];
         }
         $encode = \Dever\Helper\Str::encode($encode);
-        return Dever::url('api/notify.common', array('s' => $encode), false, 'package/api/');
+        return Dever::url('api/notify.common', ['s' => $encode], false, 'package/api/');
     }
 }

+ 16 - 20
lib/App.php

@@ -4,10 +4,10 @@ class App
 {
     public function update($db, $data)
     {
-        $func = Dever::db('app_func_work', 'api')->select(array('app_func_id' => $data['id']));
+        $func = Dever::db('app_func_work', 'api')->select(['app_func_id' => $data['id']]);
         if ($func) {
-            $platform = array();
-            Dever::db('app_platform', 'api')->delete(array('app_id' => $data['app_id']));
+            $platform = [];
+            Dever::db('app_platform', 'api')->delete(['app_id' => $data['app_id']]);
             foreach ($func as $k => $v) {
                 $api = Dever::db('api', 'api')->find($v['api_id']);
                 if ($api) {
@@ -15,7 +15,7 @@ class App
                 }
             }
             foreach ($platform as $k => $v) {
-                Dever::db('app_platform', 'api')->insert(array('app_id' => $data['app_id'], 'platform_id' => $v));
+                Dever::db('app_platform', 'api')->insert(['app_id' => $data['app_id'], 'platform_id' => $v]);
             }
         }
     }
@@ -23,34 +23,32 @@ class App
     public function updateApi($db, $data)
     {
         if (isset($data['notify']) && $data['notify'] == 2) {
-            Dever::db('api/api_notify')->delete(array('api_id' => $data['id']));
+            Dever::db('api/api_notify')->delete(['api_id' => $data['id']]);
         }
     }
 
     public function getPlatform($app)
     {
-        $set['join'] = array
-        (
-            array
-            (
+        $set['join'] = [
+            [
                 'table' => 'platform',
                 'type' => 'left join',
                 'on' => 'platform.id=app_platform.platform_id',
-            ),
-        );
+            ],
+        ];
         $set['col'] = 'platform.id as id,platform.name as name';
-        $platform = Dever::db('app_platform', 'api')->select(array('app_id' => $app), $set);
+        $platform = Dever::db('app_platform', 'api')->select(['app_id' => $app], $set);
         return $platform;
     }
 
     public function getSetting($platform_id)
     {
-        return Dever::db('platform_setting', 'api')->select(array('platform_id' => $platform_id));
+        return Dever::db('platform_setting', 'api')->select(['platform_id' => $platform_id]);
     }
 
     public function getCert($platform_id)
     {
-        return Dever::db('platform_cert', 'api')->select(array('platform_id' => $platform_id));
+        return Dever::db('platform_cert', 'api')->select(['platform_id' => $platform_id]);
     }
 
     public function getCertName($id)
@@ -61,16 +59,14 @@ class App
 
     public function getApi($func_id, $env = 1)
     {
-        $set['join'] = array
-        (
+        $set['join'] = [
             # t0
-            array
-            (
+            [
                 'table' => 'api_api',
                 'type' => 'left join',
                 'on' => 't0.id=main.api_id',
-            ),
-        );
+            ],
+        ];
         $set['col'] = 't0.*';
         $set['order'] = 'main.sort asc,t0.id desc';
         $where['main.app_func_id'] = $func_id;

+ 9 - 9
lib/Platform.php

@@ -10,7 +10,7 @@ class Platform
     public $info;
     public $field;
 
-    public function setting($id, $field = array())
+    public function setting($id, $field = [])
     {
         $this->info($id);
         $this->platform();
@@ -46,7 +46,7 @@ class Platform
         if (isset($field['account_project']) && isset($field['account_id'])) {
             $this->info['account_id'] = $field['account_id'];
             $this->info['account_project'] = $field['account_project'];
-            $setting = Dever::db('account_setting', $field['account_project'])->select(array('account_id' => $field['account_id']));
+            $setting = Dever::db('account_setting', $field['account_project'])->select(['account_id' => $field['account_id']]);
             if ($setting) {
                 foreach ($setting as $k => $v) {
                     $info = Dever::db('platform_setting', 'api')->find($v['platform_setting_id']);
@@ -69,7 +69,7 @@ class Platform
         $this->field->setUri($this->info['uri']);
         $this->field->setNotify($this->createNotify($field));
 
-        $setting = Dever::db('api_setting', 'api')->select(array('api_id' => $this->info['id']));
+        $setting = Dever::db('api_setting', 'api')->select(['api_id' => $this->info['id']]);
         if ($setting) {
             foreach ($setting as $k => $v) {
                 $this->field->set($v['key'], $this->field->value($v['value'], $v['type']));
@@ -94,10 +94,10 @@ class Platform
         $curl->setResultHeader(true);
         $response_body = $curl->result();
         $response_header = $curl->header();
-        $response_config = array('id' => $this->platform['id'], 'type' => $this->platform['response_type']);
+        $response_config = ['id' => $this->platform['id'], 'type' => $this->platform['response_type']];
         $response = new Response($response_body, $response_header, $this->field, $response_config, $this->type, $this->info['id']);
         $result = $response->out();
-        $log = array();
+        $log = [];
         $log['platform_id'] = $this->platform['id'];
         $log['api_id'] = $this->info['id'];
         $log['account_id'] = $this->info['account_id'];
@@ -155,9 +155,9 @@ class Platform
         if (strstr($this->info['uri'], 'http')) {
             $this->platform['host'] = '';
         }
-        $path = Dever::db('api_path', 'api')->select(array('api_id' => $this->info['id']));
+        $path = Dever::db('api_path', 'api')->select(['api_id' => $this->info['id']]);
         if ($path) {
-            $path = array();
+            $path = [];
             foreach ($path as $k => $v) {
                 $v['value'] = $this->field->value($v['value']);
                 if ($v['type'] == 1) {
@@ -175,9 +175,9 @@ class Platform
             }
         }
 
-        $query = Dever::db('api_query', 'api')->select(array('api_id' => $this->info['id']));
+        $query = Dever::db('api_query', 'api')->select(['api_id' => $this->info['id']]);
         if ($query) {
-            $param = array();
+            $param = [];
             foreach ($query as $k => $v) {
                 $param[$v['key']] = $this->field->value($v['value'], $v['type']);
                 if (is_array($param[$v['key']])) {

+ 5 - 5
lib/Platform/Field.php

@@ -2,7 +2,7 @@
 use Dever;
 class Field
 {
-    private $data = array();
+    private $data = [];
     public $ssl;
     public function __construct($data)
     {
@@ -125,18 +125,18 @@ class Field
         }
         if (!$type && $source == $value) {
             /*
-            $field = Dever::db('platform_field', 'api')->find(array('platform_id' => $this->data['platform_id'], 'key' => $value));
+            $field = Dever::db('platform_field', 'api')->find(['platform_id' => $this->data['platform_id'], 'key' => $value]);
             if ($field) {
                 $value = $field['value'];
                 $type = $field['type'];
             } else {
-                $sign = Dever::db('platform_sign', 'api')->find(array('platform_id' => $this->data['platform_id'], 'name' => $value));
+                $sign = Dever::db('platform_sign', 'api')->find(['platform_id' => $this->data['platform_id'], 'name' => $value]);
                 if ($sign) {
                     $value = '';
                     $type = '3,' . $sign['id'];
                 }
             }*/
-            $sign = Dever::db('platform_sign', 'api')->find(array('platform_id' => $this->data['platform_id'], 'name' => $value));
+            $sign = Dever::db('platform_sign', 'api')->find(['platform_id' => $this->data['platform_id'], 'name' => $value]);
             if ($sign) {
                 $value = '';
                 $type = '3,' . $sign['id'];
@@ -174,7 +174,7 @@ class Field
             if ($type == 1) {
                 $info = Dever::db('format', 'api')->find($type_id);
                 if ($info) {
-                    $value = \Dever\Helper\Str::val($info['method'], array('value' => $value));
+                    $value = \Dever\Helper\Str::val($info['method'], ['value' => $value]);
                 }
             } elseif ($type == 2) {
                 # state == true 是编码 == false 是解码

+ 4 - 4
lib/Platform/Request.php

@@ -12,7 +12,7 @@ class Request
 
     public function body()
     {
-        $body = array();
+        $body = [];
         $this->field->setBody($body);
         $this->load($body, 'body');
         $this->field->setBodyJson($body ? Dever::json_encode($body) : '');
@@ -21,7 +21,7 @@ class Request
 
     public function header()
     {
-        $header = array();
+        $header = [];
         $this->field->setHeader($header);
         $this->load($header, 'header');
         $this->field->setHeaderJson($header ? Dever::json_encode($header) : '');
@@ -30,8 +30,8 @@ class Request
 
     protected function load(&$data, $type)
     {
-        $this->get($data, 'platform', $type, array('platform_id' => $this->platform_id));
-        $this->get($data, $this->type, $type, array($this->type . '_id' => $this->type_id));
+        $this->get($data, 'platform', $type, ['platform_id' => $this->platform_id]);
+        $this->get($data, $this->type, $type, [$this->type . '_id' => $this->type_id]);
     }
 
     protected function get(&$data, $prefix, $type, $where)

+ 15 - 17
lib/Platform/Response.php

@@ -25,9 +25,9 @@ class Response
 
     public function header()
     {
-        $header = Dever::db($this->type . '_response_header', 'api')->select(array($this->type . '_id' => $this->type_id));
+        $header = Dever::db($this->type . '_response_header', 'api')->select([$this->type . '_id' => $this->type_id]);
         if (!$header) {
-            $header = Dever::db('platform_response_header', 'api')->select(array('platform_id' => $this->config['id']));
+            $header = Dever::db('platform_response_header', 'api')->select(['platform_id' => $this->config['id']]);
         }
         if ($header) {
             foreach ($header as $k => $v) {
@@ -79,7 +79,7 @@ class Response
     {
         $msg = '';
         $status = 1;
-        $code = Dever::db('platform_response_code', 'api')->select(array('platform_id' => $this->config['id']));
+        $code = Dever::db('platform_response_code', 'api')->select(['platform_id' => $this->config['id']]);
         if ($code) {
             foreach ($code as $k => $v) {
                 if (isset($data[$v['key']]) && $data[$v['key']] == $v['value']) {
@@ -99,10 +99,10 @@ class Response
 
     protected function handle($data)
     {
-        $result = array();
-        $body = Dever::db($this->type . '_response_body', 'api')->select(array($this->type . '_id' => $this->type_id));
+        $result = [];
+        $body = Dever::db($this->type . '_response_body', 'api')->select([$this->type . '_id' => $this->type_id]);
         if (!$body) {
-            $body = Dever::db('platform_response_body', 'api')->select(array('platform_id' => $this->config['id']));
+            $body = Dever::db('platform_response_body', 'api')->select(['platform_id' => $this->config['id']]);
         }
         $value = Value::load($this->field);
         $result = $value->get($body, $data);
@@ -112,17 +112,16 @@ class Response
 
     protected function save($value, $data)
     {
-        $save = Dever::db($this->type . '_save', 'api')->select(array($this->type . '_id' => $this->type_id));
+        $save = Dever::db($this->type . '_save', 'api')->select([$this->type . '_id' => $this->type_id]);
         if ($save) {
-            $table = array();
+            $table = [];
             foreach ($save as $k => $v) {
                 if (!isset($table[$v['table']])) {
-                    $table[$v['table']] = array
-                    (
+                    $table[$v['table']] = [
                         'total' => 0,
-                        'data' => array(),
-                        'where' => array(),
-                    );
+                        'data' => [],
+                        'where' => [],
+                    ];
                 }
                 if (strstr($v['value'], '.')) {
                     $v['value'] = explode('.', $v['value']);
@@ -146,7 +145,7 @@ class Response
             }
             if ($table) {
                 foreach ($table as $k => $v) {
-                    $update = array();
+                    $update = [];
                     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;
@@ -164,11 +163,10 @@ class Response
                             $project = $this->field->account_project;
                             $account_id = $this->field->account_id;
                             if ($project && $account_id) {
-                                $cert = array
-                                (
+                                $cert = [
                                     'account_id' => $account_id,
                                     'platform_cert_id' => $id,
-                                );
+                                ];
                                 $v1['where'] += $cert;
                                 $v1['data'] += $cert;
                                 $this->saveData($project . '/account_cert', $v1['where'], $v1['data']);

+ 2 - 2
lib/Platform/Sign.php

@@ -62,7 +62,7 @@ class Sign
 
     protected function create()
     {
-        $this->info = array();
+        $this->info = [];
         if ($this->config['arg']) {
             $col = explode("\n", $this->config['arg']);
             foreach ($col as $k => $v) {
@@ -146,7 +146,7 @@ class Sign
 
     protected function encrypt()
     {
-        $log = array();
+        $log = [];
         $log['request_id'] = $this->field->request_id;
         $log['name'] = $this->config['name'];
         $log['string'] = $this->info;

+ 1 - 1
lib/Platform/Ssl.php

@@ -106,7 +106,7 @@ class Ssl
             $project = $this->field->account_project;
             $account_id = $this->field->account_id;
             if ($project && $account_id) {
-                $cert = Dever::db('account_cert', $project)->find(array('account_id' => $account_id, 'platform_cert_id' => $config['cert_id']), array('order' => 'edate desc'));
+                $cert = Dever::db('account_cert', $project)->find(['account_id' => $account_id, 'platform_cert_id' => $config['cert_id']], ['order' => 'edate desc']);
             }
             if (!$cert) {
                 $config['cert'] = false;

+ 3 - 3
lib/Platform/Value.php

@@ -18,13 +18,13 @@ class Value
 
     public function get($config, $data)
     {
-        $result = array();
+        $result = [];
         if ($config) {
             foreach ($data as $k => $v) {
                 $this->field->set($k, $v);
             }
-            $source = array();
-            $dest = array();
+            $source = [];
+            $dest = [];
             foreach ($config as $k => $v) {
                 $temp = $this->convert($data, $v['value'], $v['key'], $v['type']);
                 if ($temp) {

+ 7 - 7
lib/Sku.php

@@ -5,12 +5,12 @@ class Sku
     # 获取当前最低价格
     public function getPrice($where, $spec_type, $app)
     {
-        $result = array();
+        $result = [];
         if ($spec_type == 2) {
             $where['key'] = '-1';
             $sku = Dever::db('sku', $app)->find($where);
         } elseif ($spec_type == 3) {
-            $sku = Dever::db('sku', $app)->find($where, array('order' => 'price asc,id desc'));
+            $sku = Dever::db('sku', $app)->find($where, ['order' => 'price asc,id desc']);
         }
         if (isset($sku) && $sku && $sku['key']) {
             $result['price'] = $sku['price'];
@@ -29,11 +29,11 @@ class Sku
     # 多规格获取多个价格
     public function getList($where, $sku_id, $app)
     {
-        $result = array();
+        $result = [];
         $sku = Dever::db('sku', $app)->select($where);
         if ($sku) {
-            $spec = array();
-            $result['info'] = array();
+            $spec = [];
+            $result['info'] = [];
             foreach ($sku as $k => $v) {
                 $t = $where;
                 $k = str_replace(',', '_', $v['key']);
@@ -62,8 +62,8 @@ class Sku
         if (!$key || $key == '-1') {
             return '默认规格';
         } else {
-            $name = array();
-            $where['id'] = array('in', $key);
+            $name = [];
+            $where['id'] = ['in', $key];
             $data = Dever::db('spec_value', $app)->select($where, array('order' => 'field(id, '.$key.')'));
             if ($data) {
                 foreach ($data as $k => $v) {

+ 5 - 5
lib/Spec.php

@@ -5,9 +5,9 @@ class Spec
     # 获取规格数据
     public function manage($table, $field, $id)
     {
-        $result = array();
+        $result = [];
         if ($id) {
-            $result = Dever::db($table)->select(array($field => $id));
+            $result = Dever::db($table)->select([$field => $id]);
             if ($result) {
                 foreach ($result as $k => $v) {
                     $result[$k]['type'] = 'show';
@@ -15,7 +15,7 @@ class Spec
                     $result[$k]['show'] = true;
                     $result[$k]['fixed'] = true;
                     $result[$k]['key'] = $v['name'];
-                    $value = Dever::db($table . '_value')->select(array($field => $id, 'spec_id' => $v['id']));
+                    $value = Dever::db($table . '_value')->select([$field => $id, 'spec_id' => $v['id']]);
                     if ($value) {
                         foreach ($value as $k1 => $v1) {
                             $value[$k1]['parent'] = $result[$k]['key'];
@@ -39,13 +39,13 @@ class Spec
     public function getList($where, $app, $select = false)
     {
         $where['state'] = 1;
-        $data = Dever::db('spec', $app)->select($where, array('col' => 'id,name'));
+        $data = Dever::db('spec', $app)->select($where, ['col' => 'id,name']);
         if ($data) {
             foreach ($data as &$v) {
                 $w = $where;
                 $w['spec_id'] = $v['id'];
                 unset($v['id']);
-                $v['value'] = Dever::db('spec_value', $app)->select($w, array('col' => 'id,value'));
+                $v['value'] = Dever::db('spec_value', $app)->select($w, ['col' => 'id,value']);
                 if ($select) {
                     foreach ($v['value'] as &$v1) {
                         $v1['selected'] = false;

+ 7 - 7
lib/Util.php

@@ -3,7 +3,7 @@ use Dever;
 class Util
 {
     # 生成订单号
-    public function createNumber($prefix, $table, $where = array(), $key = 'order_num')
+    public function createNumber($prefix, $table, $where = [], $key = 'order_num')
     {
         $number = \Dever\Helper\Str::order($prefix);
         $where[$key] = $number;
@@ -15,11 +15,11 @@ class Util
     }
 
     # 获取openid 仅jspai和小程序需要openid
-    public function openid($account, $env, $uid, $result = array())
+    public function openid($account, $env, $uid, $result = [])
     {
-        $account = Dever::db('account', 'api')->find(array('key' => $account));
+        $account = Dever::db('account', 'api')->find(['key' => $account]);
         if ($account) {
-            $info = Dever::db('openid', 'api')->find(array('account_id' => $account['id'], 'uid' => $uid, 'env' => $env));
+            $info = Dever::db('openid', 'api')->find(['account_id' => $account['id'], 'uid' => $uid, 'env' => $env]);
             if ($info) {
                 $result['openid'] = $info['openid'];
             } else {
@@ -51,7 +51,7 @@ class Util
     # 获取参数类型
     public function fieldType($platform_id)
     {
-        $data = array();
+        $data = [];
         $data[] = array
         (
             'id' => 1,
@@ -80,7 +80,7 @@ class Util
     # 获取签名列表
     public function getPlatformSign($platform_id)
     {
-        return Dever::db('platform_sign', 'api')->select(array('platform_id' => $platform_id));
+        return Dever::db('platform_sign', 'api')->select(['platform_id' => $platform_id]);
     }
 
     # 格式转换
@@ -89,7 +89,7 @@ class Util
         $info = Dever::db('format', 'api')->find($id);
         if ($info) {
             $info['method'] = str_replace('{value}', "'{value}'", $info['method']);
-            $value = \Dever\Helper\Str::val($info['method'], array('value' => $value));
+            $value = \Dever\Helper\Str::val($info['method'], ['value' => $value]);
         }
         return $value;
     }