| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Console\Commands;
- use App\Facade\TableName;
- use App\Game\GameCard;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Redis;
- class RecordThreeGameYesterday extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'record_three_game_yesterday';
- /**
- * 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()
- {
- // 今日执行昨日数据
- $DateID = Carbon::yesterday()->format('Ymd');
- $only=GameCard::where('brand','OnlyPlay')->where('state','<>',0)->pluck('gid')->toArray();
- $pg=GameCard::where('brand','PG')->where('state','<>',0)->pluck('gid')->toArray();
- $pp=GameCard::where('brand','PP')->where('state','<>',0)->pluck('gid')->toArray();
- $atmosfera=[71,74,85,86,87,88,89,92,93];
- $platform = ['only'=>$only,'atmosfera'=>$atmosfera,'pg'=>$pg,'pp'=>$pp];
- foreach ($platform as $pItem=>$gameType){
- $platformRecord = [
- 'ldate' => $DateID,
- 'platform' => $pItem,
- 'all_bet' => Redis::get('platform_'.$pItem.'_bet')?:0,
- 'all_win' => Redis::get('platform_'.$pItem.'_win')?:0,
- 'current_bet' => Redis::get('platform_'.$pItem.'_bet_'.$DateID)?:0,
- 'current_win' => Redis::get('platform_'.$pItem.'_win_'.$DateID)?:0,
- 'current_play' =>Redis::get('platform_'.$pItem.'_play_'.$DateID)?:0,
- // 'sub_detail' => ''
- ];
- // $gameType = ($pItem == 'only'?$only:$atmosfera);
- if(is_array($gameType)){
- $subData = [];
- foreach ($gameType as $item){
- $betkey = 'platform_'.$pItem.'_'.$item. '_bet_' . $DateID;
- $winkey = 'platform_'.$pItem.'_'.$item. '_win_' . $DateID;
- $playkey = 'platform_'.$pItem.'_'.$item.'_play_' . $DateID;
- $subData[$item] = ['current_bet' => Redis::get($betkey)?:0,'current_win' =>Redis::get($winkey)?:0,'current_play' =>Redis::get($playkey)?:0 ];
- }
- $platformRecord['sub_detail'] = json_encode($subData);
- }
- DB::connection('mysql')->table('record_platform_data')->updateOrInsert([ 'ldate' => $DateID, 'platform' => $pItem,],$platformRecord);
- }
- }
- }
|