Product.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\kefuapi\controller;
  12. use think\facade\App;
  13. use app\services\kefu\ProductServices;
  14. /**
  15. * Class Product
  16. * @package app\kefuapi\controller
  17. */
  18. class Product extends AuthController
  19. {
  20. /**
  21. * Product constructor.
  22. * @param App $app
  23. * @param ProductServices $services
  24. */
  25. public function __construct(App $app, ProductServices $services)
  26. {
  27. parent::__construct($app);
  28. $this->services = $services;
  29. }
  30. /**
  31. * 获取用户购买记录
  32. * @param $uid
  33. * @return mixed
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public function getCartProductList($uid, string $store_name = '')
  39. {
  40. return app('json')->success(get_thumb_water($this->services->getProductCartList((int)$uid, $store_name)));
  41. }
  42. /**
  43. * 用户浏览记录
  44. * @param $uid
  45. * @param string $store_name
  46. * @return mixed
  47. */
  48. public function getVisitProductList($uid, string $store_name = '')
  49. {
  50. return app('json')->success(get_thumb_water($this->services->getVisitProductList((int)$uid, $store_name)));
  51. }
  52. /**
  53. * 获取用户购买的热销商品
  54. * @param $uid
  55. * @param string $store_name
  56. * @return mixed
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\DbException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. */
  61. public function getProductHotSale($uid, string $store_name = '')
  62. {
  63. return app('json')->success(get_thumb_water($this->services->getProductHotSale((int)$uid, $store_name)));
  64. }
  65. /**
  66. * 商品详情
  67. * @param $id
  68. * @return mixed
  69. * @throws \think\db\exception\DataNotFoundException
  70. * @throws \think\db\exception\DbException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. */
  73. public function getProductInfo($id)
  74. {
  75. return app('json')->success(get_thumb_water($this->services->getProductInfo((int)$id), 'big', ['image', 'slider_image']));
  76. }
  77. }