123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\admin\command;
- use app\admin\model\Admin;
- use app\admin\model\MobileExportLog;
- use app\common\service\MobileExport;
- 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}条数据");
- MobileExport::export($list,$export);
- }catch (\Exception $e){
- Db::rollback();
- $export['status']=3;
- $export->save();
- self::logError($e);
- }
- }
- }
|