StoreController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. return $this->service->edit();
  89. }
  90. /**
  91. * 编辑商家
  92. * @return array
  93. */
  94. public function edit()
  95. {
  96. return $this->service->edit();
  97. }
  98. /**
  99. * 删除商家
  100. * @return array
  101. */
  102. public function delete()
  103. {
  104. if ($this->service->delete()) {
  105. return message($this->service->getError(), true);
  106. } else {
  107. return message($this->service->getError(), false);
  108. }
  109. }
  110. /**
  111. * 选项列表
  112. * @return mixed
  113. */
  114. public function options()
  115. {
  116. $result = $this->service->options();
  117. return message(1002, true, $result);
  118. }
  119. }