Setting.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\servicer\shop\controller;
  11. use addon\servicer\model\Servicer;
  12. use app\shop\controller\BaseShop;
  13. /**
  14. * 客服设置控制器
  15. */
  16. class Setting extends BaseShop
  17. {
  18. /**
  19. * 客服设置页面
  20. *
  21. * @return mixed
  22. */
  23. public function index()
  24. {
  25. $servicerModel = new Servicer();
  26. $list = $servicerModel->getServicerList();
  27. return $this->fetch('setting/index');
  28. }
  29. /**
  30. * 添加客服
  31. *
  32. * @return string
  33. */
  34. public function addServicer()
  35. {
  36. if (request()->isAjax()) {
  37. $nickName = input('nick_name', '');
  38. $userId = input('user_id', 0);
  39. $type = input('type', -1);
  40. $headImg = input('head_img', '');
  41. if (empty($nickName)) {
  42. return error(-1, '客服昵称不能空');
  43. }
  44. if (empty($userId)) {
  45. return error(-1, '归属用户不能空');
  46. }
  47. if ($type == -1) {
  48. return error(-1, '客服类型不能空');
  49. }
  50. $servicerModel = new Servicer();
  51. $servicer = $servicerModel->createServicer($nickName, 1, $type, $userId, $headImg);
  52. if (empty($servicer)) {
  53. $servicerModel->error();
  54. }
  55. return $servicerModel->success($servicer);
  56. }
  57. return error();
  58. }
  59. /**
  60. * 删除客服
  61. *
  62. * @return string
  63. */
  64. public function delServicer()
  65. {
  66. $servicer_id = input('servicer_id', 0);
  67. if (empty($servicer_id)) {
  68. return error(-1, '参数不合法');
  69. }
  70. return (new Servicer())->delServicer($servicer_id);
  71. }
  72. /**
  73. * 修改用户头像
  74. *
  75. * @return string
  76. */
  77. public function setHead()
  78. {
  79. // TODO: 明确是否有现成的上传方案
  80. }
  81. }