GenerateOrderStat.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: songdb
  5. * Date: 2017/12/26
  6. * Time: 下午5:26
  7. */
  8. namespace App\Console\Commands\Trade;
  9. use App\Modules\Trade\Services\OrderStatService;
  10. use App\Modules\Channel\Services\ChannelService;
  11. use Log;
  12. use Illuminate\Console\Command;
  13. class GenerateOrderStat extends Command
  14. {
  15. /**
  16. * 执行命令 php artisan generate_order_stat
  17. *
  18. * The name and signature of the console command.
  19. *
  20. * @var string
  21. */
  22. protected $signature = 'generate_order_stat';
  23. /**
  24. * The console command description.
  25. *
  26. * @var string
  27. */
  28. protected $description = '渠道订单统计数据生成';
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. print_r("======渠道订单统计数据生成 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
  37. Log::info("======渠道订单统计数据生成 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
  38. $channels = ChannelService::getAllChannels();
  39. $date = date('Y-m-d',strtotime('-1 day'));
  40. if(count($channels))
  41. {
  42. $channels->each(function($channel) use($date){
  43. OrderStatService::add($channel->id, $date);
  44. });
  45. }
  46. Log::info("======渠道订单统计数据生成 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
  47. print_r("======渠道订单统计数据生成 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
  48. }
  49. }