123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Console\Commands;
- use App\Models\DwbsAdmin;
- use App\Models\DwbsUser;
- use App\Models\DwbsWarea;
- use App\Models\OrderDetail;
- use App\Models\Store;
- use App\Models\User;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\DB;
- class CacheStoresWareaInfo extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'cache_stores_warea_info';
- /**
- * 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()
- {
- Log::info('开始缓存店铺战区信息'.microtime());
- $user_ids=Store::pluck('user_id');
- Cache::put('user_ids',$user_ids,mt_rand(600,1800));
- $store_user_ids=Store::pluck('user_id', 'id')->toArray();
- Cache::put('store_user_ids',$store_user_ids,mt_rand(600,1800));
- $wareas=DwbsWarea::pluck('name', 'id');
- Cache::put('wareas',$wareas,mt_rand(1800,3600),mt_rand(600,1800));
- $warea_user_ids=DwbsUser::withTrashed()->whereIn('id', $user_ids)->pluck('warea_id', 'id');
- Cache::put('warea_user_ids',$warea_user_ids,mt_rand(600,1800));
- $level_user=DwbsUser::whereIn('id', $user_ids)->pluck('level', 'id');
- Cache::put('level_user',$level_user,mt_rand(600,1800));
- Log::info('结束缓存店铺战区信息'.microtime());
- }
- }
|