From 6f956670f0b129cc1a3da6b681b9fbc4138ea179 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 19 Sep 2020 18:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/sys.php | 19 ++++++++++++++++--- app/data/service/TruckService.php | 7 ++++--- vendor/composer/autoload_classmap.php | 4 +++- vendor/composer/autoload_static.php | 4 +++- vendor/composer/installed.json | 12 ++++++------ vendor/services.php | 2 +- .../zoujingli/think-library/src/Library.php | 2 +- .../src/service/InterfaceService.php | 11 +++++++++++ .../src/service/SystemService.php | 17 ++++++++++++++--- 9 files changed, 59 insertions(+), 19 deletions(-) diff --git a/app/admin/sys.php b/app/admin/sys.php index e312efd01..8304e6bec 100644 --- a/app/admin/sys.php +++ b/app/admin/sys.php @@ -14,8 +14,21 @@ // +---------------------------------------------------------------------- use think\admin\service\AdminService; +use think\admin\service\SystemService; use think\helper\Str; +/*! 全局操作日志数据 */ +$GLOBALS['oplogs'] = []; + +/*! 操作日志批量写入日志 */ +app()->event->listen('HttpEnd', function () { + if (is_array($GLOBALS['oplogs']) && count($GLOBALS['oplogs']) > 0) { + foreach (array_chunk($GLOBALS['oplogs'], 100) as $items) { + app()->db->name('SystemOplog')->insertAll($items); + } + } +}); + /*! SQL 监听分析记录日志 */ app()->db->listen(function ($sqlstr) { [$type,] = explode(' ', $sqlstr); @@ -24,18 +37,18 @@ app()->db->listen(function ($sqlstr) { if (preg_match('/^INSERT\s+INTO\s+`(.*?)`\s+SET\s+(.*?)\s*$/i', $sqlstr, $matches)) { if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 200); - return sysoplog("添加数据 {$matches[1]}", "添加数据:{$matches[2]}"); + $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加数据 {$matches[1]}", "添加数据:{$matches[2]}"); } } elseif (preg_match('/^UPDATE\s+`(.*?)`\s+SET\s+(.*?)\s+WHERE\s+(.*?)\s*$/i', $sqlstr, $matches)) { if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 0, 200); $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 200); - return sysoplog("更新数据 {$matches[1]}( {$matches[3]} )", "更新内容:{$matches[2]}"); + $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("更新数据 {$matches[1]}( {$matches[3]} )", "更新内容 {$matches[2]}"); } } elseif (preg_match('/^DELETE\s*FROM\s*`(.*?)`\s*WHERE\s*(.*?)\s*$/i', $sqlstr, $matches)) { if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { $matches[2] = str_replace(['`', '\''], '', $matches[2]); - return sysoplog("删除数据 {$matches[1]}", "删除条件:{$matches[2]}"); + $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("删除数据 {$matches[1]}", "删除条件 {$matches[2]}"); } } } diff --git a/app/data/service/TruckService.php b/app/data/service/TruckService.php index 0689dfd92..d2de4ed1a 100644 --- a/app/data/service/TruckService.php +++ b/app/data/service/TruckService.php @@ -79,7 +79,7 @@ class TruckService extends Service */ public function query($code, $number) { - return $this->_getInterface()->doRequest('https://open.cuci.cc/user/api.auth.express/query', [ + return $this->_getInterface()->doRequest('api.auth.express/query', [ 'type' => 'free', 'express' => $code, 'number' => $number, ]); } @@ -91,7 +91,7 @@ class TruckService extends Service */ public function company() { - return $this->_getInterface()->doRequest('https://open.cuci.cc/user/api.auth.express/getCompany'); + return $this->_getInterface()->doRequest('api.auth.express/getCompany'); } /** @@ -101,7 +101,8 @@ class TruckService extends Service private function _getInterface(): InterfaceService { $service = InterfaceService::instance(); - // 测试的账号及密钥,随时可能会变更,请联系客服获取自己的账号和密钥 + // 测试的账号及密钥随时可能会变更,请联系客服更新 + $service->getway('https://open.cuci.cc/user/'); $service->setAuth("6998081316132228", "193fc1d9a2aac78475bc8dbeb9a5feb1"); return $service; } diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 0d6e1206e..f57abcb4d 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -216,16 +216,18 @@ return array( 'app\\data\\controller\\ShopGoods' => $baseDir . '/app/data/controller/ShopGoods.php', 'app\\data\\controller\\ShopGoodsCate' => $baseDir . '/app/data/controller/ShopGoodsCate.php', 'app\\data\\controller\\ShopGoodsMark' => $baseDir . '/app/data/controller/ShopGoodsMark.php', - 'app\\data\\controller\\ShopGoodsStock' => $baseDir . '/app/data/controller/ShopGoodsStock.php', 'app\\data\\controller\\ShopOrder' => $baseDir . '/app/data/controller/ShopOrder.php', 'app\\data\\controller\\ShopOrderSend' => $baseDir . '/app/data/controller/ShopOrderSend.php', 'app\\data\\controller\\ShopOrderService' => $baseDir . '/app/data/controller/ShopOrderService.php', + 'app\\data\\controller\\ShopTruckCompany' => $baseDir . '/app/data/controller/ShopTruckCompany.php', + 'app\\data\\controller\\ShopTruckTemplate' => $baseDir . '/app/data/controller/ShopTruckTemplate.php', 'app\\data\\controller\\api\\Auth' => $baseDir . '/app/data/controller/api/Auth.php', 'app\\data\\controller\\api\\Data' => $baseDir . '/app/data/controller/api/Data.php', 'app\\data\\controller\\api\\Goods' => $baseDir . '/app/data/controller/api/Goods.php', 'app\\data\\controller\\api\\Login' => $baseDir . '/app/data/controller/api/Login.php', 'app\\data\\controller\\api\\News' => $baseDir . '/app/data/controller/api/News.php', 'app\\data\\controller\\api\\Notify' => $baseDir . '/app/data/controller/api/Notify.php', + 'app\\data\\controller\\api\\Wechat' => $baseDir . '/app/data/controller/api/Wechat.php', 'app\\data\\controller\\api\\Wxapp' => $baseDir . '/app/data/controller/api/Wxapp.php', 'app\\data\\controller\\api\\auth\\Address' => $baseDir . '/app/data/controller/api/auth/Address.php', 'app\\data\\controller\\api\\auth\\Center' => $baseDir . '/app/data/controller/api/auth/Center.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 6edc50869..f7e64da2c 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -353,16 +353,18 @@ class ComposerStaticInit7ad2dfd941224dedfd9e69a3187017d8 'app\\data\\controller\\ShopGoods' => __DIR__ . '/../..' . '/app/data/controller/ShopGoods.php', 'app\\data\\controller\\ShopGoodsCate' => __DIR__ . '/../..' . '/app/data/controller/ShopGoodsCate.php', 'app\\data\\controller\\ShopGoodsMark' => __DIR__ . '/../..' . '/app/data/controller/ShopGoodsMark.php', - 'app\\data\\controller\\ShopGoodsStock' => __DIR__ . '/../..' . '/app/data/controller/ShopGoodsStock.php', 'app\\data\\controller\\ShopOrder' => __DIR__ . '/../..' . '/app/data/controller/ShopOrder.php', 'app\\data\\controller\\ShopOrderSend' => __DIR__ . '/../..' . '/app/data/controller/ShopOrderSend.php', 'app\\data\\controller\\ShopOrderService' => __DIR__ . '/../..' . '/app/data/controller/ShopOrderService.php', + 'app\\data\\controller\\ShopTruckCompany' => __DIR__ . '/../..' . '/app/data/controller/ShopTruckCompany.php', + 'app\\data\\controller\\ShopTruckTemplate' => __DIR__ . '/../..' . '/app/data/controller/ShopTruckTemplate.php', 'app\\data\\controller\\api\\Auth' => __DIR__ . '/../..' . '/app/data/controller/api/Auth.php', 'app\\data\\controller\\api\\Data' => __DIR__ . '/../..' . '/app/data/controller/api/Data.php', 'app\\data\\controller\\api\\Goods' => __DIR__ . '/../..' . '/app/data/controller/api/Goods.php', 'app\\data\\controller\\api\\Login' => __DIR__ . '/../..' . '/app/data/controller/api/Login.php', 'app\\data\\controller\\api\\News' => __DIR__ . '/../..' . '/app/data/controller/api/News.php', 'app\\data\\controller\\api\\Notify' => __DIR__ . '/../..' . '/app/data/controller/api/Notify.php', + 'app\\data\\controller\\api\\Wechat' => __DIR__ . '/../..' . '/app/data/controller/api/Wechat.php', 'app\\data\\controller\\api\\Wxapp' => __DIR__ . '/../..' . '/app/data/controller/api/Wxapp.php', 'app\\data\\controller\\api\\auth\\Address' => __DIR__ . '/../..' . '/app/data/controller/api/auth/Address.php', 'app\\data\\controller\\api\\auth\\Center' => __DIR__ . '/../..' . '/app/data/controller/api/auth/Center.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index f300eacfa..258c9ce2d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -958,17 +958,17 @@ }, { "name": "zoujingli/think-library", - "version": "v6.0.8", - "version_normalized": "6.0.8.0", + "version": "v6.0.9", + "version_normalized": "6.0.9.0", "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "686db8b3131f4cec0f5f5927338baba4580d65c5" + "reference": "6fa904cad8bde5b2d04750d17323fe715a0c2b4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/686db8b3131f4cec0f5f5927338baba4580d65c5", - "reference": "686db8b3131f4cec0f5f5927338baba4580d65c5", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/6fa904cad8bde5b2d04750d17323fe715a0c2b4d", + "reference": "6fa904cad8bde5b2d04750d17323fe715a0c2b4d", "shasum": "", "mirrors": [ { @@ -985,7 +985,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-09-14T08:48:48+00:00", + "time": "2020-09-19T10:23:24+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index a9081fa3e..00e7455f5 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php index a57864dc1..dc26e7caf 100644 --- a/vendor/zoujingli/think-library/src/Library.php +++ b/vendor/zoujingli/think-library/src/Library.php @@ -41,7 +41,7 @@ class Library extends Service /** * 扩展库版本号 */ - const VERSION = '6.0.8'; + const VERSION = '6.0.9'; /** * 启动服务 diff --git a/vendor/zoujingli/think-library/src/service/InterfaceService.php b/vendor/zoujingli/think-library/src/service/InterfaceService.php index 951a9a220..225833aa5 100644 --- a/vendor/zoujingli/think-library/src/service/InterfaceService.php +++ b/vendor/zoujingli/think-library/src/service/InterfaceService.php @@ -116,6 +116,17 @@ class InterfaceService extends Service return $this; } + /** + * 设置接口网关地址 + * @param string $getway + * @return $this + */ + public function getway(string $getway) + { + $this->baseurl = $getway; + return $this; + } + /** * 获取请求数据 * @param boolean $check 验证数据 diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 09a48f04a..3f472222c 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -176,19 +176,30 @@ class SystemService extends Service } /** - * 写入系统日志 + * 写入系统日志内容 * @param string $action * @param string $content * @return integer */ public function setOplog($action, $content) { - return $this->app->db->name('SystemOplog')->insert([ + return $this->app->db->name('SystemOplog')->insert($this->getOplog($action, $content)); + } + + /** + * 获取系统日志内容 + * @param string $action + * @param string $content + * @return array + */ + public function getOplog($action, $content) + { + return [ 'node' => NodeService::instance()->getCurrent(), 'action' => $action, 'content' => $content, 'geoip' => $this->app->request->ip() ?: '127.0.0.1', 'username' => AdminService::instance()->getUserName() ?: '-', - ]); + ]; } /**