Commit 55c5d40d by 杨树贤

修改重置任务å的方式

parent 7decbc26
......@@ -48,4 +48,5 @@ IC_AUTH_API=http://authapi.icsales.cc
RobotUrl=https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11
LARAVELS_TIMER = true
<?php
namespace App\Jobs\Timer;
use Carbon\Carbon;
use Common\Model\RedisModel;
use Hhxsv5\LaravelS\Swoole\Timer\CronJob;
use Illuminate\Support\Facades\Log;
use Swoole\Coroutine;
class ResetExchangeSettingsCronJob extends CronJob
{
// 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,13,55);
$time = $time->timestamp;
$now = Carbon::now()->timestamp;
if ($time === $now) {
Log::info("进行定时检测重置任务...");
$this->reset();
}
}
private function reset(){
Log::info("开始重置...");
//重置商品可兑换限额
//先从redis缓存里面去取需要的数据
$redis = new RedisModel();
$settings = $redis->hgetall('ic_exchange_settings');
//获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表
//列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好
try {
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);
}
} catch (\Exception $e) {
Log::info("重置失败,原因是" . $e);
return;
}
Log::info("重置完成");
}
}
\ No newline at end of file
......@@ -32,13 +32,13 @@ return [
//],
],
'timer' => [
'enable' => true,
'enable' => env('LARAVELS_TIMER'),
'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
\App\Jobs\Timer\ResetExchangeSettingsCronJob::class, // Override the corresponding method to return the configuration
],
'max_wait_time' => 5,
],
......
{"server":{"listen_ip":"0.0.0.0","listen_port":"61009","socket_type":1,"enable_coroutine_runtime":false,"server":"LaravelS","handle_static":false,"laravel_base_path":"/home/vagrant/code/ic_server_welfare","inotify_reload":{"enable":false,"watch_path":"/home/vagrant/code/ic_server_welfare","file_types":[".php"],"excluded_dirs":[],"log":true},"event_handlers":[],"websocket":{"enable":false},"sockets":[],"processes":[],"timer":{"enable":true,"jobs":["Hhxsv5\\LaravelS\\Illuminate\\LaravelScheduleJob"],"max_wait_time":5},"events":[],"swoole_tables":[],"register_providers":[],"cleaners":[],"destroy_controllers":{"enable":false,"excluded_list":[]},"swoole":{"daemonize":true,"dispatch_mode":2,"reactor_num":2,"worker_num":2,"task_worker_num":2,"task_ipc_mode":1,"task_max_request":8000,"task_tmpdir":"/dev/shm","max_request":8000,"open_tcp_nodelay":true,"pid_file":"/home/vagrant/code/ic_server_welfare/storage/laravels.pid","log_file":"/home/vagrant/code/ic_server_welfare/storage/logs/swoole-2019-09.log","log_level":4,"document_root":"/home/vagrant/code/ic_server_welfare/public","buffer_output_size":2097152,"socket_buffer_size":134217728,"package_max_length":4194304,"reload_async":true,"max_wait_time":60,"enable_reuse_port":true,"enable_coroutine":false,"http_compression":false},"enable_gzip":false,"process_prefix":"/home/vagrant/code/ic_server_welfare","ignore_check_pid":false},"laravel":{"root_path":"/home/vagrant/code/ic_server_welfare","static_path":"/home/vagrant/code/ic_server_welfare/public","cleaners":[],"register_providers":[],"destroy_controllers":{"enable":false,"excluded_list":[]},"is_lumen":true,"_SERVER":{"LESSOPEN":"| /usr/bin/lesspipe %s","MAIL":"/var/mail/vagrant","USER":"vagrant","SSH_CLIENT":"10.0.2.2 50108 22","LANGUAGE":"en_US:","SHLVL":"1","HOME":"/home/vagrant","OLDPWD":"/home/vagrant","SSH_TTY":"/dev/pts/0","LOGNAME":"vagrant","_":"/usr/bin/php","XDG_SESSION_ID":"6","TERM":"cygwin","RBENV_SHELL":"bash","PATH":"/home/vagrant/.composer/vendor/bin:/usr/local/go/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/vagrant/.dotnet/tools","S_COLORS":"auto","XDG_RUNTIME_DIR":"/run/user/1000","LANG":"en_US.UTF-8","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","SHELL":"/bin/bash","LESSCLOSE":"/usr/bin/lesspipe %s %s","LC_ALL":"en_US.UTF-8","PWD":"/home/vagrant/code/ic_server_welfare","SSH_CONNECTION":"10.0.2.2 50108 10.0.2.15 22","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","PHP_SELF":"/home/vagrant/code/ic_server_welfare/artisan","SCRIPT_NAME":"/home/vagrant/code/ic_server_welfare/artisan","SCRIPT_FILENAME":"/home/vagrant/code/ic_server_welfare/artisan","PATH_TRANSLATED":"/home/vagrant/code/ic_server_welfare/artisan","DOCUMENT_ROOT":"","REQUEST_TIME_FLOAT":1569488081.38418,"REQUEST_TIME":1569488081,"argv":["/home/vagrant/code/ic_server_welfare/artisan","laravels","config","--daemonize"],"argc":4,"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"0uUBt7t4fFIttyqkyLxDhLC7gn9361Yt","APP_TIMEZONE":"PRC","DB_CONNECTION":"mysql","DB_HOST_R":"192.168.2.232","DB_HOST_W":"192.168.2.232","DB_PORT":"3306","DB_DATABASE":"ic_welfare","DB_USERNAME":"ic_welfare","DB_PASSWORD":"ic_welfare#zsyM","DB_PREFIX":"ic_","IC_DATA_DB_HOST_R":"192.168.2.232","IC_DATA_DB_HOST_W":"192.168.2.232","IC_DATA_DB_PORT":"3306","IC_DATA_DB_DATABASE":"ic_data","IC_DATA_DB_USERNAME":"ic_data","IC_DATA_DB_PASSWORD":"ic_data#zsyM","IC_DATA_DB_PREFIX":"ic_","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","SYSTEM_CODE":"09","SYSTEM_NAME":"IC业务助手福利中心服务","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"61009","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.235","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","IC_AUTH_API":"http://authapi.icsales.cc","RobotUrl":"https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11","SHELL_VERBOSITY":0},"_ENV":{"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"0uUBt7t4fFIttyqkyLxDhLC7gn9361Yt","APP_TIMEZONE":"PRC","DB_CONNECTION":"mysql","DB_HOST_R":"192.168.2.232","DB_HOST_W":"192.168.2.232","DB_PORT":"3306","DB_DATABASE":"ic_welfare","DB_USERNAME":"ic_welfare","DB_PASSWORD":"ic_welfare#zsyM","DB_PREFIX":"ic_","IC_DATA_DB_HOST_R":"192.168.2.232","IC_DATA_DB_HOST_W":"192.168.2.232","IC_DATA_DB_PORT":"3306","IC_DATA_DB_DATABASE":"ic_data","IC_DATA_DB_USERNAME":"ic_data","IC_DATA_DB_PASSWORD":"ic_data#zsyM","IC_DATA_DB_PREFIX":"ic_","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","SYSTEM_CODE":"09","SYSTEM_NAME":"IC业务助手福利中心服务","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"61009","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.235","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","IC_AUTH_API":"http://authapi.icsales.cc","RobotUrl":"https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11","SHELL_VERBOSITY":0}}}
\ No newline at end of file
{"server":{"listen_ip":"0.0.0.0","listen_port":"61009","socket_type":1,"enable_coroutine_runtime":false,"server":"LaravelS","handle_static":false,"laravel_base_path":"/home/vagrant/code/ic_server_welfare","inotify_reload":{"enable":false,"watch_path":"/home/vagrant/code/ic_server_welfare","file_types":[".php"],"excluded_dirs":[],"log":true},"event_handlers":[],"websocket":{"enable":false},"sockets":[],"processes":[],"timer":{"enable":true,"jobs":["Hhxsv5\\LaravelS\\Illuminate\\LaravelScheduleJob","App\\Jobs\\Timer\\ResetExchangeSettingsCronJob"],"max_wait_time":5},"events":[],"swoole_tables":[],"register_providers":[],"cleaners":[],"destroy_controllers":{"enable":false,"excluded_list":[]},"swoole":{"daemonize":true,"dispatch_mode":2,"reactor_num":2,"worker_num":2,"task_worker_num":2,"task_ipc_mode":1,"task_max_request":8000,"task_tmpdir":"/dev/shm","max_request":8000,"open_tcp_nodelay":true,"pid_file":"/home/vagrant/code/ic_server_welfare/storage/laravels.pid","log_file":"/home/vagrant/code/ic_server_welfare/storage/logs/swoole-2019-09.log","log_level":4,"document_root":"/home/vagrant/code/ic_server_welfare/public","buffer_output_size":2097152,"socket_buffer_size":134217728,"package_max_length":4194304,"reload_async":true,"max_wait_time":60,"enable_reuse_port":true,"enable_coroutine":false,"http_compression":false},"enable_gzip":false,"process_prefix":"/home/vagrant/code/ic_server_welfare","ignore_check_pid":false},"laravel":{"root_path":"/home/vagrant/code/ic_server_welfare","static_path":"/home/vagrant/code/ic_server_welfare/public","cleaners":[],"register_providers":[],"destroy_controllers":{"enable":false,"excluded_list":[]},"is_lumen":true,"_SERVER":{"LESSOPEN":"| /usr/bin/lesspipe %s","MAIL":"/var/mail/vagrant","USER":"vagrant","SSH_CLIENT":"10.0.2.2 50108 22","LANGUAGE":"en_US:","SHLVL":"1","HOME":"/home/vagrant","OLDPWD":"/home/vagrant","SSH_TTY":"/dev/pts/0","LOGNAME":"vagrant","_":"/usr/bin/php","XDG_SESSION_ID":"6","TERM":"cygwin","RBENV_SHELL":"bash","PATH":"/home/vagrant/.composer/vendor/bin:/usr/local/go/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/vagrant/.dotnet/tools","S_COLORS":"auto","XDG_RUNTIME_DIR":"/run/user/1000","LANG":"en_US.UTF-8","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","SHELL":"/bin/bash","LESSCLOSE":"/usr/bin/lesspipe %s %s","LC_ALL":"en_US.UTF-8","PWD":"/home/vagrant/code/ic_server_welfare","SSH_CONNECTION":"10.0.2.2 50108 10.0.2.15 22","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","PHP_SELF":"/home/vagrant/code/ic_server_welfare/artisan","SCRIPT_NAME":"/home/vagrant/code/ic_server_welfare/artisan","SCRIPT_FILENAME":"/home/vagrant/code/ic_server_welfare/artisan","PATH_TRANSLATED":"/home/vagrant/code/ic_server_welfare/artisan","DOCUMENT_ROOT":"","REQUEST_TIME_FLOAT":1569563592.208595,"REQUEST_TIME":1569563592,"argv":["/home/vagrant/code/ic_server_welfare/artisan","laravels","config","--daemonize"],"argc":4,"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"0uUBt7t4fFIttyqkyLxDhLC7gn9361Yt","APP_TIMEZONE":"PRC","DB_CONNECTION":"mysql","DB_HOST_R":"192.168.2.232","DB_HOST_W":"192.168.2.232","DB_PORT":"3306","DB_DATABASE":"ic_welfare","DB_USERNAME":"ic_welfare","DB_PASSWORD":"ic_welfare#zsyM","DB_PREFIX":"ic_","IC_DATA_DB_HOST_R":"192.168.2.232","IC_DATA_DB_HOST_W":"192.168.2.232","IC_DATA_DB_PORT":"3306","IC_DATA_DB_DATABASE":"ic_data","IC_DATA_DB_USERNAME":"ic_data","IC_DATA_DB_PASSWORD":"ic_data#zsyM","IC_DATA_DB_PREFIX":"ic_","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","SYSTEM_CODE":"09","SYSTEM_NAME":"IC业务助手福利中心服务","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"61009","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.235","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","IC_AUTH_API":"http://authapi.icsales.cc","RobotUrl":"https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11","LARAVELS_TIMER":"true","SHELL_VERBOSITY":0},"_ENV":{"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"0uUBt7t4fFIttyqkyLxDhLC7gn9361Yt","APP_TIMEZONE":"PRC","DB_CONNECTION":"mysql","DB_HOST_R":"192.168.2.232","DB_HOST_W":"192.168.2.232","DB_PORT":"3306","DB_DATABASE":"ic_welfare","DB_USERNAME":"ic_welfare","DB_PASSWORD":"ic_welfare#zsyM","DB_PREFIX":"ic_","IC_DATA_DB_HOST_R":"192.168.2.232","IC_DATA_DB_HOST_W":"192.168.2.232","IC_DATA_DB_PORT":"3306","IC_DATA_DB_DATABASE":"ic_data","IC_DATA_DB_USERNAME":"ic_data","IC_DATA_DB_PASSWORD":"ic_data#zsyM","IC_DATA_DB_PREFIX":"ic_","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","SYSTEM_CODE":"09","SYSTEM_NAME":"IC业务助手福利中心服务","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"61009","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.235","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","IC_AUTH_API":"http://authapi.icsales.cc","RobotUrl":"https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11","LARAVELS_TIMER":"true","SHELL_VERBOSITY":0}}}
\ No newline at end of file
2170
\ No newline at end of file
12787
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment