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-17 16:15:36 +08:00
|
|
|
use App\Models\Server;
|
|
|
|
use App\Models\ServerLog;
|
2019-12-01 21:13:27 +08:00
|
|
|
use App\Utils\Helper;
|
2020-01-08 01:34:48 +08:00
|
|
|
use Cache;
|
2019-11-30 17:53:54 +08:00
|
|
|
|
2019-12-30 21:05:48 +08:00
|
|
|
class V2boardCache extends Command
|
2019-11-30 17:53:54 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-12-30 21:05:48 +08:00
|
|
|
protected $signature = 'v2board:cache';
|
2019-11-30 17:53:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-12-30 21:05:48 +08:00
|
|
|
protected $description = '缓存任务';
|
2019-11-30 17:53:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() {
|
2020-01-08 01:34:48 +08:00
|
|
|
Cache::put(
|
2019-12-10 11:23:14 +08:00
|
|
|
'month_income',
|
2019-12-10 11:25:53 +08:00
|
|
|
Order::where('created_at', '>=', strtotime(date('Y-m-1')))
|
|
|
|
->where('created_at', '<', time())
|
2019-11-30 17:53:54 +08:00
|
|
|
->where('status', '3')
|
|
|
|
->sum('total_amount')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setMonthRegisterTotal() {
|
2020-01-08 01:34:48 +08:00
|
|
|
Cache::put(
|
2019-12-10 11:23:14 +08:00
|
|
|
'month_register_total',
|
2019-12-10 11:25:53 +08:00
|
|
|
User::where('created_at', '>=', strtotime(date('Y-m-1')))
|
|
|
|
->where('created_at', '<', time())
|
2019-11-30 17:53:54 +08:00
|
|
|
->count()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|