Merchant.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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', 'type_id','is_trader']);
  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. public function systemDetail()
  58. {
  59. $config = systemConfig(['site_logo', 'site_name']);
  60. return app('json')->success([
  61. 'mer_avatar' => $config['site_logo'],
  62. 'mer_name' => $config['site_name'],
  63. 'mer_id' => 0,
  64. ]);
  65. }
  66. /**
  67. * @Author:Qinii
  68. * @Date: 2020/5/29
  69. * @param $id
  70. * @return mixed
  71. */
  72. public function productList($id)
  73. {
  74. [$page, $limit] = $this->getPage();
  75. $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
  76. if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
  77. return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo));
  78. }
  79. /**
  80. * @Author:Qinii
  81. * @Date: 2020/5/29
  82. * @param int $id
  83. * @return mixed
  84. */
  85. public function categoryList($id)
  86. {
  87. if(!$this->repository->merExists($id))
  88. return app('json')->fail('店铺已打烊');
  89. return app('json')->success($this->repository->categoryList($id));
  90. }
  91. public function qrcode($id)
  92. {
  93. if(!$this->repository->merExists($id))
  94. return app('json')->fail('店铺已打烊');
  95. $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
  96. return app('json')->success(compact('url'));
  97. }
  98. public function localLst()
  99. {
  100. [$page, $limit] = $this->getPage();
  101. $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id']);
  102. $where['delivery_way'] = 1;
  103. return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
  104. }
  105. }