| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Console\Commands;
- use App\dao\Channel\ChannelList;
- use App\Facade\TableName;
- use App\Util;
- use Illuminate\Console\Command;
- use Illuminate\Support\Carbon;
- use Illuminate\Support\Facades\DB;
- class OnlineReport extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'online_report';
- /**
- * 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()
- {
- // Util::WriteLog('online_report',time());
- $where = [];
- $where[] = ['DateID', '=', date('Ymd')];
- // !empty($date_end) && $where[] = ['DateID', '<=', date('Ymd', strtotime($date_end))];
- $where[] = ['Channel' ,'=', '-1'];
- $sum = implode(',', [
- 'sum(RegPeple) as RegPeple','sum(ActivePeple) as ActivePeple','sum(PayTotal) as PayTotal','sum(DrawTotal) as DrawTotal',
- ]);
- $list = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData')
- ->where($where)
- ->selectRaw($sum)
- ->first();
- $line = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker')
- ->selectRaw('KindID,count(DISTINCT UserID) as game_count')
- ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
- ->groupBy('KindID')
- ->get();
- $online = json_encode($line);
- Util::WriteLog('online_report',$list);
- Util::WriteLog('online_report',$online);
- if($list){
- $data = [
- 'ldate' => date('Ymd'),
- 'online' => $online,
- 'register' => $list->RegPeple??0,
- 'active' => $list->ActivePeple??0,
- 'recharge' => $list->PayTotal??0,
- 'withdraw' => $list->DrawTotal??0,
- 'created' => time()
- ];
- DB::connection('mysql')->table('game-report')->insert($data);
- }
- }
- }
|