Merchant.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\store\merchant;
  12. use app\common\repositories\user\UserMerchantRepository;
  13. use think\App;
  14. use crmeb\basic\BaseController;
  15. use app\common\repositories\system\merchant\MerchantRepository as repository;
  16. class Merchant extends BaseController
  17. {
  18. protected $repository;
  19. protected $userInfo;
  20. /**
  21. * ProductCategory constructor.
  22. * @param App $app
  23. * @param repository $repository
  24. */
  25. public function __construct(App $app, repository $repository)
  26. {
  27. parent::__construct($app);
  28. $this->repository = $repository;
  29. $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null;
  30. }
  31. /**
  32. * @Author:Qinii
  33. * @Date: 2020/5/27
  34. * @return mixed
  35. */
  36. public function lst()
  37. {
  38. [$page, $limit] = $this->getPage();
  39. $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id']);
  40. return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
  41. }
  42. /**
  43. * @Author:Qinii
  44. * @Date: 2020/5/29
  45. * @param $id
  46. * @return mixed
  47. */
  48. public function detail($id)
  49. {
  50. if (!$this->repository->apiGetOne($id))
  51. return app('json')->fail('店铺已打烊');
  52. if ($this->request->isLogin()) {
  53. app()->make(UserMerchantRepository::class)->updateLastTime($this->request->uid(), intval($id));
  54. }
  55. return app('json')->success($this->repository->detail($id, $this->userInfo));
  56. }
  57. /**
  58. * @Author:Qinii
  59. * @Date: 2020/5/29
  60. * @param $id
  61. * @return mixed
  62. */
  63. public function productList($id)
  64. {
  65. [$page, $limit] = $this->getPage();
  66. $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
  67. if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
  68. return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo));
  69. }
  70. /**
  71. * @Author:Qinii
  72. * @Date: 2020/5/29
  73. * @param int $id
  74. * @return mixed
  75. */
  76. public function categoryList($id)
  77. {
  78. if(!$this->repository->merExists($id))
  79. return app('json')->fail('店铺已打烊');
  80. return app('json')->success($this->repository->categoryList($id));
  81. }
  82. public function qrcode($id)
  83. {
  84. if(!$this->repository->merExists($id))
  85. return app('json')->fail('店铺已打烊');
  86. $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
  87. return app('json')->success(compact('url'));
  88. }
  89. }