12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Console\Commands\Temp;
- use Log;
- use Illuminate\Console\Command;
- use DB;
- class FixRealReg extends Command
- {
- /**
- * 执行命令 php artisan temp:fix_read_reg
- *
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'temp:fix_read_reg';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '修复实际注册用户数';
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- print_r("======修复实际注册用户数 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
- Log::info("======修复实际注册用户数 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
- $_start = new \DateTime('2017-12-12');
- $_end = new \DateTime('2017-12-24');
- foreach (new \DatePeriod($_start, new \DateInterval('P1D'), $_end) as $d)
- {
- $date = $d->format('Y-m-d');
- $start = $date;
- $end_time = date('Y-m-d', strtotime($date) + 86400);
- $real_reg_data_res = DB::select("select distribution_channel_id,count(1) num from users u where created_at >='{$date}' and created_at <'{$end_time}' and not exists (select id from users where openid = u.openid and created_at < '{$date}' limit 1) group by distribution_channel_id");
- dump($real_reg_data_res);
- foreach ($real_reg_data_res as $item)
- {
- DB::table('order_day_stats')->where('date',$date)->where('distribution_channel_id',$item->distribution_channel_id)->update(['real_register_user_num'=>(int)$item->num]);
- }
- Log::info("======修复实际注册用户数 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
- print_r("======修复实际注册用户数 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
- }
- }
- }
|