Logistics.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  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. $this->registerApi($url, __FUNCTION__, func_get_args());
  33. return $this->callPostApi($url, $data, true);
  34. }
  35. /**
  36. * 取消运单
  37. * @param array $data
  38. * @return array
  39. * @throws \WeChat\Exceptions\InvalidResponseException
  40. * @throws \WeChat\Exceptions\LocalCacheException
  41. */
  42. public function cancelOrder($data)
  43. {
  44. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/cancel?access_token=ACCESS_TOKEN';
  45. $this->registerApi($url, __FUNCTION__, func_get_args());
  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. $this->registerApi($url, __FUNCTION__, func_get_args());
  58. return $this->callGetApi($url);
  59. }
  60. /**
  61. * 获取运单数据
  62. * @param array $data
  63. * @return array
  64. * @throws \WeChat\Exceptions\InvalidResponseException
  65. * @throws \WeChat\Exceptions\LocalCacheException
  66. */
  67. public function getOrder($data)
  68. {
  69. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/get?access_token=ACCESS_TOKEN';
  70. $this->registerApi($url, __FUNCTION__, func_get_args());
  71. return $this->callPostApi($url, $data, true);
  72. }
  73. /**
  74. * 查询运单轨迹
  75. * @param array $data
  76. * @return array
  77. * @throws \WeChat\Exceptions\InvalidResponseException
  78. * @throws \WeChat\Exceptions\LocalCacheException
  79. */
  80. public function getPath($data)
  81. {
  82. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN';
  83. $this->registerApi($url, __FUNCTION__, func_get_args());
  84. return $this->callPostApi($url, $data, true);
  85. }
  86. /**
  87. * 获取打印员。若需要使用微信打单 PC 软件,才需要调用
  88. * @return array
  89. * @throws \WeChat\Exceptions\InvalidResponseException
  90. * @throws \WeChat\Exceptions\LocalCacheException
  91. */
  92. public function getPrinter()
  93. {
  94. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/getall?access_token=ACCESS_TOKEN';
  95. $this->registerApi($url, __FUNCTION__, func_get_args());
  96. return $this->callGetApi($url);
  97. }
  98. /**
  99. * 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用
  100. * @param array $data
  101. * @return array
  102. * @throws \WeChat\Exceptions\InvalidResponseException
  103. * @throws \WeChat\Exceptions\LocalCacheException
  104. */
  105. public function getQuota($data)
  106. {
  107. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN';
  108. $this->registerApi($url, __FUNCTION__, func_get_args());
  109. return $this->callPostApi($url, $data, true);
  110. }
  111. /**
  112. * 模拟快递公司更新订单状态, 该接口只能用户测试
  113. * @param array $data
  114. * @return array
  115. * @throws \WeChat\Exceptions\InvalidResponseException
  116. * @throws \WeChat\Exceptions\LocalCacheException
  117. */
  118. public function testUpdateOrder($data)
  119. {
  120. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/test_update_order?access_token=ACCESS_TOKEN';
  121. $this->registerApi($url, __FUNCTION__, func_get_args());
  122. return $this->callPostApi($url, $data, true);
  123. }
  124. /**
  125. * 配置面单打印员,若需要使用微信打单 PC 软件,才需要调用
  126. * @param array $data
  127. * @return array
  128. * @throws \WeChat\Exceptions\InvalidResponseException
  129. * @throws \WeChat\Exceptions\LocalCacheException
  130. */
  131. public function updatePrinter($data)
  132. {
  133. $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/update?access_token=ACCESS_TOKEN';
  134. $this->registerApi($url, __FUNCTION__, func_get_args());
  135. return $this->callPostApi($url, $data, true);
  136. }
  137. /**
  138. * 获取面单联系人信息
  139. * @param array $data
  140. * @return array
  141. * @throws \WeChat\Exceptions\InvalidResponseException
  142. * @throws \WeChat\Exceptions\LocalCacheException
  143. */
  144. public function getContact($data)
  145. {
  146. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/contact/get?access_token=ACCESS_TOKEN';
  147. $this->registerApi($url, __FUNCTION__, func_get_args());
  148. return $this->callPostApi($url, $data, true);
  149. }
  150. /**
  151. * 预览面单模板。用于调试面单模板使用
  152. * @param array $data
  153. * @return array
  154. * @throws \WeChat\Exceptions\InvalidResponseException
  155. * @throws \WeChat\Exceptions\LocalCacheException
  156. */
  157. public function previewTemplate($data)
  158. {
  159. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/template/preview?access_token=ACCESS_TOKEN';
  160. $this->registerApi($url, __FUNCTION__, func_get_args());
  161. return $this->callPostApi($url, $data, true);
  162. }
  163. /**
  164. * 更新商户审核结果
  165. * @param array $data
  166. * @return array
  167. * @throws \WeChat\Exceptions\InvalidResponseException
  168. * @throws \WeChat\Exceptions\LocalCacheException
  169. */
  170. public function updateBusiness($data)
  171. {
  172. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/service/business/update?access_token=ACCESS_TOKEN';
  173. $this->registerApi($url, __FUNCTION__, func_get_args());
  174. return $this->callPostApi($url, $data, true);
  175. }
  176. /**
  177. * 更新运单轨迹
  178. * @param array $data
  179. * @return array
  180. * @throws \WeChat\Exceptions\InvalidResponseException
  181. * @throws \WeChat\Exceptions\LocalCacheException
  182. */
  183. public function updatePath($data)
  184. {
  185. $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/path/update?access_token=ACCESS_TOKEN';
  186. $this->registerApi($url, __FUNCTION__, func_get_args());
  187. return $this->callPostApi($url, $data, true);
  188. }
  189. }