123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use app\model\Customer;
- use app\model\CustomerVisitLog;
- class Defreshcust extends Command
- {
- protected function configure()
- {
- $this->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." 条记录处理完毕");
- }
- }
|