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
cdb56a0a
authored
Sep 27, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-ic助手服务开发-20190824'
parents
3a5843c8
42612a5f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
app/Jobs/Timer/ResetExchangeSettingsCronJob.php
storage/laravels.json
storage/laravels.pid
app/Jobs/Timer/ResetExchangeSettingsCronJob.php
View file @
cdb56a0a
...
...
@@ -3,6 +3,7 @@
namespace
App\Jobs\Timer
;
use
App\Models\ExchangeSetting
;
use
Carbon\Carbon
;
use
Common\Model\RedisModel
;
use
Hhxsv5\LaravelS\Swoole\Timer\CronJob
;
...
...
@@ -11,22 +12,24 @@ use Swoole\Coroutine;
class
ResetExchangeSettingsCronJob
extends
CronJob
{
// protected $i = 0;
// protected $i = 0;
// !!! 定时任务的`interval`和`isImmediate`有两种配置方式(二选一):一是重载对应的方法,二是注册定时任务时传入参数。
// --- 重载对应的方法来返回配置:开始
public
function
interval
()
{
return
1000
;
// 每1秒运行一次
}
public
function
isImmediate
()
{
return
true
;
// 是否立即执行第一次,false则等待间隔时间后执行第一次
}
// --- 重载对应的方法来返回配置:结束
public
function
run
()
{
//判断是否是10点,如果是10点就进行重置任务
$time
=
Carbon
::
create
(
null
,
null
,
null
,
14
,
3
0
);
$time
=
Carbon
::
create
(
null
,
null
,
null
,
15
,
0
0
);
$time
=
$time
->
timestamp
;
$now
=
Carbon
::
now
()
->
timestamp
;
if
(
$time
===
$now
)
{
...
...
@@ -35,18 +38,19 @@ class ResetExchangeSettingsCronJob extends CronJob
}
}
private
function
reset
(){
private
function
reset
()
{
Log
::
info
(
"开始重置..."
);
//重置商品可兑换限额
//先从redis缓存里面去取需要的数据
$redis
=
new
RedisModel
();
$settings
=
$redis
->
hgetall
(
'ic_exchange_settings'
);
$settings
=
ExchangeSetting
::
where
(
'status'
,
1
)
->
get
()
->
toArray
();
//获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表
//列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好
try
{
foreach
(
$settings
as
$key
=>
$setting
)
{
$setting
=
json_decode
(
$setting
,
true
);
$id
=
$setting
[
'id'
];
//先去删除原有的
...
...
storage/laravels.json
View file @
cdb56a0a
This diff is collapsed.
Click to expand it.
storage/laravels.pid
View file @
cdb56a0a
12787
\ No newline at end of file
13457
\ No newline at end of file
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