123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?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';
- // 进度条
- // https://docs.laravel-excel.com/3.1/imports/progress-bar.html
- // $this->output->title('Starting import');
- // (new chatOrder)->withOutput($this->output)->import($filePath);
- // $this->output->success('Import successful');
- 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;
- }
- }
|