OnlineReport.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\dao\Channel\ChannelList;
  4. use App\Facade\TableName;
  5. use App\Util;
  6. use Illuminate\Console\Command;
  7. use Illuminate\Support\Carbon;
  8. use Illuminate\Support\Facades\DB;
  9. class OnlineReport extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'online_report';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = 'Command description';
  23. /**
  24. * Create a new command instance.
  25. *
  26. * @return void
  27. */
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. }
  32. /**
  33. * Execute the console command.
  34. *
  35. * @return mixed
  36. */
  37. public function handle()
  38. {
  39. // Util::WriteLog('online_report',time());
  40. $where = [];
  41. $where[] = ['DateID', '=', date('Ymd')];
  42. // !empty($date_end) && $where[] = ['DateID', '<=', date('Ymd', strtotime($date_end))];
  43. $where[] = ['Channel' ,'=', '-1'];
  44. $sum = implode(',', [
  45. 'sum(RegPeple) as RegPeple','sum(ActivePeple) as ActivePeple','sum(PayTotal) as PayTotal','sum(DrawTotal) as DrawTotal',
  46. ]);
  47. $list = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData')
  48. ->where($where)
  49. ->selectRaw($sum)
  50. ->first();
  51. $line = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker')
  52. ->selectRaw('KindID,count(DISTINCT UserID) as game_count')
  53. ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
  54. ->groupBy('KindID')
  55. ->get();
  56. $online = json_encode($line);
  57. Util::WriteLog('online_report',$list);
  58. Util::WriteLog('online_report',$online);
  59. if($list){
  60. $data = [
  61. 'ldate' => date('Ymd'),
  62. 'online' => $online,
  63. 'register' => $list->RegPeple??0,
  64. 'active' => $list->ActivePeple??0,
  65. 'recharge' => $list->PayTotal??0,
  66. 'withdraw' => $list->DrawTotal??0,
  67. 'created' => time()
  68. ];
  69. DB::connection('mysql')->table('game-report')->insert($data);
  70. }
  71. }
  72. }