Kernel.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace App\Console;
  3. use App\Console\Commands\AutoPayment;
  4. use App\Console\Commands\EveryDayInfo;
  5. use App\Models\Goodtest;
  6. use App\Models\Ordertest;
  7. //<<<<<<< HEAD
  8. //use Carbon\Carbon;
  9. //use Illuminate\Console\Scheduling\Schedule;
  10. //use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  11. //=======
  12. use App\Models\User;
  13. use App\Models\UserCert;
  14. use Carbon\Carbon;
  15. use Illuminate\Console\Scheduling\Schedule;
  16. use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  17. use Illuminate\Support\Facades\DB;
  18. //>>>>>>> 9aa477479386789a8615d89285e74706ec72fbab
  19. use Illuminate\Support\Facades\Log;
  20. class Kernel extends ConsoleKernel
  21. {
  22. /**
  23. * The Artisan commands provided by your application.
  24. *
  25. * @var array
  26. */
  27. protected $commands = [
  28. AutoPayment::class,
  29. EveryDayInfo::class,
  30. ];
  31. /**
  32. * Define the application's command schedule.
  33. *
  34. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  35. * @return void
  36. */
  37. protected function schedule(Schedule $schedule)
  38. {
  39. // $schedule->command('inspire')
  40. // ->hourly();
  41. $schedule->call(function (){
  42. $now=Carbon::now()->timestamp;
  43. $data=Goodtest::whereNotNull('show_time')->where('is_deleted',0)->get();
  44. foreach ($data as $k=>$v){
  45. $good=Goodtest::find($v->id);
  46. if (strtotime($v->show_time)<$now&&strtotime($v->off_time)>$now){
  47. $good->is_show=3;
  48. //<<<<<<< HEAD
  49. // }elseif (strtotime($v->show_time)<$now){
  50. // $good->is_show=1;
  51. // }elseif (strtotime($v->off_time)<$now){
  52. // $good->is_show=4;
  53. //=======
  54. }elseif (strtotime($v->show_time)>$now&&strtotime($v->off_time)>$now+3){
  55. $good->is_show=1;
  56. }elseif (strtotime($v->off_time)<$now+3){
  57. $good->is_show=4;
  58. $good->show_time=null;
  59. //>>>>>>> 9aa477479386789a8615d89285e74706ec72fbab
  60. }
  61. $good->save();
  62. }
  63. Log::error('111');
  64. Log::error('111');
  65. })->everyMinute();
  66. $schedule->call(function (){
  67. $data=Ordertest::where('status',3)->where('pay_status',2)->whereNotNull('receive_time')->get();
  68. foreach ($data as $k=>$v){
  69. $now=Carbon::now()->timestamp;
  70. if (strtotime($v->receice)>$now){
  71. $order=Ordertest::find($v->id);
  72. $order->status=4;
  73. $order->save();
  74. Log::error('订单编号为'.$v->order_num.'的商品已经自动收货');
  75. }
  76. }
  77. })->everyMinute();
  78. //自动支付
  79. $schedule->command('autoPayment')->everyMinute();
  80. $schedule->call(function (){
  81. $re=User::where('cert_status',2)->whereNull('deleted_at')->select('id','mobile')->get();
  82. $s=0;
  83. foreach ($re as $k=>$v){
  84. $res=UserCert::where('user_id',$v->id)->get();
  85. foreach ($res as $ke=>$va){
  86. if ($va->recom_audit==1&& $va->agent_audit==1){
  87. Log::error($v->mobile);
  88. }
  89. }
  90. }
  91. Log::error('这是相关数据'.$s);
  92. })->dailyAt('15:32');
  93. }
  94. /**
  95. * Register the commands for the application.
  96. *
  97. * @return void
  98. */
  99. protected function commands()
  100. {
  101. $this->load(__DIR__.'/Commands');
  102. require base_path('routes/console.php');
  103. }
  104. }