12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Models\User;
- use App\Models\Order;
- use App\Models\Server;
- use App\Models\ServerLog;
- use App\Utils\Helper;
- use Cache;
- class V2boardCache extends Command
- {
-
- protected $signature = 'v2board:cache';
-
- protected $description = '缓存任务';
-
- public function __construct()
- {
- parent::__construct();
- }
-
- public function handle()
- {
- $this->setMonthIncome();
- $this->setMonthRegisterTotal();
- }
- private function setMonthIncome()
- {
- Cache::put(
- 'month_income',
- Order::where('created_at', '>=', strtotime(date('Y-m-1')))
- ->where('created_at', '<', time())
- ->where('status', '3')
- ->sum('total_amount')
- );
- }
- private function setMonthRegisterTotal()
- {
- Cache::put(
- 'month_register_total',
- User::where('created_at', '>=', strtotime(date('Y-m-1')))
- ->where('created_at', '<', time())
- ->count()
- );
- }
- }
|