ChatController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\kefuapi\controller;
  20. use app\kefuapi\lists\ChatRecordLists;
  21. use app\kefuapi\logic\ChatLogic;
  22. use app\kefuapi\lists\{ChatUserLists, ChatOrderLists, KefuLangLists};
  23. use app\kefuapi\validate\{ChatRecordValidate, ChatOrderValidate};
  24. /**
  25. * 客服聊天相关
  26. * Class ChatController
  27. * @package app\kefuapi\controller
  28. */
  29. class ChatController extends BaseKefuController
  30. {
  31. public array $notNeedLogin = ['config'];
  32. /**
  33. * @notes 获取文件配置
  34. * @return \think\response\Json
  35. * @author 段誉
  36. * @date 2022/3/14 12:01
  37. */
  38. public function config()
  39. {
  40. return $this->success('', ChatLogic::getConfig());
  41. }
  42. /**
  43. * @notes 用户列表
  44. * @return \think\response\Json
  45. * @author 段誉
  46. * @date 2022/3/14 12:02
  47. */
  48. public function user()
  49. {
  50. return $this->dataLists(new ChatUserLists());
  51. }
  52. /**
  53. * @notes 获取指定用户聊天记录
  54. * @return \think\response\Json
  55. * @author 段誉
  56. * @date 2022/3/14 12:02
  57. */
  58. public function record()
  59. {
  60. (new ChatRecordValidate())->goCheck();
  61. return $this->dataLists(new ChatRecordLists());
  62. }
  63. /**
  64. * @notes 获取指定用户订单列表
  65. * @return \think\response\Json
  66. * @author 段誉
  67. * @date 2022/3/14 12:03
  68. */
  69. public function order()
  70. {
  71. (new ChatOrderValidate())->goCheck();
  72. return $this->dataLists(new ChatOrderLists());
  73. }
  74. /**
  75. * @notes 获取在线客服列表
  76. * @return \think\response\Json
  77. * @author 段誉
  78. * @date 2022/3/14 12:05
  79. */
  80. public function online()
  81. {
  82. $result = ChatLogic::getOnlineKefu($this->kefuId);
  83. return $this->success('', $result);
  84. }
  85. /**
  86. * @notes 获取快捷回复列表
  87. * @return \think\response\Json
  88. * @author 段誉
  89. * @date 2022/3/14 12:06
  90. */
  91. public function reply()
  92. {
  93. return $this->dataLists(new KefuLangLists());
  94. }
  95. /**
  96. * @notes 获取用户详情
  97. * @return \think\response\Json
  98. * @author 段誉
  99. * @date 2022/3/14 12:07
  100. */
  101. public function userInfo()
  102. {
  103. $user_id = $this->request->get('user_id/d');
  104. $result = ChatLogic::getUserInfo($user_id);
  105. if (false === $result) {
  106. return $this->fail(ChatLogic::getError() ?: '系统错误');
  107. }
  108. return $this->success('', $result);
  109. }
  110. /**
  111. * @notes 获取客服详情
  112. * @return \think\response\Json
  113. * @author 段誉
  114. * @date 2022/3/14 12:10
  115. */
  116. public function kefuInfo()
  117. {
  118. $result = ChatLogic::getKefuInfo($this->kefuId);
  119. return $this->success('', $result);
  120. }
  121. }