RecordThreeGameYesterday.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Facade\TableName;
  4. use App\Game\GameCard;
  5. use Carbon\Carbon;
  6. use Illuminate\Console\Command;
  7. use Illuminate\Support\Facades\DB;
  8. use Illuminate\Support\Facades\Redis;
  9. class RecordThreeGameYesterday extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'record_three_game_yesterday';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $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. // 今日执行昨日数据
  40. $DateID = Carbon::yesterday()->format('Ymd');
  41. $only=GameCard::where('brand','OnlyPlay')->where('state','<>',0)->pluck('gid')->toArray();
  42. $pg=GameCard::where('brand','PG')->where('state','<>',0)->pluck('gid')->toArray();
  43. $pp=GameCard::where('brand','PP')->where('state','<>',0)->pluck('gid')->toArray();
  44. $atmosfera=[71,74,85,86,87,88,89,92,93];
  45. $platform = ['only'=>$only,'atmosfera'=>$atmosfera,'pg'=>$pg,'pp'=>$pp];
  46. foreach ($platform as $pItem=>$gameType){
  47. $platformRecord = [
  48. 'ldate' => $DateID,
  49. 'platform' => $pItem,
  50. 'all_bet' => Redis::get('platform_'.$pItem.'_bet')?:0,
  51. 'all_win' => Redis::get('platform_'.$pItem.'_win')?:0,
  52. 'current_bet' => Redis::get('platform_'.$pItem.'_bet_'.$DateID)?:0,
  53. 'current_win' => Redis::get('platform_'.$pItem.'_win_'.$DateID)?:0,
  54. 'current_play' =>Redis::get('platform_'.$pItem.'_play_'.$DateID)?:0,
  55. // 'sub_detail' => ''
  56. ];
  57. // $gameType = ($pItem == 'only'?$only:$atmosfera);
  58. if(is_array($gameType)){
  59. $subData = [];
  60. foreach ($gameType as $item){
  61. $betkey = 'platform_'.$pItem.'_'.$item. '_bet_' . $DateID;
  62. $winkey = 'platform_'.$pItem.'_'.$item. '_win_' . $DateID;
  63. $playkey = 'platform_'.$pItem.'_'.$item.'_play_' . $DateID;
  64. $subData[$item] = ['current_bet' => Redis::get($betkey)?:0,'current_win' =>Redis::get($winkey)?:0,'current_play' =>Redis::get($playkey)?:0 ];
  65. }
  66. $platformRecord['sub_detail'] = json_encode($subData);
  67. }
  68. DB::connection('mysql')->table('record_platform_data')->updateOrInsert([ 'ldate' => $DateID, 'platform' => $pItem,],$platformRecord);
  69. }
  70. }
  71. }