ChatTeamLog.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Repositories;
  3. use App\Exceptions\TencentImException;
  4. use App\Models\ChatTeam;
  5. use App\Services\TencentImGroupService;
  6. use App\Services\TencentImMessage;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Repositories\Repository;
  9. use GuzzleHttp\Exception\GuzzleException;
  10. use Illuminate\Pagination\LengthAwarePaginator;
  11. class ChatTeamLog extends Repository
  12. {
  13. public $group_id;
  14. public $to_user_id;
  15. public function __construct($group_id)
  16. {
  17. $this->group_id = $group_id;
  18. }
  19. /**
  20. * 查询表格数据
  21. *
  22. * @param Grid\Model $model
  23. * @return LengthAwarePaginator
  24. */
  25. public function get(Grid\Model $model)
  26. {
  27. $currentPage = $model->getCurrentPage();
  28. $perPage = $model->getPerPage();
  29. $data =new TencentImGroupService();
  30. try {
  31. $req_data['GroupId'] = $this->group_id;
  32. $req_data['number'] = 20;
  33. // $req_data['seq'] = 20;
  34. $res = $data->groupMsgGetSimple($req_data);
  35. if($res['IsFinished']==1){
  36. if (!empty($res) && !empty($res['RspMsgList'])) {
  37. foreach ($res['RspMsgList'] as $k=>$v){
  38. $res['RspMsgList'][$k]['IsSystemMsg'] = $v['IsSystemMsg']??0;
  39. if($v['IsPlaceMsg']==1){
  40. unset($res['RspMsgList'][$k]);
  41. }
  42. }
  43. return $model->makePaginator(count($res['RspMsgList']),$res['RspMsgList']);
  44. }
  45. }else{
  46. return $model->makePaginator(0,[]);
  47. }
  48. } catch (TencentImException | GuzzleException $e) {
  49. return $e->getMessage();
  50. }
  51. }
  52. }