Merchant.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. if (!$where['location']) {
  41. $where['location'] = $this->userInfo['now_local'];
  42. }
  43. return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
  44. }
  45. /**
  46. * @Author:Qinii
  47. * @Date: 2020/5/29
  48. * @param $id
  49. * @return mixed
  50. */
  51. public function detail($id)
  52. {
  53. if (!$this->repository->apiGetOne($id))
  54. return app('json')->fail('店铺已打烊');
  55. if ($this->request->isLogin()) {
  56. app()->make(UserMerchantRepository::class)->updateLastTime($this->request->uid(), intval($id));
  57. }
  58. return app('json')->success($this->repository->detail($id, $this->userInfo));
  59. }
  60. /**
  61. * @Author:Qinii
  62. * @Date: 2020/5/29
  63. * @param $id
  64. * @return mixed
  65. */
  66. public function productList($id)
  67. {
  68. [$page, $limit] = $this->getPage();
  69. $where = $this->request->params(['keyword', 'order', 'mer_cate_id', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
  70. if (!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
  71. return app('json')->success($this->repository->productList($id, $where, $page, $limit, $this->userInfo));
  72. }
  73. /**
  74. * @Author:Qinii
  75. * @Date: 2020/5/29
  76. * @param int $id
  77. * @return mixed
  78. */
  79. public function categoryList($id)
  80. {
  81. if (!$this->repository->merExists($id))
  82. return app('json')->fail('店铺已打烊');
  83. return app('json')->success($this->repository->categoryList($id));
  84. }
  85. public function qrcode($id)
  86. {
  87. if (!$this->repository->merExists($id))
  88. return app('json')->fail('店铺已打烊');
  89. $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
  90. return app('json')->success(compact('url'));
  91. }
  92. }