Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
95e814ff
authored
Aug 26, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
每天10点定时重置可兑换商品数额
parent
7f2b8d27
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
app/Console/Commands/ResetExchangeSetting.php
app/Console/Kernel.php
config/laravels.php
app/Console/Commands/ResetExchangeSetting.php
0 → 100644
View file @
95e814ff
<?php
namespace
App\Console\Commands
;
use
Common\Model\RedisModel
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Log
;
class
ResetExchangeSetting
extends
Command
{
// 供我们调用命令
protected
$signature
=
'ic:reset_exchange_setting'
;
// 命令的描述
protected
$description
=
'定时重置商品兑换的配额'
;
// 最终执行的方法
public
function
handle
()
{
// 在命令行打印一行信息
$this
->
info
(
"开始查找..."
);
//重置商品可兑换限额
//先从redis缓存里面去取需要的数据
$redis
=
new
RedisModel
();
$settings
=
$redis
->
hgetall
(
'ic_exchange_settings'
);
//获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表
//列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好
foreach
(
$settings
as
$key
=>
$setting
)
{
$setting
=
json_decode
(
$setting
,
true
);
$id
=
$setting
[
'id'
];
//先去删除原有的
$redis
->
del
(
'ic_exchange_settings_'
.
$id
);
$data
=
array_fill
(
0
,
$setting
[
'stock'
],
1
);
$redis
->
lpush
(
'ic_exchange_settings_'
.
$id
,
$data
);
}
$this
->
info
(
"执行成功!"
);
}
}
\ No newline at end of file
app/Console/Kernel.php
View file @
95e814ff
...
...
@@ -2,6 +2,7 @@
namespace
App\Console
;
use
App\Console\Commands\ResetExchangeSetting
;
use
Illuminate\Console\Scheduling\Schedule
;
use
Laravel\Lumen\Console\Kernel
as
ConsoleKernel
;
...
...
@@ -14,6 +15,7 @@ class Kernel extends ConsoleKernel
*/
protected
$commands
=
[
//
ResetExchangeSetting
::
class
,
];
/**
...
...
@@ -25,5 +27,6 @@ class Kernel extends ConsoleKernel
protected
function
schedule
(
Schedule
$schedule
)
{
//
$schedule
->
command
(
'ic:reset_exchange_setting'
)
->
dailyAt
(
'10:00'
);
}
}
config/laravels.php
View file @
95e814ff
...
...
@@ -32,10 +32,10 @@ return [
//],
],
'timer'
=>
[
'enable'
=>
fals
e
,
'enable'
=>
tru
e
,
'jobs'
=>
[
// Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab
//
\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class,
\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob
::
class
,
// Two ways to configure parameters:
// [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering
// \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment