StoreProductAssistSet.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\controller\api\store\product;
  3. use app\common\repositories\store\product\ProductAssistSetRepository;
  4. use app\common\repositories\store\product\ProductAssistUserRepository;
  5. use think\App;
  6. use ln\basic\BaseController;
  7. class StoreProductAssistSet extends BaseController
  8. {
  9. protected $repository;
  10. protected $userInfo;
  11. /**
  12. * StoreProductPresell constructor.
  13. * @param App $app
  14. * @param repository $repository
  15. */
  16. public function __construct(App $app, ProductAssistSetRepository $repository)
  17. {
  18. parent::__construct($app);
  19. $this->repository = $repository;
  20. $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
  21. }
  22. /**
  23. * TODO 个人助力列表
  24. * @return mixed
  25. * @author Qinii
  26. * @day 2020-11-25
  27. */
  28. public function lst()
  29. {
  30. [$page, $limit] = $this->getPage();
  31. $where['uid'] = $this->request->uid();
  32. return app('json')->success($this->repository->getApiList($where,$page, $limit));
  33. }
  34. public function detail($id)
  35. {
  36. $data = $this->repository->detail($id,$this->userInfo);
  37. return app('json')->success($data);
  38. }
  39. /**
  40. * TODO 发起助力
  41. * @param $id
  42. * @return mixed
  43. * @author Qinii
  44. * @day 2020-10-28
  45. */
  46. public function create($id)
  47. {
  48. // if($this->userInfo->user_type == 'wechat' && !$this->userInfo->subscribe){
  49. // return app('json')->fail('请先关注公众号');
  50. // }
  51. $data = $this->repository->create($id,$this->request->uid());
  52. return app('json')->success($data);
  53. }
  54. /**
  55. * TODO 帮好友助力
  56. * @param $id
  57. * @return mixed
  58. * @author Qinii
  59. * @day 2020-10-28
  60. */
  61. public function set($id)
  62. {
  63. $this->repository->set($id,$this->userInfo);
  64. return app('json')->success('助力成功');
  65. }
  66. public function delete($id)
  67. {
  68. $res = $this->repository->getWhere(['product_assist_set_id' => $id,'uid' => $this->request->uid()]);
  69. if(!$res)return app('json')->fail('信息错误');
  70. $this->repository->update($id,['status' => -1]);
  71. return app('json')->success('取消成功');
  72. }
  73. /**
  74. * TODO 助力列表
  75. * @param $id
  76. * @param ProductAssistUserRepository $repository
  77. * @return mixed
  78. * @author Qinii
  79. * @day 2020-10-28
  80. */
  81. public function userList($id,ProductAssistUserRepository $repository)
  82. {
  83. [$page, $limit] = $this->getPage();
  84. $where['product_assist_set_id'] = $id;
  85. if(!$this->repository->get($id)) return app('json')->fail('数据丢失');
  86. return app('json')->success($repository->userList($where,$page, $limit));
  87. }
  88. public function shareNum($id)
  89. {
  90. $this->repository->incNum(1,$id);
  91. return app('json')->success('oks');
  92. }
  93. }