Skip to content

Commit 13c8661

Browse files
committed
Merge branch 'demo' into develop
2 parents 62a88e0 + ea1e13f commit 13c8661

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

laravel/app/Http/Controllers/Api/PermissionController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public function edit($id)
116116
*/
117117
public function update(Update $request, $id)
118118
{
119+
if (env('APP_ENV') == 'demo' && $id < 50) {
120+
return $this->out(4000, [], 'demo account Do Not Operate');
121+
}
119122
$input = $request->all();
120123
is_null($input['route']) && $input['route'] = '';
121124
// $model = new Category();$model->save($input, ['id' => $id]);

laravel/app/Http/Controllers/Api/RoleController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ public function edit($id)
117117
*/
118118
public function update(Update $request, $id)
119119
{
120+
if (env('APP_ENV') == 'demo' && $id == 1) {
121+
return $this->out(4000, [], 'demo account Do Not Operate');
122+
}
120123
$role = Role::findOrFail($id); // 通过给定id获取角色
121124
// 验证 name 和 permission 字段
122125
// $this->validate($request, [

laravel/app/Http/Repository/ApiRepository.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use App\Models\ApiExcel;
1313
use App\Models\ApiExcelLogs;
14+
use Illuminate\Support\Facades\DB;
1415

1516
class ApiRepository
1617
{
@@ -70,14 +71,29 @@ public function handleAutoDelete()
7071
public function autoFailed()
7172
{
7273
// 查询数据库已完成的任务,判断过期条件
73-
$excels = ApiExcel::where('state', 1)->get(['id', 'auto_delete', 'created_at', 'updated_at']);
74+
// $excels = ApiExcel::where('state', 1)->get(['id', 'auto_delete', 'created_at', 'updated_at']);
75+
76+
// New: 2020-05-31 失败任务的条件
77+
// 1. 完成率 96% -- 5 秒不再增加
78+
// 2. 完成率 50% -- 1 分钟不再增加
79+
// 3. 完成率 10% -- 5 分钟不再增加
80+
// 4. 完成率 1% -- 10 分钟不再增加
81+
$excels = DB::connection()->select('SELECT ae.id,ae.api_param_id,ae.state,ae.total_excel,ael.api_excel_id,ael.sort_index,ael.created_at FROM `boss_api_excel` ae LEFT JOIN boss_api_excel_logs ael ON ae.id=ael.api_excel_id AND ael.id=(SELECT id FROM boss_api_excel_logs WHERE boss_api_excel_logs.api_excel_id=ae.id ORDER BY sort_index DESC LIMIT 1) WHERE ae.state=1 AND ae.`deleted_at` IS NULL ');
7482

7583
foreach ($excels as $excel) {
7684
// 开启任务后 10 分钟未查询出结果=》失败
77-
if ($excel['auto_delete'] > 0 && strtotime($excel['updated_at']) + 600 < time()) {
78-
ApiExcel::where('id', $excel['id'])->update(['state' => 5]);
85+
// if ($excel['auto_delete'] > 0 && strtotime($excel['updated_at']) + 600 < time()) {
86+
// ApiExcel::where('id', $excel['id'])->update(['state' => 5]);
87+
// }
88+
if (!$excel->sort_index || !$excel->created_at) {
89+
continue;
90+
}
91+
// 记录完成率
92+
$finish = (($excel->sort_index + 1) / $excel->total_excel) * 100;
93+
$finish = sprintf("%.2f", $finish);
94+
if (($finish > '96' && strtotime($excel->created_at) + 5 < time()) || ($finish > '50' && strtotime($excel->created_at) + 60 < time()) || ($finish > '10' && strtotime($excel->created_at) + 300 < time()) || ($finish > '1' && strtotime($excel->created_at) + 600 < time())) {
95+
ApiExcel::where('id', $excel->id)->update(['state' => 5]);
7996
}
80-
8197
}
8298
}
8399

laravel/app/Services/WebSocketService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function onOpen($server, $request)
6868
// 设置过期时间
6969
$this->redis->expire($redisKey, 6000);
7070
}
71-
if ($count > 200) { // 防止刷单的安全拦截
71+
if ($count > 20000) { // 防止刷单的安全拦截
7272
break; // 超出就跳出循环
7373
}
7474
} else {

laravel/public/static/js/app.144d08b0.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

laravel/public/static/js/chunk-0c1e6da9.a4450a8e.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

laravel/public/static/js/chunk-55dcc495.dfbdffd1.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)