freight_facade.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @copyright Copyright(c) 2014 aircheng.com
  4. * @file freight_facade.php
  5. * @author nswe
  6. * @date 2014/4/18 16:22:33
  7. * @version 1.0.0
  8. */
  9. /**
  10. * @class freight_facade
  11. * @brief 快递跟踪接口类
  12. */
  13. class freight_facade
  14. {
  15. //使用的物流接口
  16. public static $freightInterface = 'hqepay';
  17. /**
  18. * @brief 开始快递跟踪
  19. * @param $ShipperCode string 物流公司编码
  20. * @param $LogisticCode string 物流单号
  21. */
  22. public static function line($ShipperCode,$LogisticCode)
  23. {
  24. if( $freightObj = self::createObject() )
  25. {
  26. return $freightObj->line($ShipperCode,$LogisticCode);
  27. }
  28. }
  29. /**
  30. * @brief 创建物流接口实力
  31. * @return object 快递跟踪类实例
  32. */
  33. private static function createObject()
  34. {
  35. //类库路径
  36. $basePath = IWeb::$app->getBasePath().'plugins/freight/';
  37. //配置参数
  38. $siteConfig = new Config('site_config');
  39. switch(self::$freightInterface)
  40. {
  41. default:
  42. {
  43. include($basePath.'hqepay.php');
  44. return new Hqepay($siteConfig->freightid,$siteConfig->freightkey);
  45. }
  46. }
  47. }
  48. }
  49. /**
  50. * @brief 物流开发接口
  51. */
  52. interface freight_inter
  53. {
  54. /**
  55. * @brief 物流快递轨迹查询
  56. * @param $ShipperCode string 物流公司快递号
  57. * @param $LogisticCode string 快递单号
  58. */
  59. public function line($ShipperCode,$LogisticCode);
  60. /**
  61. * @brief 处理返回数据统一数据格式
  62. * @param $result 结果处理
  63. * @return array 通用的结果集 array('result' => 'success或者fail','data' => array( array('time' => '时间','station' => '地点'),......),'reason' => '失败原因')
  64. */
  65. public function response($result);
  66. }