BroadcastGoods.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\broadcast\BroadcastGoodsRepository;
  13. use crmeb\basic\BaseController;
  14. use think\App;
  15. class BroadcastGoods extends BaseController
  16. {
  17. protected $repository;
  18. public function __construct(App $app, BroadcastGoodsRepository $repository)
  19. {
  20. parent::__construct($app);
  21. $this->repository = $repository;
  22. }
  23. public function lst()
  24. {
  25. [$page, $limit] = $this->getPage();
  26. $where = $this->request->params(['keyword', 'status_tag', 'is_trader', 'mer_valid','broadcast_goods_id']);
  27. return app('json')->success($this->repository->adminList($where, $page, $limit));
  28. }
  29. public function detail($id)
  30. {
  31. if (!$this->repository->exists($id))
  32. return app('json')->fail('数据不存在');
  33. return app('json')->success($this->repository->get($id)->append(['product'])->toArray());
  34. }
  35. public function applyForm($id)
  36. {
  37. if (!$this->repository->exists($id))
  38. return app('json')->fail('数据不存在');
  39. return app('json')->success(formToData($this->repository->applyForm($id)));
  40. }
  41. public function apply($id)
  42. {
  43. if (!$this->repository->exists($id))
  44. return app('json')->fail('数据不存在');
  45. [$status, $msg] = $this->request->params(['status', 'msg'], true);
  46. $status = $status == 1 ? 1 : -1;
  47. if ($status == -1 && !$msg)
  48. return app('json')->fail('请输入理由');
  49. $this->repository->apply($id, $status, $msg);
  50. return app('json')->success('操作成功');
  51. }
  52. public function changeStatus($id)
  53. {
  54. $isShow = $this->request->param('is_show') == 1 ? 1 : 0;
  55. if (!$this->repository->exists($id))
  56. return app('json')->fail('数据不存在');
  57. $this->repository->isShow($id, $isShow, true);
  58. return app('json')->success('修改成功');
  59. }
  60. public function sort($id)
  61. {
  62. $sort = (int)$this->request->param('sort');
  63. if (!$this->repository->exists($id))
  64. return app('json')->fail('数据不存在');
  65. $this->repository->change($id, compact('sort'));
  66. return app('json')->success('修改成功');
  67. }
  68. public function delete($id)
  69. {
  70. if (!$this->repository->exists($id))
  71. return app('json')->fail('数据不存在');
  72. $this->repository->delete($id);
  73. return app('json')->success('删除成功');
  74. }
  75. }