overTimeOrder.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Order;
  4. use App\Models\SystemConfig;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Log;
  7. class overTimeOrder extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'overOrder';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '超时';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. Log::info('超时命令'.date('Y-m-d H:is',time()).PHP_EOL);
  38. return ;
  39. $config_chat = SystemConfig::get('docter_config','chat_complete_time');
  40. $config_phone = SystemConfig::get('docter_config','phone_complete_time');
  41. // 换算为秒
  42. $config_chat = $config_chat*60;
  43. $config_phone = $config_phone*60;
  44. $inOrder = Order::with('orderPatient')->where(['order_status'=>3,'payment_status'=>2])->get();
  45. $catNewIds = [];
  46. $menNewIds = [];
  47. foreach ($inOrder as $k=>$v){
  48. if ($v['product_type']==1){
  49. if ((time()-$v['receiving_time'])>=$config_chat){
  50. $catNewIds[$k] = $v['id'];
  51. }
  52. }else if($v['product_type']==2){
  53. if ((time()-$v['receiving_time'])>=$config_phone){
  54. $catNewIds[$k] = $v['id'];
  55. }
  56. }else if($v['product_type']==3){
  57. if ((time()-$v['receiving_time'])>=(1*60*60*24)){
  58. $menNewIds[$k] = $v['id'];
  59. }
  60. }
  61. }
  62. if ($catNewIds || $menNewIds){
  63. // 操作图文和电话订单为已完成
  64. Order::whereIn('id',$catNewIds)->update(['order_status'=>4]);
  65. // 操作门诊订单为已超时
  66. Order::whereIn('id',$menNewIds)->update(['order_status'=>6]);
  67. }
  68. }
  69. }