ComposerUpdate

This commit is contained in:
Anyon 2020-05-14 16:52:42 +08:00
parent 2d2d665370
commit b08ca4c9bb
9 changed files with 62 additions and 45 deletions

8
composer.lock generated
View File

@ -915,12 +915,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9" "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ac00eec5a084eecf07d4260d975fc2f3f52659d9", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac",
"reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9", "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -964,7 +964,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "homepage": "http://framework.thinkadmin.top",
"time": "2020-05-12T02:34:46+00:00" "time": "2020-05-13T02:56:23+00:00"
}, },
{ {
"name": "zoujingli/wechat-developer", "name": "zoujingli/wechat-developer",

View File

@ -941,12 +941,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9" "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ac00eec5a084eecf07d4260d975fc2f3f52659d9", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac",
"reference": "ac00eec5a084eecf07d4260d975fc2f3f52659d9", "reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -962,7 +962,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-05-12T02:34:46+00:00", "time": "2020-05-13T02:56:23+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-05-13 09:41:06 // This file is automatically generated at:2020-05-14 16:52:07
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -124,15 +124,25 @@ class Queue extends Command
*/ */
protected function cleanAction() protected function cleanAction()
{ {
// 清理 7 天前的历史任务记录
$map = [['exec_time', '<', time() - 7 * 24 * 3600]]; $map = [['exec_time', '<', time() - 7 * 24 * 3600]];
$count1 = $this->app->db->name($this->table)->where($map)->delete(); $count = $this->app->db->name($this->table)->where($map)->delete();
$this->setQueueProgress("清理 {$count1} 条历史任务成功"); $this->setQueueProgress("本次清理了 {$count} 条历史任务记录");
// 重置超60分钟无响应的记录 // 标记超过 1 小时未完成的任务为失败状态
$map = [['exec_time', '<', time() - 3600], ['status', '=', '2']]; $map = [['exec_time', '<', time() - 3600], ['status', '=', '2']];
$count2 = $this->app->db->name($this->table)->where($map)->update([ list($used, $total) = [0, $this->app->db->name($this->table)->where($map)->count()];
'status' => '4', 'exec_desc' => '任务执行超时,已自动标识为失败!', $this->app->db->name($this->table)->where($map)->chunk(100, function (Collection $result) use ($total, &$used) {
]); foreach ($result->toArray() as $item) {
$this->setQueueProgress("处理 {$count2} 条超时间任务成功", 100); $stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}";
$this->setQueueProgress("[{$stridx}] 正在标记任务 {$item['code']} 超时", $used / $total * 100);
$item['loops_time'] > 0 ? $this->app->db->name($this->table)->where(['id' => $item['id']])->update([
'status' => 2, 'exec_desc' => '任务执行超时,已自动重置任务待!',
]) : $this->app->db->name($this->table)->where(['id' => $item['id']])->update([
'status' => 4, 'exec_desc' => '任务执行超时,已自动标识为失败!',
]);
}
});
$this->setQueueSuccess("清理 {$count} 条历史任务,标识 {$total} 条超时任务");
} }
/** /**

View File

@ -24,45 +24,42 @@ class DataExtend
{ {
/** /**
* 一维数据数组生成数据树 * 一维数组生成数据树
* @param array $list 数据列表 * @param array $list 待处理数据
* @param string $key ID_KEY * @param string $cid 自己的主键
* @param string $pkey PID_KEY * @param string $pid 上级的主键
* @param string $skey 子数据名称 * @param string $sub 子数组名称
* @return array * @return array
*/ */
public static function arr2tree($list, $key = 'id', $pkey = 'pid', $skey = 'sub') public static function arr2tree($list, $cid = 'id', $pid = 'pid', $sub = 'sub')
{ {
list($tree, $map) = [[], []]; list($tree, $tmp) = [[], array_combine(array_column($list, $cid), array_values($list))];
foreach ($list as $item) $map[$item[$key]] = $item; foreach ($list as $vo) isset($vo[$pid]) && isset($tmp[$vo[$pid]]) ? $tmp[$vo[$pid]][$sub][] = &$tmp[$vo[$cid]] : $tree[] = &$tmp[$vo[$cid]];
foreach ($list as $item) if (isset($item[$pkey]) && isset($map[$item[$pkey]])) { unset($tmp, $list);
$map[$item[$pkey]][$skey][] = &$map[$item[$key]];
} else $tree[] = &$map[$item[$key]];
unset($map);
return $tree; return $tree;
} }
/** /**
* 一维数据数组生成数据树 * 一维数组生成数据树
* @param array $list 数据列表 * @param array $list 待处理数据
* @param string $key ID_KEY * @param string $cid 自己的主键
* @param string $pkey PID_KEY * @param string $pid 上级的主键
* @param string $path * @param string $cpath 当前 PATH
* @param string $ppath * @param string $ppath 上级 PATH
* @return array * @return array
*/ */
public static function arr2table(array $list, $key = 'id', $pkey = 'pid', $path = 'path', $ppath = '') public static function arr2table(array $list, $cid = 'id', $pid = 'pid', $cpath = 'path', $ppath = '')
{ {
$tree = []; $tree = [];
foreach (self::arr2tree($list, $key, $pkey) as $attr) { foreach (self::arr2tree($list, $cid, $pid) as $attr) {
$attr[$path] = "{$ppath}-{$attr[$key]}"; $attr[$cpath] = "{$ppath}-{$attr[$cid]}";
$attr['sub'] = isset($attr['sub']) ? $attr['sub'] : []; $attr['sub'] = isset($attr['sub']) ? $attr['sub'] : [];
$attr['spt'] = substr_count($ppath, '-'); $attr['spt'] = substr_count($ppath, '-');
$attr['spl'] = str_repeat(" ├ ", $attr['spt']); $attr['spl'] = str_repeat(" ├ ", $attr['spt']);
$sub = $attr['sub']; $sub = $attr['sub'];
unset($attr['sub']); unset($attr['sub']);
$tree[] = $attr; $tree[] = $attr;
if (!empty($sub)) $tree = array_merge($tree, self::arr2table($sub, $key, $pkey, $path, $attr[$path])); if (!empty($sub)) $tree = array_merge($tree, self::arr2table($sub, $cid, $pid, $cpath, $attr[$cpath]));
} }
return $tree; return $tree;
} }

View File

@ -16,7 +16,7 @@
namespace think\admin\extend; namespace think\admin\extend;
/** /**
* 出CSV文件扩展 * 出CSV文件扩展
* Class ExcelExtend * Class ExcelExtend
* @package think\admin\extend * @package think\admin\extend
*/ */

View File

@ -174,7 +174,7 @@ class HttpExtend
private static function getUserAgent() private static function getUserAgent()
{ {
if (!empty($_SERVER['HTTP_USER_AGENT'])) return $_SERVER['HTTP_USER_AGENT']; if (!empty($_SERVER['HTTP_USER_AGENT'])) return $_SERVER['HTTP_USER_AGENT'];
$agents = [ $aligs = [
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11",
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",
@ -185,6 +185,6 @@ class HttpExtend
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
]; ];
return $agents[array_rand($agents, 1)]; return $aligs[array_rand($aligs, 1)];
} }
} }

View File

@ -50,7 +50,7 @@ class AdminService extends Service
*/ */
public function getUserId() public function getUserId()
{ {
return $this->app->session->get('user.id', 0); return intval($this->app->session->get('user.id', 0));
} }
/** /**

View File

@ -73,9 +73,19 @@ class SystemService extends Service
return htmlspecialchars($value); return htmlspecialchars($value);
}, $this->data[$type])); }, $this->data[$type]));
} else { } else {
if (isset($this->data[$type]) && isset($this->data[$type][$field])) { if (isset($this->data[$type])) {
return $outer === 'raw' ? $this->data[$type][$field] : htmlspecialchars($this->data[$type][$field]); if ($field) {
} else return ''; if (isset($this->data[$type][$field])) {
return $outer === 'raw' ? $this->data[$type][$field] : htmlspecialchars($this->data[$type][$field]);
}
} else {
if ($outer === 'raw') foreach ($this->data[$type] as $key => $vo) {
$this->data[$type][$key] = htmlspecialchars($vo);
}
return $this->data[$type];
}
}
return '';
} }
} }