GroupChat.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\v1\work;
  12. use app\controller\admin\AuthController;
  13. use app\model\work\WorkGroupChatStatistic;
  14. use app\services\work\WorkGroupChatMemberServices;
  15. use app\services\work\WorkGroupChatServices;
  16. use app\services\work\WorkGroupChatStatisticServices;
  17. use think\facade\App;
  18. /**
  19. * 企业微信群
  20. * Class GroupChat
  21. * @package app\controller\admin\v1\work
  22. */
  23. class GroupChat extends AuthController
  24. {
  25. /**
  26. * GroupChat constructor.
  27. * @param App $app
  28. * @param WorkGroupChatServices $services
  29. */
  30. public function __construct(App $app, WorkGroupChatServices $services)
  31. {
  32. parent::__construct($app);
  33. $this->services = $services;
  34. }
  35. /**
  36. * 获取群列表
  37. * @return mixed
  38. */
  39. public function index()
  40. {
  41. $where = $this->request->getMore([
  42. ['userids', []],
  43. ['time', ''],
  44. ['name', '']
  45. ]);
  46. return $this->success($this->services->getList($where));
  47. }
  48. /**
  49. * 同步企业微信群
  50. * @return mixed
  51. */
  52. public function synchGroupChat()
  53. {
  54. $this->services->authGroupChat();
  55. return $this->success('已加入消息队列,请稍后查看');
  56. }
  57. /**
  58. * 群成员
  59. * @param WorkGroupChatMemberServices $services
  60. * @param $id
  61. * @return mixed
  62. */
  63. public function chatMember(WorkGroupChatMemberServices $services, $id)
  64. {
  65. if (!$id) {
  66. return $this->fail('缺少参数');
  67. }
  68. return $this->success($services->getChatMemberList((int)$id));
  69. }
  70. /**
  71. * 客户群统计
  72. * @param $id
  73. * @return mixed
  74. */
  75. public function chatStatistics($id)
  76. {
  77. if (!$id) {
  78. return $this->fail('缺少参数');
  79. }
  80. $time = $this->request->get('time', '');
  81. return $this->success($this->services->getChatStatistics((int)$id, $time));
  82. }
  83. /**
  84. * 客户群统计列表数据
  85. * @param WorkGroupChatStatisticServices $services
  86. * @param $id
  87. * @return mixed
  88. */
  89. public function chatStatisticsList(WorkGroupChatStatisticServices $services, $id)
  90. {
  91. if (!$id) {
  92. return $this->fail('缺少参数');
  93. }
  94. $time = $this->request->get('time', '');
  95. return $this->success($services->getChatStatisticsList((int)$id, $time));
  96. }
  97. }