Discounts.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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. class Discounts extends BaseController
  16. {
  17. protected $repository ;
  18. /**
  19. * Product constructor.
  20. * @param App $app
  21. * @param StoreDiscountRepository $repository
  22. */
  23. public function __construct(App $app ,StoreDiscountRepository $repository)
  24. {
  25. parent::__construct($app);
  26. $this->repository = $repository;
  27. }
  28. public function lst()
  29. {
  30. [$page, $limit] = $this->getPage();
  31. $where = $this->request->params(['keyword','store_name','mer_id','title','status','type']);
  32. $data = $this->repository->getAdminlist($where, $page, $limit);
  33. return app('json')->success($data);
  34. }
  35. public function detail($id)
  36. {
  37. $data = $this->repository->detail($id, 0);
  38. if (!$data ) return app('json')->fail('数据不存在');
  39. return app('json')->success($data);
  40. }
  41. public function switchStatus($id)
  42. {
  43. $status = $this->request->param('status') == 1 ?: 0;
  44. if (!$this->repository->getWhere([$this->repository->getPk() => $id]))
  45. return app('json')->fail('数据不存在');
  46. $this->repository->update($id, ['status' => $status]);
  47. return app('json')->success('修改成功');
  48. }
  49. }