GoodsController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\GoodsService;
  13. /**
  14. * 商品管理-控制器
  15. * @author laravel开发员
  16. * @since 2020/11/11
  17. * Class GoodsController
  18. * @package App\Http\Controllers
  19. */
  20. class GoodsController extends Backend
  21. {
  22. /**
  23. * 构造函数
  24. * @author laravel开发员
  25. * @since 2020/11/11
  26. * GoodsController constructor.
  27. */
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. $this->service = new GoodsService();
  32. }
  33. /**
  34. * 列表(商品审核列表)
  35. * @return array
  36. */
  37. public function index()
  38. {
  39. $pageSize = request()->get('limit', 15);
  40. $params = request()->all();
  41. $params['store_id'] = $this->storeId;
  42. $list = $this->service->getDataList($params, $pageSize);
  43. $message = array(
  44. "msg" => '操作成功',
  45. "code" => 0,
  46. "data" => isset($list['list']) ? $list['list'] : [],
  47. "count" => isset($list['total']) ? $list['total'] : 0,
  48. );
  49. return $message;
  50. }
  51. /**
  52. * 获取详情
  53. * @return array
  54. */
  55. public function info()
  56. {
  57. return $this->service->info();
  58. }
  59. /**
  60. * 添加或编辑
  61. * @return array
  62. */
  63. public function edit()
  64. {
  65. return $this->service->edit();
  66. }
  67. /**
  68. * 审核商品
  69. * @return array
  70. */
  71. public function confirm()
  72. {
  73. $params = request()->post();
  74. if ($this->service->confirm($this->userId, $params)) {
  75. return message($this->service->getError(), true);
  76. } else {
  77. return message($this->service->getError(), false);
  78. }
  79. }
  80. /**
  81. * 删除数据
  82. * @return mixed
  83. * @since 2020/11/11
  84. * @author laravel开发员
  85. */
  86. public function delete()
  87. {
  88. $result = $this->service->delete();
  89. return $result;
  90. }
  91. /**
  92. * 选项列表(用于下拉选择)
  93. * @return array
  94. */
  95. public function options()
  96. {
  97. // 这里可以返回商品选项,如果需要的话
  98. return message('操作成功', true, []);
  99. }
  100. }