StoreController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Services\Common\StoreService;
  13. /**
  14. * 商户管理-控制器
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * @package App\Http\Controllers
  18. */
  19. class StoreController extends Backend
  20. {
  21. /**
  22. * 构造函数
  23. * @author laravel开发员
  24. * @since 2020/11/11
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->service = new StoreService();
  30. }
  31. public function index()
  32. {
  33. $pageSize = request()->get('limit', 15);
  34. $params = request()->all();
  35. $params['store_id'] = $this->storeId;
  36. return $this->service->getDataList($params, $pageSize);
  37. }
  38. /**
  39. * 获取当前登录商家信息
  40. * @return array
  41. */
  42. public function currentInfo()
  43. {
  44. $service = new StoreService();
  45. $storeId = $this->storeId;
  46. return $service->getCurrentStoreInfo($storeId);
  47. }
  48. /**
  49. * 获取详情
  50. * @return array
  51. */
  52. public function info()
  53. {
  54. return $this->service->info();
  55. }
  56. /**
  57. * 审核商家
  58. * @return array
  59. */
  60. public function confirm()
  61. {
  62. $params = request()->post();
  63. if ($this->service->confirm($this->userId, $params)) {
  64. return message($this->service->getError(), true);
  65. } else {
  66. return message($this->service->getError(), false);
  67. }
  68. }
  69. /**
  70. * 设置状态(禁用/启用)
  71. * @return array
  72. */
  73. public function status()
  74. {
  75. $params = request()->post();
  76. if ($this->service->setStatus($params)) {
  77. return message($this->service->getError(), true);
  78. } else {
  79. return message($this->service->getError(), false);
  80. }
  81. }
  82. /**
  83. * 新增商家
  84. * @return array
  85. */
  86. public function add()
  87. {
  88. $params = request()->post();
  89. if ($this->service->edit($params)) {
  90. return message($this->service->getError(), true);
  91. } else {
  92. return message($this->service->getError(), false);
  93. }
  94. }
  95. /**
  96. * 编辑商家
  97. * @return array
  98. */
  99. public function edit()
  100. {
  101. $params = request()->post();
  102. if ($this->service->edit($params)) {
  103. return message($this->service->getError(), true);
  104. } else {
  105. return message($this->service->getError(), false);
  106. }
  107. }
  108. /**
  109. * 删除商家
  110. * @return array
  111. */
  112. public function delete()
  113. {
  114. $params = request()->post();
  115. if ($this->service->delete($params)) {
  116. return message($this->service->getError(), true);
  117. } else {
  118. return message($this->service->getError(), false);
  119. }
  120. }
  121. /**
  122. * 选项列表
  123. * @return mixed
  124. */
  125. public function options()
  126. {
  127. $result = $this->service->options();
  128. return message(1002, true, $result);
  129. }
  130. }