GenerateCpBookBetweenStat.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * zhoulj
  4. * 2018-05-15
  5. */
  6. namespace App\Console\Commands\CP;
  7. use App\Modules\CP\Services\GenerateCpBookStatService;
  8. use Illuminate\Console\Command;
  9. use Log;
  10. class GenerateCpBookBetweenStat extends Command
  11. {
  12. /**
  13. * 执行命令 php artisan cp_generate_cp_book_between_stat 2018-10-01 2018-11-01
  14. *
  15. * The name and signature of the console command.
  16. *
  17. * @var string
  18. */
  19. protected $signature = 'cp_generate_cp_book_between_stat {start_date} {end_date}';
  20. /**
  21. * The console command description.
  22. *
  23. * @var string
  24. */
  25. protected $description = 'CP图书订阅指定时间区间数据生成';
  26. /**
  27. * Execute the console command.
  28. * 注意:start_date <= 计算区间 <= end_date
  29. * @return mixed
  30. */
  31. public function handle()
  32. {
  33. print_r("======CP图书订阅指定时间区间数据生成 【任务执行开始】=====" . date("y-m-d H:i:s" . "\n"));
  34. Log::info("======CP图书订阅指定时间区间数据生成【任务执行开始】=====" . date("y-m-d H:i:s" . "\n"));
  35. $start_date = $this->argument('start_date');
  36. $end_date = $this->argument('end_date');
  37. if(empty($start_date) || empty($end_date)){
  38. Log::info('GenerateCpBookBetweenStat param null:start_date:'.$start_date.' end_date:'.$end_date);
  39. }
  40. $month = date('Y-m',strtotime($start_date));
  41. $calculate_date = $end_date;
  42. $end_date = date('Y-m-d',strtotime($end_date) - 24*3600);
  43. Log::info('start_date:'.$start_date.' end_date:'.$end_date.' month:'.$month.' calculate_date:'.$calculate_date);
  44. GenerateCpBookStatService::generateCpBookBetweenStat($start_date,$end_date,$month,$calculate_date);
  45. Log::info("======CP图书订阅指定时间区间数据生成 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
  46. print_r("======CP图书订阅指定时间区间数据生成 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
  47. }
  48. }