12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php declare(strict_types=1);
- namespace app\admin\command;
- use app\model\CommonModel;
- use app\model\ServiceModel;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Cache;
- //处理服务的活动状态
- class HandleServiceStatus extends Command
- {
- protected function configure()
- {
- // parent::configure(); // TODO: Change the autogenerated stub
- $this->setName('HandleServiceStatus')->setDescription('处理服务的活动状态');
- }
- protected function execute(Input $input, Output $output)
- {
- $key = 'handle_service_status';
- $redis = Cache::store('redis')->get($key);
- if (!$redis) {
- Cache::set($key, 1, 60);
- $date = date('Y-m-d H:i:s');
- ServiceModel::where('is_del', CommonModel::$del_normal)
- ->where('starttime', '<=', $date)
- ->where('endtime', '>', $date)
- ->save(['activity_status' => ServiceModel::$activity_status_ing, 'updaterid' => 0, 'updater' => '脚本', 'updatetime' => $date]);
- ServiceModel::where('is_del', CommonModel::$del_normal)
- ->where('endtime', '<', $date)
- ->save(['activity_status' => ServiceModel::$activity_status_end, 'updaterid' => 0, 'updater' => '脚本', 'updatetime' => $date]);
- Cache::set($key, 0);
- }
- }
- }
|