截流自动化的商城平台

Kefu.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. namespace app\admin\controller\kefu;
  3. use app\admin\logic\kefu\KefuLogic;
  4. use app\admin\validate\kefu\KefuValidate;
  5. use app\admin\validate\kefu\LoginValidate;
  6. use app\common\basics\AdminBase;
  7. use app\common\model\Role;
  8. use app\common\server\JsonServer;
  9. use think\facade\Request;
  10. /**
  11. * 客服管理控制器
  12. * Class Kefu
  13. * @package app\admin\controller\kefu
  14. */
  15. class Kefu extends AdminBase
  16. {
  17. /**
  18. * @notes 客服列表
  19. * @return \think\response\Json|\think\response\View
  20. * @author 段誉
  21. * @date 2021/11/26 18:40
  22. */
  23. public function lists()
  24. {
  25. if ($this->request->isAjax()) {
  26. $get = $this->request->get();
  27. $lists = KefuLogic::getLists($get);
  28. return JsonServer::success('获取成功', $lists);
  29. }
  30. return view();
  31. }
  32. /**
  33. * @notes 添加客服
  34. * @return \think\response\Json|\think\response\View
  35. * @author 段誉
  36. * @date 2021/11/26 18:04
  37. */
  38. public function add()
  39. {
  40. if ($this->request->isAjax()) {
  41. $post = $this->request->post();
  42. $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
  43. (new KefuValidate())->goCheck('add', $post);
  44. $res = KefuLogic::add($post);
  45. if (false === $res) {
  46. $error = KefuLogic::getError() ?: '操作失败';
  47. return JsonServer::error($error);
  48. }
  49. return JsonServer::success('操作成功');
  50. }
  51. return view();
  52. }
  53. /**
  54. * @notes 编辑客服
  55. * @return \think\response\Json|\think\response\View
  56. * @author 段誉
  57. * @date 2021/11/27 10:45
  58. */
  59. public function edit()
  60. {
  61. if ($this->request->isAjax()) {
  62. $post = $this->request->post();
  63. $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
  64. (new KefuValidate())->goCheck('edit', $post);
  65. $res = KefuLogic::edit($post);
  66. if (false === $res) {
  67. $error = KefuLogic::getError() ?: '操作失败';
  68. return JsonServer::error($error);
  69. }
  70. return JsonServer::success('操作成功');
  71. }
  72. $id = $this->request->get('id');
  73. return view('', [
  74. 'detail' => KefuLogic::detail($id),
  75. ]);
  76. }
  77. /**
  78. * @notes 删除客服
  79. * @return \think\response\Json|void
  80. * @author 段誉
  81. * @date 2021/11/26 18:53
  82. */
  83. public function del()
  84. {
  85. if ($this->request->isAjax()) {
  86. $post = $this->request->post();
  87. (new KefuValidate())->goCheck('del');
  88. KefuLogic::del($post);
  89. return JsonServer::success('操作成功');
  90. }
  91. }
  92. /**
  93. * @notes 管理员列表
  94. * @return \think\response\Json|\think\response\View
  95. * @throws \think\db\exception\DataNotFoundException
  96. * @throws \think\db\exception\DbException
  97. * @throws \think\db\exception\ModelNotFoundException
  98. * @author 段誉
  99. * @date 2021/11/26 18:01
  100. */
  101. public function adminLists()
  102. {
  103. if ($this->request->isAjax()) {
  104. $get = $this->request->get();
  105. return JsonServer::success('', KefuLogic::getAdminLists($get));
  106. }
  107. return view('', ['role_lists' => (new Role())->getRoleLists()]);
  108. }
  109. /**
  110. * @notes 设置状态
  111. * @return \think\response\Json|void
  112. * @author 段誉
  113. * @date 2021/11/26 18:40
  114. */
  115. public function status()
  116. {
  117. if ($this->request->isAjax()) {
  118. $post = $this->request->post();
  119. KefuLogic::setStatus($post);
  120. return JsonServer::success('操作成功');
  121. }
  122. }
  123. /**
  124. * @notes 登录工作台
  125. * @return \think\response\Json
  126. * @author 段誉
  127. * @date 2021/12/15 19:57
  128. */
  129. public function login()
  130. {
  131. if ($this->request->isAjax()) {
  132. $id = $this->request->post('id/d');
  133. (new LoginValidate())->goCheck();
  134. $res = KefuLogic::login($id);
  135. if (false === $res) {
  136. return JsonServer::error(KefuLogic::getError() ?: '系统错误');
  137. }
  138. return JsonServer::success('', ['url' => $res]);
  139. }
  140. }
  141. }