ExternalContact.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php namespace App\Servers\WechatWork;
  2. /**
  3. * 获取配置了客户联系功能的成员列表
  4. *
  5. */
  6. class ExternalContact extends Work
  7. {
  8. /**
  9. * 获取配置了客户联系功能的成员列表
  10. *
  11. *
  12. */
  13. public function getFollowUsers(){
  14. // 获取部门列表
  15. $result = $this->work->external_contact->getFollowUsers();
  16. // 返回列表
  17. if( $result['errcode'] == 0 ) return $result['follow_user'];
  18. // 如果请求失败,返回空数据
  19. return [];
  20. }
  21. /**
  22. * 批量获取客户详情
  23. *
  24. * @param array $userIdList 接待成员ID列表
  25. * @param string $cursor 分页游标
  26. * @param int $limit 每页数量
  27. *
  28. */
  29. public function batchGetByUser($userIdList,$cursor,$limit=100) {
  30. // 获取部门列表
  31. $result = $this->work->external_contact->batchGetByUser($userIdList, $cursor, $limit);
  32. // 返回列表
  33. if( $result['errcode'] == 0 ) return ['external_contact_list'=>$result['external_contact_list'], 'next_cursor'=> empty($result['next_cursor']) ? '' : $result['next_cursor']];
  34. // 如果请求失败,返回空数据
  35. return [];
  36. }
  37. /**
  38. * 获取详情
  39. *
  40. * @param string $extUserid 外部联系人ID
  41. *
  42. */
  43. public function getOne($extUserid){
  44. // 获取部门列表
  45. $result = $this->work->external_contact->get($extUserid);
  46. // 返回列表
  47. if( $result['errcode'] == 0 ) return ['external_contact'=>$result['external_contact'],'follow_user'=>$result['follow_user']];
  48. // 如果请求失败,返回空数据
  49. return [];
  50. }
  51. /**
  52. * 发送欢迎语
  53. *
  54. * @param string $welcomeCode 欢迎语code
  55. * @param array $msg 欢迎语code
  56. *
  57. */
  58. public function sendWelcome($welcomeCode, $msg){
  59. // 获取部门列表
  60. $result = $this->work->external_contact_message->sendWelcome($welcomeCode, $msg);
  61. // 返回列表
  62. if( $result['errcode'] == 0 ) return true;
  63. // 如果请求失败,返回空数据
  64. return false;
  65. }
  66. /**
  67. * 修改备注信息
  68. *
  69. * @param string $extUserid 外部联系人ID
  70. * @param string $userid 跟进人ID
  71. * @param array $data 要修改的信息
  72. *
  73. */
  74. public function remark($extUserid, $userid,$data=[]){
  75. // 修改信息
  76. $data['external_userid'] = $extUserid;
  77. $data['userid'] = $userid;
  78. // 获取部门列表
  79. $result = $this->work->external_contact->remark($data);
  80. // 返回列表
  81. if( $result['errcode'] == 0 ) return true;
  82. // 如果请求失败,返回空数据
  83. return false;
  84. }
  85. }