Merchant.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\controller\api\store\merchant;
  3. use app\common\repositories\user\UserMerchantRepository;
  4. use think\App;
  5. use ln\basic\BaseController;
  6. use app\common\repositories\system\merchant\MerchantRepository as repository;
  7. class Merchant extends BaseController
  8. {
  9. protected $repository;
  10. protected $userInfo;
  11. /**
  12. * ProductCategory constructor.
  13. * @param App $app
  14. * @param repository $repository
  15. */
  16. public function __construct(App $app, repository $repository)
  17. {
  18. parent::__construct($app);
  19. $this->repository = $repository;
  20. $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null;
  21. }
  22. /**
  23. * @Author:Qinii
  24. * @Date: 2020/5/27
  25. * @return mixed
  26. */
  27. public function lst()
  28. {
  29. [$page, $limit] = $this->getPage();
  30. $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id']);
  31. return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
  32. }
  33. /**
  34. * @Author:Qinii
  35. * @Date: 2020/5/29
  36. * @param $id
  37. * @return mixed
  38. */
  39. public function detail($id)
  40. {
  41. if (!$this->repository->apiGetOne($id))
  42. return app('json')->fail('店铺已打烊');
  43. if ($this->request->isLogin()) {
  44. app()->make(UserMerchantRepository::class)->updateLastTime($this->request->uid(), intval($id));
  45. }
  46. return app('json')->success($this->repository->detail($id, $this->userInfo));
  47. }
  48. /**
  49. * @Author:Qinii
  50. * @Date: 2020/5/29
  51. * @param $id
  52. * @return mixed
  53. */
  54. public function productList($id)
  55. {
  56. [$page, $limit] = $this->getPage();
  57. $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
  58. if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
  59. return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo));
  60. }
  61. /**
  62. * @Author:Qinii
  63. * @Date: 2020/5/29
  64. * @param int $id
  65. * @return mixed
  66. */
  67. public function categoryList($id)
  68. {
  69. if(!$this->repository->merExists($id))
  70. return app('json')->fail('店铺已打烊');
  71. return app('json')->success($this->repository->categoryList($id));
  72. }
  73. public function qrcode($id)
  74. {
  75. if(!$this->repository->merExists($id))
  76. return app('json')->fail('店铺已打烊');
  77. $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
  78. return app('json')->success(compact('url'));
  79. }
  80. }