12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\admin\model;
- use Curl\Curl;
- use GuzzleHttp\Client;
- use think\facade\Db;
- class TaxiCar
- {
- protected $path = "http://dlyz.chefudang.cn:8102/transportapp/queryVehicleList?";
- protected $curl = null;
- public function __construct()
- {
- $this->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<strlen($str);$i++){
- if(is_numeric($str[$i])){
- $result.=$str[$i];
- }
- }
- return $result;
- }
- }
|