Logistics.php 6.4 KB

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