1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\admin\command;
- use app\admin\model\MobileExportLog;
- use app\common\service\MobileExportCsv;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Db;
- class MobileExportCommand extends Command
- {
- protected function configure()
- {
- $this
- ->setName('mobile:export');
- }
- protected function execute(Input $input, Output $output)
- {
- if(MobileExportLog::where('status',1)->find()){
- return;
- }
- $export=MobileExportLog::where('status',0)->find();
- if(!$export){
- return;
- }
- $export['status']=1;
- $export->save();
- try {
- $list=Db::query($export['sql']);
- $listCount=count($list);
- self::log("【{$export['id']}】共{$listCount}条数据");
- MobileExportCsv::export($list,$export);
- }catch (\Exception $e){
- Db::rollback();
- $export['status']=3;
- $export->save();
- self::logError($e);
- }
- }
- }
|