Store.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\admin\controller;
  13. use app\admin\model\Store as StoreModel;
  14. /**
  15. * 小程序商城管理
  16. * Class Store
  17. * @package app\admin\controller
  18. */
  19. class Store extends Controller
  20. {
  21. /**
  22. * 强制验证当前访问的控制器方法method
  23. * @var array
  24. */
  25. protected $methodRules = [
  26. 'index' => 'GET',
  27. 'recycle' => 'GET',
  28. 'add' => 'POST',
  29. 'move' => 'POST',
  30. 'delete' => 'POST',
  31. ];
  32. /**
  33. * 小程序商城列表
  34. * @return array
  35. * @throws \think\db\exception\DbException
  36. */
  37. public function index()
  38. {
  39. // 商城列表
  40. $model = new StoreModel;
  41. $list = $model->getList();
  42. return $this->renderSuccess(compact('list'));
  43. }
  44. /**
  45. * 回收站列表
  46. * @return array
  47. * @throws \think\db\exception\DbException
  48. */
  49. public function recycle()
  50. {
  51. // 商城列表
  52. $model = new StoreModel;
  53. $list = $model->getList(true);
  54. return $this->renderSuccess(compact('list'));
  55. }
  56. /**
  57. * 回收小程序
  58. * @param int $storeId
  59. * @return array
  60. */
  61. public function recovery(int $storeId)
  62. {
  63. // 小程序详情
  64. $model = StoreModel::detail($storeId);
  65. if (!$model->recycle()) {
  66. return $this->renderError($model->getError() ?: '操作失败');
  67. }
  68. return $this->renderSuccess('操作成功');
  69. }
  70. /**
  71. * 移出回收站
  72. * @param int $storeId
  73. * @return array
  74. */
  75. public function move(int $storeId)
  76. {
  77. // 小程序详情
  78. $model = StoreModel::detail($storeId);
  79. if (!$model->recycle(false)) {
  80. return $this->renderError($model->getError() ?: '操作失败');
  81. }
  82. return $this->renderSuccess('操作成功');
  83. }
  84. public function add()
  85. {
  86. return $this->renderError('很抱歉,免费版暂不支持多开商城');
  87. }
  88. }