LogisticZopService.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Services;
  3. use App\library\zop\ZopClient;
  4. use App\library\zop\ZopProperties;
  5. use App\library\zop\ZopRequest;
  6. class LogisticZopService
  7. {
  8. public function get(array $logisticNums)
  9. {
  10. $url = config('api_logistic.ZTO.url');
  11. $xAppKey = config('api_logistic.ZTO.x-appKey');
  12. $appSecret = config('api_logistic.ZTO.appSecret');
  13. $properties = new ZopProperties($xAppKey, $appSecret);
  14. $client = new ZopClient($properties);
  15. $request = new ZopRequest();
  16. $request->setUrl($url);
  17. $body = json_encode([
  18. 'type' => 1,
  19. 'billCode' => '75424921258500',
  20. ]);
  21. $request->setBody($body);
  22. return json_decode($client->execute($request));
  23. }
  24. public function tt(array $logisticNums)
  25. {
  26. $url = 'https://japi.zto.com/zto.open.obtainPicePrescription"';
  27. $xAppKey = config('api_logistic.ZTO.x-appKey');
  28. $xDataDigest = config('api_logistic.ZTO.appSecret');
  29. $properties = new ZopProperties($xAppKey, $xDataDigest);
  30. $client = new ZopClient($properties);
  31. $request = new ZopRequest();
  32. $request->setUrl($url);
  33. $body = json_encode([
  34. 'type' => 1,
  35. 'billCode' => '75424921258500',
  36. ]);
  37. $request->setBody("{\"transportType\":0,\"sender\":{\"address\":\"华志路1685号\",\"province\":\"上海\",\"city\":\"上海市\",\"district\":\"青浦区\"},\"addresser\":{\"district\":\"青浦区\",\"address\":\"华志路1685号\",\"province\":\"上海\",\"city\":\"上海市\"},\"weight\":1}");
  38. return json_decode($client->execute($request));
  39. }
  40. }