123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\admin\command;
- use app\admin\model\MobileUpload;
- use app\common\service\MobileImport;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
- use think\Cache;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Db;
- class MobileImportCommand extends Command
- {
- protected function configure()
- {
- $this
- ->setName('mobile:import');
- }
- protected function execute(Input $input, Output $output)
- {
- if(MobileUpload::where('status',1)->find()){
- return;
- }
- $upload= MobileUpload::where('status',0)->find();
- if(!$upload){
- return;
- }
- $upload['status']=1;
- $upload->save();
- try {
- MobileImport::import($upload['file'],$upload['admin_id'],$upload['params']['type'],$upload['params']['status'],$upload);
- }catch (\Exception $e){
- Db::rollback();
- $upload['remark']=$e->getMessage();
- $upload['status']=2;
- $upload->save();
- self::logError($e);
- }
- }
- }
|