12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Console\Commands;
- use App\Imports\chatOrder;
- use Illuminate\Console\Command;
- use Maatwebsite\Excel\Facades\Excel;
- class ImportOrder extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'importOrder {type} {filepath}';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '订单数据导入';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $type = $this->argument('type');
- $file_path = $this->argument('filepath');
- //路径相对于项目根目录即 /public
- if(empty($type) || empty($file_path)){
- dd('请输入完整参数');
- }
- //图文咨询订单导入
- if($type == 'chat'){
- $this->makeChat($file_path);
- }
- }
- public function makeChat($file_path)
- {
- $this->imports($file_path);
- }
- public function imports($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xls';
- Excel::import(new chatOrder(), $filePath);
- //delete from bm_docter_settings where docter_id = 10002;
- //delete from bm_order_packs where order_id in (select docter_id from bm_orders where docter_id=10002 );
- //delete from bm_order_patients where order_id in (select id from bm_orders where docter_id=10002 );
- //delete from bm_order_vaccines where order_id in (select id from bm_orders where docter_id=10002 );
- //delete from bm_order_nurses where order_id in (select id from bm_orders where docter_id= 10002);
- //delete from bm_docters where id = 10002;
- //delete from bm_docter_organization where docter_id = 10002;
- }
- }
|