| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Carbon;
- use Illuminate\Support\Facades\DB;
- class StockChange extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'stock_change';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- // 过滤试玩场
- $blacklist = [32, 33, 39];
- $list = DB::table('QPPlatformDB.dbo.GameRoomInfo')
- ->whereNotIn('ServerID', $blacklist)
- ->get();
- $stock = [];
- foreach ($list as $value) {
- $RoomStock = $value->RoomStock;
- $RoomStock = $RoomStock ? explode(':', explode(';', $RoomStock)[0])[1] : 0;
- $stock[] = ['stock' => (int)$RoomStock, 'serverID' => $value->ServerID, 'type' => 1, 'mydate' => date('Y-m-d H:i:s')];
- }
- // 首先把标识符取掉
- DB::table('agent.dbo.stock_change')->whereDate('mydate', date('Y-m-d'))->update(['identifier' => 0]);
- // 插入数据
- DB::table('agent.dbo.stock_change')->insert($stock);
- }
- }
|