12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\common\command;
- use app\common\model\Mobile;
- use app\service\EsMobileService;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Db;
- class DelMobileCommand extends Command{
- protected function configure()
- {
- $this->setName('del:mobile')->setDescription('订单超时关闭');
- }
- protected function execute(Input $input, Output $output)
- {
- $count=0;
- Mobile::where('type',1)->where('id','<',137372423)->chunk(10000,function ($mobiles)use (&$count){
- foreach ($mobiles as $mobile){
- try {
- $existsInEs=es()->get([
- 'index'=>EsMobileService::index(),
- 'id'=>$mobile['id']
- ]);
- }catch (\Exception $exception){
- $existsInEs=false;
- }
- if($existsInEs){
- EsMobileService::delMobiles([$mobile['id']]);
- $count+=1;
- $this->output->info($count);
- user_log('DelMobileCommand',$mobile['id']);
- }else {
-
-
- }
- }
- });
- }
- }
|