Logistics.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. namespace WeMini;
  14. use WeChat\Contracts\BasicWeChat;
  15. /**
  16. * 小程序物流助手
  17. * Class Logistics
  18. * @package WeMini
  19. */
  20. class Logistics extends BasicWeChat
  21. {
  22. /**
  23. * 生成运单
  24. * @param array $data
  25. * @return array
  26. * @throws \WeChat\Exceptions\InvalidResponseException
  27. * @throws \WeChat\Exceptions\LocalCacheException
  28. */
  29. public function addOrder($data)
  30. {
  31. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/add?access_token=ACCESS_TOKEN';
  32. return $this->callPostApi($url, $data, true);
  33. }
  34. /**
  35. * 取消运单
  36. * @param array $data
  37. * @return array
  38. * @throws \WeChat\Exceptions\InvalidResponseException
  39. * @throws \WeChat\Exceptions\LocalCacheException
  40. */
  41. public function cancelOrder($data)
  42. {
  43. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/cancel?access_token=ACCESS_TOKEN';
  44. return $this->callPostApi($url, $data, true);
  45. }
  46. /**
  47. * 获取支持的快递公司列表
  48. * @return array
  49. * @throws \WeChat\Exceptions\InvalidResponseException
  50. * @throws \WeChat\Exceptions\LocalCacheException
  51. */
  52. public function getAllDelivery()
  53. {
  54. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/delivery/getall?access_token=ACCESS_TOKEN';
  55. return $this->callGetApi($url);
  56. }
  57. /**
  58. * 获取运单数据
  59. * @param array $data
  60. * @return array
  61. * @throws \WeChat\Exceptions\InvalidResponseException
  62. * @throws \WeChat\Exceptions\LocalCacheException
  63. */
  64. public function getOrder($data)
  65. {
  66. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/get?access_token=ACCESS_TOKEN';
  67. return $this->callPostApi($url, $data, true);
  68. }
  69. /**
  70. * 查询运单轨迹
  71. * @param array $data
  72. * @return array
  73. * @throws \WeChat\Exceptions\InvalidResponseException
  74. * @throws \WeChat\Exceptions\LocalCacheException
  75. */
  76. public function getPath($data)
  77. {
  78. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN';
  79. return $this->callPostApi($url, $data, true);
  80. }
  81. /**
  82. * 获取打印员。若需要使用微信打单 PC 软件,才需要调用
  83. * @return array
  84. * @throws \WeChat\Exceptions\InvalidResponseException
  85. * @throws \WeChat\Exceptions\LocalCacheException
  86. */
  87. public function getPrinter()
  88. {
  89. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/getall?access_token=ACCESS_TOKEN';
  90. return $this->callGetApi($url);
  91. }
  92. /**
  93. * 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用
  94. * @param array $data
  95. * @return array
  96. * @throws \WeChat\Exceptions\InvalidResponseException
  97. * @throws \WeChat\Exceptions\LocalCacheException
  98. */
  99. public function getQuota($data)
  100. {
  101. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN';
  102. return $this->callPostApi($url, $data, true);
  103. }
  104. /**
  105. * 模拟快递公司更新订单状态, 该接口只能用户测试
  106. * @param array $data
  107. * @return array
  108. * @throws \WeChat\Exceptions\InvalidResponseException
  109. * @throws \WeChat\Exceptions\LocalCacheException
  110. */
  111. public function testUpdateOrder($data)
  112. {
  113. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/test_update_order?access_token=ACCESS_TOKEN';
  114. return $this->callPostApi($url, $data, true);
  115. }
  116. /**
  117. * 配置面单打印员,若需要使用微信打单 PC 软件,才需要调用
  118. * @param array $data
  119. * @return array
  120. * @throws \WeChat\Exceptions\InvalidResponseException
  121. * @throws \WeChat\Exceptions\LocalCacheException
  122. */
  123. public function updatePrinter($data)
  124. {
  125. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/update?access_token=ACCESS_TOKEN';
  126. return $this->callPostApi($url, $data, true);
  127. }
  128. /**
  129. * 获取面单联系人信息
  130. * @param array $data
  131. * @return array
  132. * @throws \WeChat\Exceptions\InvalidResponseException
  133. * @throws \WeChat\Exceptions\LocalCacheException
  134. */
  135. public function getContact($data)
  136. {
  137. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/contact/get?access_token=ACCESS_TOKEN';
  138. return $this->callPostApi($url, $data, true);
  139. }
  140. /**
  141. * 预览面单模板。用于调试面单模板使用
  142. * @param array $data
  143. * @return array
  144. * @throws \WeChat\Exceptions\InvalidResponseException
  145. * @throws \WeChat\Exceptions\LocalCacheException
  146. */
  147. public function previewTemplate($data)
  148. {
  149. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/template/preview?access_token=ACCESS_TOKEN';
  150. return $this->callPostApi($url, $data, true);
  151. }
  152. /**
  153. * 更新商户审核结果
  154. * @param array $data
  155. * @return array
  156. * @throws \WeChat\Exceptions\InvalidResponseException
  157. * @throws \WeChat\Exceptions\LocalCacheException
  158. */
  159. public function updateBusiness($data)
  160. {
  161. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/service/business/update?access_token=ACCESS_TOKEN';
  162. return $this->callPostApi($url, $data, true);
  163. }
  164. /**
  165. * 更新运单轨迹
  166. * @param array $data
  167. * @return array
  168. * @throws \WeChat\Exceptions\InvalidResponseException
  169. * @throws \WeChat\Exceptions\LocalCacheException
  170. */
  171. public function updatePath($data)
  172. {
  173. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/path/update?access_token=ACCESS_TOKEN';
  174. return $this->callPostApi($url, $data, true);
  175. }
  176. }