Shipping.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\library\wechat;
  13. use cores\exception\BaseException;
  14. /**
  15. * 发货信息录入接口
  16. * Class wechat
  17. * @package app\library
  18. */
  19. class Shipping extends WxBase
  20. {
  21. /**
  22. * 发货信息录入接口
  23. * api文档: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html
  24. * @throws BaseException
  25. */
  26. public function uploadShippingInfo(array $params)
  27. {
  28. // 微信接口url
  29. $accessToken = $this->getAccessToken();
  30. $apiUrl = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token={$accessToken}";
  31. // 执行请求
  32. $result = $this->post($apiUrl, $this->jsonEncode($params));
  33. // 记录日志
  34. log_record(['name' => '微信小程序-发货信息录入接口', 'url' => $apiUrl, 'params' => $params, 'result' => $result]);
  35. // 返回结果
  36. $response = $this->jsonDecode($result);
  37. if (!isset($response['errcode'])) {
  38. $this->error = 'not found errcode';
  39. return false;
  40. }
  41. if ($response['errcode'] != 0) {
  42. $this->error = $response['errmsg'];
  43. return false;
  44. }
  45. return $response;
  46. }
  47. }