ProductController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\v1\work;
  12. use app\services\kefu\ProductServices;
  13. /**
  14. * Class ProductController
  15. * @package app\controller\api\v1\work
  16. */
  17. class ProductController extends BaseWorkController
  18. {
  19. /**
  20. * ProductController constructor.
  21. * @param ProductServices $services
  22. */
  23. public function __construct(ProductServices $services)
  24. {
  25. parent::__construct();
  26. $this->service = $services;
  27. }
  28. /**
  29. * 获取用户购买记录
  30. * @return mixed
  31. */
  32. public function getCartProductList(string $store_name = '')
  33. {
  34. $uid = $this->clientInfo['uid'] ?? 0;
  35. if (!$uid) {
  36. return $this->success([]);
  37. }
  38. return $this->success(get_thumb_water($this->service->getProductCartList((int)$uid, $store_name)));
  39. }
  40. /**
  41. * 用户浏览记录
  42. * @param string $store_name
  43. * @return mixed
  44. */
  45. public function getVisitProductList(string $store_name = '')
  46. {
  47. $uid = $this->clientInfo['uid'] ?? 0;
  48. if (!$uid) {
  49. return $this->success([]);
  50. }
  51. return $this->success(get_thumb_water($this->service->getVisitProductList((int)$uid, $store_name)));
  52. }
  53. /**
  54. * 获取用户购买的热销商品
  55. * @param string $store_name
  56. * @return mixed
  57. */
  58. public function getProductHotSale(string $store_name = '')
  59. {
  60. $uid = $this->clientInfo['uid'] ?? 0;
  61. if (!$uid) {
  62. return $this->success([]);
  63. }
  64. return $this->success(get_thumb_water($this->service->getProductHotSale((int)$uid, $store_name)));
  65. }
  66. }