Expressage.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace expressage;
  3. class Expressage
  4. {
  5. protected $app;
  6. protected $key;
  7. protected $logisticsInfo;
  8. protected $error;
  9. public function __construct($app, $key)
  10. {
  11. $this->app = $app;
  12. $this->key = $key;
  13. }
  14. /**
  15. * @notes 格式化
  16. * @return false
  17. * @author 段誉
  18. * @date 2021/8/11 16:52
  19. */
  20. public function logisticsFormat()
  21. {
  22. if (empty($this->logisticsInfo)) {
  23. return false;
  24. }
  25. $info = $this->logisticsInfo;
  26. foreach ($info as $k => $v) {
  27. $info[$k] = array_values($v);
  28. }
  29. return $info;
  30. }
  31. /**
  32. * @notes 电商Sign签名生成
  33. * @param $data
  34. * @param $appkey
  35. * @return string
  36. * @author 段誉
  37. * @date 2021/8/11 16:52
  38. */
  39. protected function encrypt($data, $appkey)
  40. {
  41. return urlencode(base64_encode(md5($data . $appkey)));
  42. }
  43. /**
  44. * @notes 获取错误信息
  45. * @return mixed
  46. * @author 段誉
  47. * @date 2021/8/11 16:52
  48. */
  49. public function getError()
  50. {
  51. return $this->error;
  52. }
  53. }