Client.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 crmeb\services\wechat\groupChat;
  12. use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
  13. use EasyWeChat\Work\ExternalContact\Client as WorkClient;
  14. use GuzzleHttp\Exception\GuzzleException;
  15. /**
  16. * 客户群聊配置
  17. * Class Client
  18. * @package crmeb\services\wechat\groupChat
  19. */
  20. class Client extends WorkClient
  21. {
  22. /**
  23. * 配置客户群进群方式
  24. * @param string $roomName 自动建群的群名前缀
  25. * @param array $chatIdList 使用该配置的客户群ID列表
  26. * @param string $state 企业自定义的state参数
  27. * @param int $autoCreateRoom 当群满了后,是否自动新建群。0-否;1-是。 默认为1
  28. * @param string|null $remark 联系方式的备注信息
  29. * @param int $scene 场景。1 - 群的小程序插件 2 - 群的二维码插件
  30. * @param int $roomBaseId 自动建群的群起始序号
  31. * @return array
  32. * @throws GuzzleException
  33. * @throws InvalidConfigException
  34. */
  35. public function addJoinWay(string $roomName, array $chatIdList, string $state, int $autoCreateRoom = 1, int $roomBaseId = 1, string $remark = null, int $scene = 2)
  36. {
  37. $data = [
  38. 'scene' => $scene,
  39. 'remark' => $remark,
  40. 'chat_id_list' => $chatIdList,
  41. 'auto_create_room' => $autoCreateRoom,
  42. 'room_base_name' => $roomName,
  43. 'room_base_id' => $roomBaseId,
  44. 'state' => $state
  45. ];
  46. return $this->httpPostJson('cgi-bin/externalcontact/groupchat/add_join_way', $data);
  47. }
  48. /**
  49. * 更新客户群进群方式配置
  50. * @param string $configId
  51. * @param string $roomBaseName
  52. * @param array $chatIdList
  53. * @param string $state
  54. * @param int $autoCreateRoom
  55. * @param string|null $remark
  56. * @param int $scene
  57. * @param int $roomBaseId
  58. * @return array
  59. * @throws GuzzleException
  60. * @throws InvalidConfigException
  61. */
  62. public function updateJoinWay(string $configId, string $roomBaseName, array $chatIdList, string $state, int $autoCreateRoom = 1, int $roomBaseId = 1, string $remark = null, int $scene = 2)
  63. {
  64. $data = [
  65. 'config_id' => $configId,
  66. 'scene' => $scene,
  67. 'remark' => $remark,
  68. 'auto_create_room' => $autoCreateRoom,
  69. 'room_base_name' => $roomBaseName,
  70. 'room_base_id' => $roomBaseId,
  71. 'chat_id_list' => $chatIdList,
  72. 'state' => $state,
  73. ];
  74. return $this->httpPostJson('cgi-bin/externalcontact/groupchat/update_join_way', $data);
  75. }
  76. /**
  77. * 获取客户群进群方式配置
  78. * @param string $configId
  79. * @return array
  80. * @throws GuzzleException
  81. * @throws InvalidConfigException
  82. */
  83. public function getJoinWay(string $configId)
  84. {
  85. return $this->httpPostJson('cgi-bin/externalcontact/groupchat/get_join_way', ['config_id' => $configId]);
  86. }
  87. /**
  88. * 删除客户群进群方式配置
  89. * @param string $configId
  90. * @return array
  91. * @throws GuzzleException
  92. * @throws InvalidConfigException
  93. */
  94. public function deleteJoinWay(string $configId)
  95. {
  96. return $this->httpPostJson('cgi-bin/externalcontact/groupchat/del_join_way', ['config_id' => $configId]);
  97. }
  98. }