截流自动化的商城平台

IntegralGoods.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\admin\controller\integral;
  3. use app\admin\logic\integral\IntegralGoodsLogic;
  4. use app\admin\validate\integral\IntegralGoodsValidate;
  5. use app\common\basics\AdminBase;
  6. use app\common\server\JsonServer;
  7. /**
  8. * 积分商城-积分商品
  9. * Class IntegralGoods
  10. * @package app\admin\controller\integral
  11. */
  12. class IntegralGoods extends AdminBase
  13. {
  14. /**
  15. * @notes 商品列表
  16. * @return \think\response\Json|\think\response\View
  17. * @author 段誉
  18. * @date 2022/2/25 18:28
  19. */
  20. public function lists()
  21. {
  22. if ($this->request->isAjax()) {
  23. $get = $this->request->get();
  24. $lists = IntegralGoodsLogic::getLists($get);
  25. return JsonServer::success('获取成功', $lists);
  26. }
  27. return view();
  28. }
  29. /**
  30. * @notes 添加商品
  31. * @return \think\response\Json|\think\response\View
  32. * @author 段誉
  33. * @date 2022/2/25 18:27
  34. */
  35. public function add()
  36. {
  37. if ($this->request->isAjax()) {
  38. $post = $this->request->post();
  39. $post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 0;
  40. (new IntegralGoodsValidate())->goCheck('add', $post);
  41. $res = IntegralGoodsLogic::add($post);
  42. if (false === $res) {
  43. $error = IntegralGoodsLogic::getError() ?: '操作失败';
  44. return JsonServer::error($error);
  45. }
  46. return JsonServer::success('操作成功');
  47. }
  48. return view();
  49. }
  50. /**
  51. * @notes 编辑积分商品
  52. * @return \think\response\Json|\think\response\View
  53. * @author 段誉
  54. * @date 2022/3/1 15:40
  55. */
  56. public function edit()
  57. {
  58. if ($this->request->isAjax()) {
  59. $post = $this->request->post();
  60. $post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 0;
  61. (new IntegralGoodsValidate())->goCheck('edit', $post);
  62. $res = IntegralGoodsLogic::edit($post);
  63. if (false === $res) {
  64. $error = IntegralGoodsLogic::getError() ?: '操作失败';
  65. return JsonServer::error($error);
  66. }
  67. return JsonServer::success('操作成功');
  68. }
  69. $id = $this->request->get('id');
  70. return view('', [
  71. 'detail' => IntegralGoodsLogic::detail($id),
  72. ]);
  73. }
  74. /**
  75. * @notes 删除商品
  76. * @return \think\response\Json|void
  77. * @author 段誉
  78. * @date 2022/2/25 18:26
  79. */
  80. public function del()
  81. {
  82. if ($this->request->isAjax()) {
  83. $post = $this->request->post();
  84. (new IntegralGoodsValidate())->goCheck('del');
  85. IntegralGoodsLogic::del($post);
  86. return JsonServer::success('操作成功');
  87. }
  88. return JsonServer::error('操作失败');
  89. }
  90. /**
  91. * @notes 切换状态
  92. * @return \think\response\Json|void
  93. * @author 段誉
  94. * @date 2022/2/25 18:26
  95. */
  96. public function switchStatus()
  97. {
  98. if ($this->request->isAjax()) {
  99. $post = $this->request->post();
  100. IntegralGoodsLogic::switchStatus($post);
  101. return JsonServer::success('操作成功');
  102. }
  103. return JsonServer::error('操作失败');
  104. }
  105. }