db = Db::connect('mysql0'); $this->client = new Client(); $this->curl = new Curl(); } /** * 处理数据 * @throws \think\db\exception\DbException */ public function editData() { $this->db->table('total_cars') ->field('id,num,cert') ->chunk(1000,function ($list){ foreach ($list as $item){ //$certiticate = $this->findNum($item['Certiticate']); $this->getCarRes($item['num'],$item['cert'],$item['id']); } }); } /** * 更新车证状态 * @param $plate_number * @param $vin_no * @param $car_id * @throws \think\db\exception\DbException */ public function getCarRes($plate_number,$Certiticate,$car_id) { $plate_number = urlencode($plate_number); $params = 'VehicleNo='.$plate_number.'&TransCertificateCode='.$Certiticate.'&Page=1&PageSize=10'; $url = $this->path.$params; $re = curlGet($url); if(strpos($re,'营运') !== false ){ $this->db->table('total_cars') ->where('id','=',$car_id) ->update(['is_leg'=>'有']); } // if(strpos($re,'注销') !== false || strpos($re,'服务器内部错误') !== false){ // $this->db->table('taxi_cars') // ->where('carid','=',$car_id) // ->update(['is_test'=>1]); // } } /** * 字符串中提取数字 * @param string $str * @return string */ public function findNum($str='') { $str=trim($str); if(empty($str)){return '';} $result=''; for($i=0;$i