TaxiChauffeur.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\admin\service;
  3. use Curl\Curl;
  4. use GuzzleHttp\Client;
  5. use think\facade\Db;
  6. /**
  7. * Class TaxiChauffeur
  8. * @package app\service
  9. */
  10. class TaxiChauffeur
  11. {
  12. protected $client;
  13. protected $curl;
  14. public $url = 'http://106.37.189.144:8080/staffcert-web/public/queryStaffCertFromTranscert.json';
  15. public function __construct()
  16. {
  17. $this->client = new Client();
  18. $this->curl = new Curl();
  19. }
  20. public function getChauffeurData($page,$size)
  21. {
  22. $data = Db::table('taxi_chauffeur_copy1')
  23. ->field('chauffeurid,card_num,areacode,fullname,is_test')
  24. ->page($page,$size)
  25. ->select()
  26. ->each(function ($item){
  27. $item['areacode'] = substr_replace($item['areacode'],'0000',2);
  28. return $item;
  29. });
  30. foreach ($data as $item){
  31. dump($this->selectRes($item));
  32. }
  33. return ;
  34. }
  35. public function updateIsLegitimate($id)
  36. {
  37. $data = Db::table('taxi_chauffeur_copy1')
  38. ->where('chauffeurid','=',$id)
  39. ->update(['is_legitimate'=>2]);
  40. return $data;
  41. }
  42. /**
  43. * @param $data
  44. * @return bool|mixed
  45. */
  46. public function selectRes($data)
  47. {
  48. $infos = [
  49. 'provinceCode'=>$data['areacode'],
  50. 'idCard'=>$data['card_num'],
  51. 'staffName'=>$data['fullname']
  52. ];
  53. if($this->curl->post($this->url,$infos)->response != '') {
  54. $this->updateIsLegitimate($data['chauffeurid']);
  55. }else{
  56. return 'no legitimate'.$data['chauffeurid'];
  57. }
  58. }
  59. }