chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
133
crmeb/services/wechat/client/work/ContactWayClient.php
Normal file
133
crmeb/services/wechat/client/work/ContactWayClient.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 联系客服
|
||||
* Class ContactWayClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/19
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class ContactWayClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* 配置客户联系「联系我」方式.
|
||||
* @param int $type
|
||||
* @param int $scene
|
||||
* @param array $config
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function create(int $type, int $scene, array $config = []): ResponseInterface|Response
|
||||
{
|
||||
$params = array_merge([
|
||||
'type' => $type,
|
||||
'scene' => $scene,
|
||||
], $config);
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/add_contact_way', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新企业已配置的「联系我」方式.
|
||||
* @param string $configId
|
||||
* @param array $config
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function update(string $configId, array $config = []): ResponseInterface|Response
|
||||
{
|
||||
$params = array_merge([
|
||||
'config_id' => $configId,
|
||||
], $config);
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/update_contact_way', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除企业已配置的「联系我」方式.
|
||||
* @param string $configId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function delete(string $configId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/del_contact_way', [
|
||||
'config_id' => $configId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业已配置的「联系我」列表,注意,该接口仅可获取2021年7月10日以后创建的「联系我」
|
||||
* @param string $cursor 分页查询使用的游标,为上次请求返回的 next_cursor
|
||||
* @param int $limit 每次查询的分页大小,默认为100条,最多支持1000条
|
||||
* @param int|null $startTime 「联系我」创建起始时间戳, 不传默认为90天前
|
||||
* @param int|null $endTime 「联系我」创建结束时间戳, 不传默认为当前时间
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function list(string $cursor = '', int $limit = 100, int $startTime = null, int $endTime = null): ResponseInterface|Response
|
||||
{
|
||||
$data = [
|
||||
'cursor' => $cursor,
|
||||
'limit' => $limit,
|
||||
];
|
||||
if ($startTime) {
|
||||
$data['start_time'] = $startTime;
|
||||
}
|
||||
if ($endTime) {
|
||||
$data['end_time'] = $endTime;
|
||||
}
|
||||
return $this->api->postJson('cgi-bin/externalcontact/list_contact_way', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束临时会话
|
||||
* @param string $userId 企业成员的user_id
|
||||
* @param string $externalUserId 客户的外部联系人user_id
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function closeTempChat(string $userId, string $externalUserId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/close_temp_chat', [
|
||||
'userid' => $userId,
|
||||
'external_userid' => $externalUserId
|
||||
]);
|
||||
}
|
||||
}
|
||||
101
crmeb/services/wechat/client/work/DepartmentClient.php
Normal file
101
crmeb/services/wechat/client/work/DepartmentClient.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
* Class DepartmentClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class DepartmentClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取部门信息
|
||||
* @param int $id
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function get(int $id): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/department/get', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
* @param int|null $id
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function list(?int $id = null): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/department/list', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子部门ID列表
|
||||
* @param int|null $id
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function simpleList(?int $id = null): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/department/simplelist', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员ID列表
|
||||
* @param int $limit
|
||||
* @param string $cursor
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getUserListIds(int $limit = 0, string $cursor = ''): ResponseInterface|Response
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($limit) {
|
||||
$data['limit'] = $limit;
|
||||
}
|
||||
|
||||
if ($cursor) {
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
return $this->api->postJson('cgi-bin/user/list_id', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
222
crmeb/services/wechat/client/work/ExternalContactClient.php
Normal file
222
crmeb/services/wechat/client/work/ExternalContactClient.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 外部联系
|
||||
* Class ExternalContactClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class ExternalContactClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取外部联系人详情
|
||||
* @param string $externalUserId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function get(string $externalUserId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/externalcontact/get', [
|
||||
'external_userid' => $externalUserId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取客户详情
|
||||
* @param array $userIdList
|
||||
* @param string $cursor
|
||||
* @param int $limit
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function batchGet(array $userIdList, string $cursor = '', int $limit = 100): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/batch/get_by_user', [
|
||||
'userid_list' => $userIdList,
|
||||
'cursor' => $cursor,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业标签库
|
||||
* @param array $tagIds
|
||||
* @param array $groupIds
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getCorpTags(array $tagIds = [], array $groupIds = []): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'tag_id' => $tagIds,
|
||||
'group_id' => $groupIds
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_corp_tag_list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加企业客户标签
|
||||
* @param array $params
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function addCorpTag(array $params): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/add_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑企业客户标签
|
||||
* @param string $id
|
||||
* @param string|null $name
|
||||
* @param int|null $order
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function updateCorpTag(string $id, ?string $name = null, ?int $order = null): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
"id" => $id
|
||||
];
|
||||
|
||||
if (!\is_null($name)) {
|
||||
$params['name'] = $name;
|
||||
}
|
||||
|
||||
if (!\is_null($order)) {
|
||||
$params['order'] = $order;
|
||||
}
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/edit_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除企业客户标签
|
||||
* @param array $tagId
|
||||
* @param array $groupId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function deleteCorpTag(array $tagId, array $groupId): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
"tag_id" => $tagId,
|
||||
"group_id" => $groupId,
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/del_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑客户企业标签
|
||||
* @param array $params
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function markTags(array $params): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/mark_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户群列表
|
||||
* @param array $params
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getGroupChats(array $params): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户群详情
|
||||
* @param string $chatId
|
||||
* @param int $needName
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getGroupChat(string $chatId, int $needName = 0): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'chat_id' => $chatId,
|
||||
'need_name' => $needName,
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取「群聊数据统计」数据. (按自然日聚合的方式)
|
||||
* @param int $dayBeginTime
|
||||
* @param int $dayEndTime
|
||||
* @param array $userIds
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function groupChatStatisticGroupByDay(int $dayBeginTime, int $dayEndTime, array $userIds = []): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'day_begin_time' => $dayBeginTime,
|
||||
'day_end_time' => $dayEndTime,
|
||||
'owner_filter' => [
|
||||
'userid_list' => $userIds
|
||||
]
|
||||
];
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/statistic_group_by_day', $params);
|
||||
}
|
||||
|
||||
}
|
||||
121
crmeb/services/wechat/client/work/GroupChatClient.php
Normal file
121
crmeb/services/wechat/client/work/GroupChatClient.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 客户群聊配置
|
||||
* Class GroupChatClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class GroupChatClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 更新客户群进群方式配置
|
||||
* @param string $configId
|
||||
* @param string $roomBaseName
|
||||
* @param array $chatIdList
|
||||
* @param string $state
|
||||
* @param int $autoCreateRoom
|
||||
* @param int $roomBaseId
|
||||
* @param string|null $remark
|
||||
* @param int $scene
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function updateJoinWay(string $configId, string $roomBaseName, array $chatIdList, string $state, int $autoCreateRoom = 1, int $roomBaseId = 1, string $remark = null, int $scene = 2): ResponseInterface|Response
|
||||
{
|
||||
$data = [
|
||||
'config_id' => $configId,
|
||||
'scene' => $scene,
|
||||
'remark' => $remark,
|
||||
'auto_create_room' => $autoCreateRoom,
|
||||
'room_base_name' => $roomBaseName,
|
||||
'room_base_id' => $roomBaseId,
|
||||
'chat_id_list' => $chatIdList,
|
||||
'state' => $state,
|
||||
];
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/update_join_way', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置客户群进群方式
|
||||
* @param string $roomName
|
||||
* @param array $chatIdList
|
||||
* @param string $state
|
||||
* @param int $autoCreateRoom
|
||||
* @param int $roomBaseId
|
||||
* @param string|null $remark
|
||||
* @param int $scene
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function addJoinWay(string $roomName, array $chatIdList, string $state, int $autoCreateRoom = 1, int $roomBaseId = 1, string $remark = null, int $scene = 2): ResponseInterface|Response
|
||||
{
|
||||
$data = [
|
||||
'scene' => $scene,
|
||||
'remark' => $remark,
|
||||
'chat_id_list' => $chatIdList,
|
||||
'auto_create_room' => $autoCreateRoom,
|
||||
'room_base_name' => $roomName,
|
||||
'room_base_id' => $roomBaseId,
|
||||
'state' => $state
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/add_join_way', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户群进群方式配置
|
||||
* @param string $configId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getJoinWay(string $configId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/get_join_way', ['config_id' => $configId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客户群进群方式配置
|
||||
* @param string $configId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function deleteJoinWay(string $configId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/groupchat/del_join_way', ['config_id' => $configId]);
|
||||
}
|
||||
|
||||
}
|
||||
85
crmeb/services/wechat/client/work/MediaClient.php
Normal file
85
crmeb/services/wechat/client/work/MediaClient.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
/**
|
||||
* 附件管理
|
||||
* Class MediaClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class MediaClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $path
|
||||
* @param array $form
|
||||
* @return Response
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function upload(string $type, string $path, array $form = []): Response
|
||||
{
|
||||
$files = [
|
||||
'media' => $path,
|
||||
];
|
||||
|
||||
return $this->httpUpload('cgi-bin/media/upload', $files, $form, compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件资源
|
||||
* @param string $path
|
||||
* @param string $mediaType
|
||||
* @param string $attachmentType
|
||||
* @return Response
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function uploadAttachment(string $path, string $mediaType, string $attachmentType): Response
|
||||
{
|
||||
$query = [
|
||||
'media_type' => $mediaType,
|
||||
'attachment_type' => $attachmentType,
|
||||
];
|
||||
|
||||
return $this->httpUpload('cgi-bin/media/upload_attachment', ['media' => $path], $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临时素材
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @param string $mediaId
|
||||
* @return Response
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public function get(string $mediaId): Response
|
||||
{
|
||||
return $this->getResources($mediaId, 'cgi-bin/media/get');
|
||||
}
|
||||
}
|
||||
225
crmeb/services/wechat/client/work/MessageClient.php
Normal file
225
crmeb/services/wechat/client/work/MessageClient.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use crmeb\services\wechat\WechatException;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 消息发送
|
||||
* Class MessageClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/10/8
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class MessageClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* Required attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $required = ['content', 'title', 'url', 'pic_media_id', 'appid', 'page'];
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $textMessage = [
|
||||
'content' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $imageMessage = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $linkMessage = [
|
||||
'title' => '',
|
||||
'picurl' => '',
|
||||
'desc' => '',
|
||||
'url' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $miniprogramMessage = [
|
||||
'title' => '',
|
||||
'pic_media_id' => '',
|
||||
'appid' => '',
|
||||
'page' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $message
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function send(array $message): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/message/send', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加企业群发消息模板
|
||||
* @param array $msg
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function submit(array $msg): ResponseInterface|Response
|
||||
{
|
||||
$params = $this->formatMessage($msg);
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/add_msg_template', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/26
|
||||
*/
|
||||
protected function formatMessage(array $data = [])
|
||||
{
|
||||
$params = $data;
|
||||
|
||||
if (!empty($params['text'])) {
|
||||
$params['text'] = $this->formatFields($params['text'], $this->textMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['image'])) {
|
||||
$params['image'] = $this->formatFields($params['image'], $this->imageMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['link'])) {
|
||||
$params['link'] = $this->formatFields($params['link'], $this->linkMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['miniprogram'])) {
|
||||
$params['miniprogram'] = $this->formatFields($params['miniprogram'], $this->miniprogramMessage);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $default
|
||||
* @return array
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/26
|
||||
*/
|
||||
protected function formatFields(array $data = [], array $default = [])
|
||||
{
|
||||
$params = array_merge($default, $data);
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($default[$key])) {
|
||||
throw new WechatException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $default[$key] : $value;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $welcomeCode
|
||||
* @param array $msg
|
||||
* @return ResponseInterface|Response
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/26
|
||||
*/
|
||||
public function sendWelcome(string $welcomeCode, array $msg): ResponseInterface|Response
|
||||
{
|
||||
$formattedMsg = $this->formatMessage($msg);
|
||||
|
||||
$params = array_merge($formattedMsg, [
|
||||
'welcome_code' => $welcomeCode,
|
||||
]);
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/send_welcome_msg', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群发成员发送任务列表
|
||||
* @param string $msgId 群发消息的id,通过获取群发记录列表接口返回
|
||||
* @param int|null $limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
|
||||
* @param string|null $cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getGroupmsgTask(string $msgId, ?int $limit = null, ?string $cursor = null): ResponseInterface|Response
|
||||
{
|
||||
$data = [
|
||||
'msgid' => $msgId,
|
||||
'limit' => $limit,
|
||||
'cursor' => $cursor,
|
||||
];
|
||||
$writableData = array_filter($data, function (string $key) use ($data) {
|
||||
return !is_null($data[$key]);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_groupmsg_task', $writableData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业群发成员执行结果
|
||||
* @param string $msgId 群发消息的id,通过获取群发记录列表接口返回
|
||||
* @param string $userid 发送成员userid,通过获取群发成员发送任务列表接口返回
|
||||
* @param int|null $limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
|
||||
* @param string|null $cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getGroupmsgSendResult(string $msgId, string $userid, ?int $limit = null, ?string $cursor = null): ResponseInterface|Response
|
||||
{
|
||||
$data = [
|
||||
'msgid' => $msgId,
|
||||
'userid' => $userid,
|
||||
'limit' => $limit,
|
||||
'cursor' => $cursor,
|
||||
];
|
||||
$writableData = array_filter($data, function (string $key) use ($data) {
|
||||
return !is_null($data[$key]);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_groupmsg_send_result', $writableData);
|
||||
}
|
||||
}
|
||||
164
crmeb/services/wechat/client/work/MomentClient.php
Normal file
164
crmeb/services/wechat/client/work/MomentClient.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
/**
|
||||
* 朋友圈
|
||||
* Class MomentClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class MomentClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建发表任务
|
||||
* @param array $param
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function createTask(array $param): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/add_moment_task', $param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务创建结果
|
||||
* @param string $jobId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getTask(string $jobId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/externalcontact/get_moment_task_result', ['jobid' => $jobId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业全部的发表列表
|
||||
* @param array $params
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function list(array $params): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_moment_list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户朋友圈企业发表的列表
|
||||
* @param string $momentId
|
||||
* @param string $cursor
|
||||
* @param int $limit
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getTasks(string $momentId, string $cursor = '', int $limit = 500): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'moment_id' => $momentId,
|
||||
'cursor' => $cursor,
|
||||
'limit' => $limit
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_moment_task', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户朋友圈发表时选择的可见范围
|
||||
* @param string $momentId
|
||||
* @param string $userId
|
||||
* @param string $cursor
|
||||
* @param int $limit
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getCustomers(string $momentId, string $userId, string $cursor, int $limit): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'moment_id' => $momentId,
|
||||
'userid' => $userId,
|
||||
'cursor' => $cursor,
|
||||
'limit' => $limit
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_moment_customer_list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户朋友圈发表后的可见客户列表
|
||||
* @param string $momentId
|
||||
* @param string $userId
|
||||
* @param string $cursor
|
||||
* @param int $limit
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getSendResult(string $momentId, string $userId, string $cursor, int $limit): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'moment_id' => $momentId,
|
||||
'userid' => $userId,
|
||||
'cursor' => $cursor,
|
||||
'limit' => $limit
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_moment_send_result', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户朋友圈的互动数据
|
||||
* @param string $momentId
|
||||
* @param string $userId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getComments(string $momentId, string $userId): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'moment_id' => $momentId,
|
||||
'userid' => $userId
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/externalcontact/get_moment_comments', $params);
|
||||
}
|
||||
}
|
||||
86
crmeb/services/wechat/client/work/UserClient.php
Normal file
86
crmeb/services/wechat/client/work/UserClient.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\client\work;
|
||||
|
||||
|
||||
use crmeb\services\wechat\client\BaseClient;
|
||||
use EasyWeChat\Kernel\HttpClient\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
* Class UserClient
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/18
|
||||
* @package crmeb\services\wechat\client\work
|
||||
*/
|
||||
class UserClient extends BaseClient
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取部门成员详细信息
|
||||
* @param int $departmentId
|
||||
* @param bool $fetchChild
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function getDetailedDepartmentUsers(int $departmentId, bool $fetchChild = false): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'department_id' => $departmentId,
|
||||
'fetch_child' => (int)$fetchChild,
|
||||
];
|
||||
|
||||
return $this->api->get('cgi-bin/user/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通讯录成员详情
|
||||
* @param string $userId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function get(string $userId): ResponseInterface|Response
|
||||
{
|
||||
return $this->api->get('cgi-bin/user/get', ['userid' => $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* userid转openid
|
||||
* @param string $userId
|
||||
* @param int|null $agentId
|
||||
* @return Response|ResponseInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
public function userIdToOpenid(string $userId, int $agentId = null): ResponseInterface|Response
|
||||
{
|
||||
$params = [
|
||||
'userid' => $userId,
|
||||
'agentid' => $agentId,
|
||||
];
|
||||
|
||||
return $this->api->postJson('cgi-bin/user/convert_to_openid', $params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user