From 6f2f588617e2aced2b8b205a77e7b1c228b6cdcc Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Sun, 28 Jun 2020 14:39:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ConsoleController.class.php | 10 ++++++---- .../FinancePromoteController.class.php | 15 ++++++++++++--- Application/Base/Task/Task.class.php | 3 ++- Application/Base/Task/TestTask.class.php | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 Application/Base/Task/TestTask.class.php diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 62c10f21a..787594709 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -94,7 +94,7 @@ class ConsoleController extends Think { } } - public function runTask($queue = 'common', $count = 1) + public function runTask($queue = 'common', $count = 10) { Printer::export($queue); Printer::export($count); @@ -109,7 +109,7 @@ class ConsoleController extends Think { public function addTask() { - $id = M('market_shift', 'tab_')->add([ + /* $id = M('market_shift', 'tab_')->add([ 'from_id' => 1, 'to_id' => 2, 'split_time' => 0, @@ -117,8 +117,10 @@ class ConsoleController extends Think { ]); $params = [ 'market_shift_id' => $id - ]; - Task::add('market-shift', $params); + ]; */ + for ($i=0; $i<50; $i++) { + Task::add('test', ['value' => $i]); + } } public function initMarketAdmin() diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 43e4699d5..24a0b62f3 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -127,7 +127,10 @@ class FinancePromoteController extends AdminController ); $promotes = []; if (count($senddata) > 0) { - $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', array_column($senddata, 'p_id')]])->select(); + $promoteIds = array_column($senddata, 'p_id'); + if ($promoteIds) { + $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', $promoteIds]])->select(); + } } $promotes = index_by_column('id', $promotes); $adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id')); @@ -355,7 +358,10 @@ class FinancePromoteController extends AdminController $promotes = []; if (count($senddata) > 0) { - $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', array_column($senddata, 'promote_id')]])->select(); + $promoteIds = array_column($senddata, 'promote_id'); + if (count($promoteIds)) { + $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', $promoteIds]])->select(); + } } $promotes = index_by_column('id', $promotes); $adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id')); @@ -507,7 +513,10 @@ class FinancePromoteController extends AdminController } $promotes = []; if (count($data) > 0) { - $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', array_column($data, 'p_id')]])->select(); + $promoteIds = array_column($data, 'p_id'); + if (count($promoteIds) > 0) { + $promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])->where(['id' => ['in', $promoteIds]])->select(); + } } $promotes = index_by_column('id', $promotes); $adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id')); diff --git a/Application/Base/Task/Task.class.php b/Application/Base/Task/Task.class.php index b2b91e0a2..902f5ad97 100644 --- a/Application/Base/Task/Task.class.php +++ b/Application/Base/Task/Task.class.php @@ -9,10 +9,11 @@ class Task { public static $types = [ 'market-shift' => '\Base\Task\MarketShiftTask', + 'test' => '\Base\Task\TestTask', ]; public static $queues = [ - 'common' => [], + 'common' => ['test'], 'market-shift' => ['market-shift'] ]; diff --git a/Application/Base/Task/TestTask.class.php b/Application/Base/Task/TestTask.class.php new file mode 100644 index 000000000..f4f8894f6 --- /dev/null +++ b/Application/Base/Task/TestTask.class.php @@ -0,0 +1,17 @@ + + */ +class TestTask extends BaseTask +{ + public function run() + { + echo '测试' . $this->params['value'] . '执行成功'; + echo PHP_EOL; + } +} \ No newline at end of file