2019-11-30 17:53:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\Order;
|
2019-12-01 21:13:27 +08:00
|
|
|
use App\Utils\Helper;
|
2019-11-30 17:53:54 +08:00
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
class SystemCache extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'system:cache';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '系统缓存任务';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->setMonthIncome();
|
|
|
|
$this->setMonthRegisterTotal();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setMonthIncome() {
|
|
|
|
Redis::set(
|
2019-12-10 11:23:14 +08:00
|
|
|
'month_income',
|
2019-11-30 17:53:54 +08:00
|
|
|
Order::where('created_at', '>', strtotime(date('Y-m-1')))
|
|
|
|
->where('created_at', '>', time())
|
|
|
|
->where('status', '3')
|
|
|
|
->where('callback_no', '!=', NULL)
|
|
|
|
->sum('total_amount')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setMonthRegisterTotal() {
|
|
|
|
Redis::set(
|
2019-12-10 11:23:14 +08:00
|
|
|
'month_register_total',
|
2019-11-30 17:53:54 +08:00
|
|
|
User::where('created_at', '>', strtotime(date('Y-m-1')))
|
|
|
|
->where('created_at', '>', time())
|
|
|
|
->count()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|