CartClient.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 CartClient extends BaseClient
  18. {
  19. /**
  20. * 导入收藏.
  21. *
  22. * @param array $params
  23. * @param bool $isTest
  24. *
  25. * @return mixed
  26. *
  27. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  28. * @throws \GuzzleHttp\Exception\GuzzleException
  29. */
  30. public function add($params, $isTest = false)
  31. {
  32. return $this->httpPostJson('mall/addshoppinglist', $params, ['is_test' => (int) $isTest]);
  33. }
  34. /**
  35. * 查询用户收藏信息.
  36. *
  37. * @param array $params
  38. *
  39. * @return mixed
  40. *
  41. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  42. * @throws \GuzzleHttp\Exception\GuzzleException
  43. */
  44. public function query($params)
  45. {
  46. return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'batchquery']);
  47. }
  48. /**
  49. * 查询用户收藏信息.
  50. *
  51. * @param array $params
  52. *
  53. * @return mixed
  54. *
  55. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  56. * @throws \GuzzleHttp\Exception\GuzzleException
  57. */
  58. public function queryByPage($params)
  59. {
  60. return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'getbypage']);
  61. }
  62. /**
  63. * 删除收藏.
  64. *
  65. * @param string $openid
  66. *
  67. * @return mixed
  68. *
  69. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  70. * @throws \GuzzleHttp\Exception\GuzzleException
  71. */
  72. public function delete($openid, array $products = [])
  73. {
  74. if (empty($products)) {
  75. return $this->httpPostJson('mall/deletebizallshoppinglist', ['user_open_id' => $openid]);
  76. }
  77. return $this->httpPostJson('mall/deleteshoppinglist', ['user_open_id' => $openid, 'sku_product_list' => $products]);
  78. }
  79. }