ImportOrder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Imports\chatOrder;
  4. use Illuminate\Console\Command;
  5. use Maatwebsite\Excel\Facades\Excel;
  6. class ImportOrder extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'importOrder {type} {filepath}';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '订单数据导入';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. $type = $this->argument('type');
  37. $file_path = $this->argument('filepath');
  38. //路径相对于项目根目录即 /public
  39. if(empty($type) || empty($file_path)){
  40. dd('请输入完整参数');
  41. }
  42. //图文咨询订单导入
  43. if($type == 'chat'){
  44. $this->makeChat($file_path);
  45. }
  46. }
  47. public function makeChat($file_path)
  48. {
  49. $this->imports($file_path);
  50. }
  51. public function imports($filePath)
  52. {
  53. $filePath = './public/import/' . $filePath . '.xls';
  54. Excel::import(new chatOrder(), $filePath);
  55. //delete from bm_docter_settings where docter_id = 10002;
  56. //delete from bm_order_packs where order_id in (select docter_id from bm_orders where docter_id=10002 );
  57. //delete from bm_order_patients where order_id in (select id from bm_orders where docter_id=10002 );
  58. //delete from bm_order_vaccines where order_id in (select id from bm_orders where docter_id=10002 );
  59. //delete from bm_order_nurses where order_id in (select id from bm_orders where docter_id= 10002);
  60. //delete from bm_docters where id = 10002;
  61. //delete from bm_docter_organization where docter_id = 10002;
  62. }
  63. }