StoreProductGiftGroup.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /**
  66. * 获取我的礼包商品列表(当前管理员)
  67. * @return \think\Response
  68. */
  69. public function getMyGiftProductList()
  70. {
  71. $where = $this->request->getMore([
  72. ['name', '']
  73. ]);
  74. $uid = $this->adminId; // 自动获取当前登录管理员的uid
  75. $where['uid'] = $uid; // 添加uid过滤条件
  76. return app('json')->success($this->services->getGiftProductList($where));
  77. }
  78. /**
  79. * 获取我的推荐关系列表(当前管理员)
  80. * @return \think\Response
  81. */
  82. public function getMyRecommendationRelationList()
  83. {
  84. $where = $this->request->getMore([
  85. ['product_id', 0]
  86. ]);
  87. $uid = $this->adminId; // 自动获取当前登录管理员的uid
  88. $where['uid'] = $uid;
  89. return app('json')->success($this->services->getRecommendationRelationList($where));
  90. }
  91. }