setName('defreshcust') ->setDescription('deal old customer data'); } protected function execute(Input $input, Output $output) { $where = []; $records = Customer::where($where)->field('id,phone')->select(); $i = 0; foreach($records as $item){ if(strlen($item->phone) == 11){ $output->writeln($item->phone); $cypherhone = cypherphone($item->phone); $output->writeln($i); $output->writeln($cypherhone); $i++; Customer::where('id',$item->id)->update(['phone' => $cypherhone]); } // //if(CustomerVisitLog::where('customer_id', $item->id)->find()){ // $customer = Customer::find($item->id); // $customer->fresh = 0; // if($customer->save()){ // $output->writeln($i); // $i++; // } // //} } $output->writeln($i." 条记录处理完毕"); } }