OrderClient.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat\MiniProgram\Mall;
  11. use EasyWeChat\Kernel\BaseClient;
  12. /**
  13. * Class Client.
  14. *
  15. * @author mingyoung <mingyoungcheung@gmail.com>
  16. */
  17. class OrderClient extends BaseClient
  18. {
  19. /**
  20. * 导入订单.
  21. *
  22. * @param array $params
  23. * @param bool $isHistory
  24. *
  25. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  26. *
  27. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  28. * @throws \GuzzleHttp\Exception\GuzzleException
  29. */
  30. public function add($params, $isHistory = false)
  31. {
  32. return $this->httpPostJson('mall/importorder', $params, ['action' => 'add-order', 'is_history' => (int) $isHistory]);
  33. }
  34. /**
  35. * 导入订单.
  36. *
  37. * @param array $params
  38. * @param bool $isHistory
  39. *
  40. * @return mixed
  41. *
  42. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  43. * @throws \GuzzleHttp\Exception\GuzzleException
  44. */
  45. public function update($params, $isHistory = false)
  46. {
  47. return $this->httpPostJson('mall/importorder', $params, ['action' => 'update-order', 'is_history' => (int) $isHistory]);
  48. }
  49. /**
  50. * 删除订单.
  51. *
  52. * @param string $openid
  53. * @param string $orderId
  54. *
  55. * @return mixed
  56. *
  57. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  58. * @throws \GuzzleHttp\Exception\GuzzleException
  59. */
  60. public function delete($openid, $orderId)
  61. {
  62. $params = [
  63. 'user_open_id' => $openid,
  64. 'order_id' => $orderId,
  65. ];
  66. return $this->httpPostJson('mall/deleteorder', $params);
  67. }
  68. }