Discounts.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\admin\store;
  12. use app\common\repositories\store\product\StoreDiscountRepository;
  13. use crmeb\basic\BaseController;
  14. use think\App;
  15. /**
  16. * 组合套餐
  17. */
  18. class Discounts extends BaseController
  19. {
  20. protected $repository;
  21. /**
  22. * Product constructor.
  23. * @param App $app
  24. * @param StoreDiscountRepository $repository
  25. */
  26. public function __construct(App $app, StoreDiscountRepository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * 列表
  33. * @return \think\response\Json
  34. * @author Qinii
  35. */
  36. public function lst()
  37. {
  38. [$page, $limit] = $this->getPage();
  39. $where = $this->request->params(['keyword', 'store_name', 'mer_id', 'title', 'status', 'type']);
  40. $data = $this->repository->getAdminlist($where, $page, $limit);
  41. return app('json')->success($data);
  42. }
  43. /**
  44. * 详情
  45. * @param $id
  46. * @return \think\response\Json
  47. * @author Qinii
  48. */
  49. public function detail($id)
  50. {
  51. $data = $this->repository->detail($id, 0);
  52. if (!$data) return app('json')->fail('数据不存在');
  53. return app('json')->success($data);
  54. }
  55. /**
  56. * 改变状态
  57. * @param $id
  58. * @return \think\response\Json
  59. * @author Qinii
  60. */
  61. public function switchStatus($id)
  62. {
  63. $status = $this->request->param('status') == 1 ?: 0;
  64. if (!$this->repository->getWhere([$this->repository->getPk() => $id]))
  65. return app('json')->fail('数据不存在');
  66. $this->repository->update($id, ['status' => $status]);
  67. return app('json')->success('修改成功');
  68. }
  69. }