StoreProductGiftGroup.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\adminapi\controller\v1\product;
  3. use app\adminapi\controller\AuthController;
  4. use app\services\product\product\StoreProductGiftGroupService;
  5. use think\facade\App;
  6. /**
  7. * 商品参数
  8. * @author wuhaotian
  9. * @email 442384644@qq.com
  10. * @date 2024/12/17
  11. */
  12. class StoreProductGiftGroup extends AuthController
  13. {
  14. /**
  15. * @param App $app
  16. * @param StoreProductGiftGroupService $services
  17. */
  18. public function __construct(App $app, StoreProductGiftGroupService $services)
  19. {
  20. parent::__construct($app);
  21. $this->services = $services;
  22. }
  23. /**
  24. * 获取礼包商品列表(最外层礼包名列表)
  25. * @return \think\Response
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. * @author wuhaotian
  30. * @email 442384644@qq.com
  31. * @date 2024/12/17
  32. */
  33. public function getGiftProductList()
  34. {
  35. $where = $this->request->getMore([
  36. ['name', '']
  37. ]);
  38. return app('json')->success($this->services->getGiftProductList($where));
  39. }
  40. /**
  41. * 获取推荐关系列表
  42. * - 只传product_id:显示该商品中最上层的推荐人(只存在于pid中,而没有在uid里的用户)
  43. * - 同时传product_id和uid:显示该用户的小组成员(fake_pid为该uid的用户)
  44. * @return \think\Response
  45. */
  46. public function getRecommendationRelationList()
  47. {
  48. $where = $this->request->getMore([
  49. ['product_id', 0],
  50. ['uid', 0]
  51. ]);
  52. return app('json')->success($this->services->getRecommendationRelationList($where));
  53. }
  54. /**
  55. * 获取指定商品的所有推荐关系用户
  56. * @return \think\Response
  57. */
  58. public function getRecommendationUsers()
  59. {
  60. $product_id = $this->request->get('product_id', 0);
  61. if (!$product_id) return app('json')->fail('请选择商品');
  62. $users = $this->services->getRecommendationUsers($product_id);
  63. return app('json')->success($users);
  64. }
  65. }