123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shensong
- * Date: 2022/7/27
- * Time: 10:34
- */
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- use App\Log;
- use App\Service\AndroidToolService;
- use App\Service\ChatGroup\ChatGroupMassMsgRuleService;
- use App\Service\ChatGroup\ChatGroupRuleService;
- use App\Service\ChatGroup\ChatGroupService;
- use Illuminate\Http\Request;
- use Illuminate\Validation\Rule;
- class ChatGroupController extends Controller
- {
- // 设置客户群群发规则
- public function setChatGroupMassMsg(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'name' => 'required|string',
- 'send_type' => ['required', Rule::in([1, 2])],
- 'send_mode' => ['required', Rule::in([1, 2])],
- 'send_time' => 'required|date_format:Y-m-d H:i:s',
- 'content' => ['required_without:attachments', 'nullable'],
- 'attachments' => ['required_without:content', 'nullable'],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params = array();
- $ruleId = $request->input('rule_id');
- $params['corpid'] = $request->input('corpid');
- $params['admin_id'] = $request->input('admin_id');
- $params['name'] = $request->input('name');
- $params['send_type'] = $request->input('send_type'); // 发送类型 1:立即发送 2:定时发送
- $params['send_time'] = $request->input('send_time'); // 发送时间
- $params['senders'] = $request->input('senders'); // 群主集合
- $params['content'] = $request->input('content'); // 内容
- $params['attachments'] = $request->input('attachments'); // 附件
- $params['send_mode'] = $request->input('send_mode'); // 发送方式 1按群主 2按群聊
- $params['chat_groups'] = $request->input('chat_groups'); // 群聊集合
- $params['item_id'] = $request->input('item_id'); // 商品ID
- $params['operate_type'] = $request->input('operate_type', 1);# 运营类型 1单主体 2多主体
- # 设置群发规则
- $errNo = ChatGroupRuleService::setChatGroupMassMsg($ruleId, $params);
- return self::returnValue([], $errNo);
- }
- /**
- * 客户群列表
- * */
- public function groupList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $owner = $request->input('owner');
- $keyword = $request->input('keyword');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- if($pageSize == 500) $pageSize = 20000; // 用于数据导出
- # 获取群列表
- list($list, $count) = ChatGroupRuleService::groupList($corpid, $owner, $keyword, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 查询所有群聊的去重客户数
- * */
- public function uniqueMemberCount(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $count = ChatGroupRuleService::getUniqueMemberCount($corpid);
- return self::returnValue(['member_count' => $count]);
- }
- /**
- * 客户群概况
- * */
- public function condition(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'chat_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $chatId = $request->input('chat_id');
- # 获取群概况
- $condition = ChatGroupRuleService::groupCondition($corpid, $chatId);
- return self::returnValue($condition);
- }
- /**
- * 客户群成员列表
- * */
- public function memberList(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'chat_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $chatId = $request->input('chat_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $status = $request->input('status');
- $keyword = $request->input('keyword');
- $joinTimeStart = $request->input('join_time_start');
- $joinTimeEnd = $request->input('join_time_end');
- # 获取客户群成员列表
- list($list, $count) = ChatGroupRuleService::getMemberList($corpid, $chatId, $status, $keyword, $joinTimeStart
- , $joinTimeEnd, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- // 群发消息列表
- public function ruleLists(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'send_time_start' => 'nullable|date_format:Y-m-d H:i:s',
- 'send_time_end' => 'nullable|date_format:Y-m-d H:i:s',
- 'create_time_start' => 'nullable|date_format:Y-m-d H:i:s',
- 'create_time_end' => 'nullable|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $creatorId = $request->input('creator_id');
- $sendTimeStart = $request->input('send_time_start');
- $sendTimeEnd = $request->input('send_time_end');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $ruleName = $request->input('rule_name');
- $createTimeStart = $request->input('create_time_start');
- $createTimeEnd = $request->input('create_time_end');
- $sortColumn = $request->input('sort_column','send_time');
- $sortMethod = $request->input('sort_method','desc');
- # 获取群发规则列表
- $errno = 0;
- list($list, $count) = ChatGroupMassMsgRuleService::ruleList(
- $corpid, $creatorId, $sendTimeStart, $sendTimeEnd, $createTimeStart,$createTimeEnd,$sortColumn,$sortMethod,
- $page, $pageSize, $errno, $ruleName
- );
- if($errno) return self::returnValue([], $errno);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 客户群群发详情
- * */
- public function ruleDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $ruleId = $request->input('rule_id');
- # 获取群发消息详情
- $errno = 0;
- $detail = ChatGroupMassMsgRuleService::ruleDetailNew($corpid, $ruleId, $errno);
- return self::returnValue($detail, $errno);
- }
- // 群发规则禁用启用
- public function updateStatus(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- 'status' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $status = $request->input('status');
- $ruleId = $request->input('rule_id');
- $errno = ChatGroupMassMsgRuleService::updateRuleStatus($corpid, $ruleId, $status);
- return self::returnValue([], $errno);
- }
- // 给群发消息未发送成员发送消息提醒
- public function noticeUser(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $ruleId = $request->input('rule_id');
- $errno = ChatGroupMassMsgRuleService::noticeUser($corpid, $ruleId);
- return self::returnValue([], $errno);
- }
- /**
- * 客户群群发详情
- * */
- public function chatGroupReceiveDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $ruleId = $request->input('rule_id');
- $chatGroupName = $request->input('chat_group_name');
- $senderList = $request->input('sender_list');
- $status = $request->input('status');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- if($pageSize==500) $pageSize = 10000;
- $errno = 0;
- list($list, $count) = ChatGroupMassMsgRuleService::chatGroupReceiveDetailNew(
- $ruleId, $chatGroupName, $senderList, $status, $errno, $page, $pageSize
- );
- if($errno){
- return self::returnValue([], $errno);
- }
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- public function chatGroupOwnerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_name' => 'nullable|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userName = $request->input('user_name');
- $data = ChatGroupService::ownerList($corpid, $userName);
- return self::returnValue($data);
- }
- /**
- * 获取账号下各企微的群主列表
- * */
- public function ownerListOfCompany(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'user_name' => 'nullable|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $userName = $request->input('user_name');
- $sysGroupId = $request->input('sys_group_id');
- $data = ChatGroupService::ownerListOfCompany($userName, $sysGroupId);
- return self::returnValue($data);
- }
- /**
- * 检索框群列表
- * @param Request $request
- * @return array
- */
- public function chatGroupList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'start_time' => 'nullable|date_format:Y-m-d H:i:s',
- 'end_time' => 'nullable|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $keyword = $request->input('keyword');
- $startTime = $request->input('start_time');
- $endTime = $request->input('end_time');
- $owner = $request->input('owner');
- $isActive = $request->input('is_active', 0);
- $data = ChatGroupService::chatGroupList($corpid, $keyword, $startTime, $endTime, $owner, $isActive);
- return self::returnValue($data);
- }
- /**
- * 简单群主列表
- * @param Request $request
- * @return array
- */
- public function chatGroupOwnerIndex(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_name' => 'nullable|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userName = $request->input('user_name');
- $data = ChatGroupService::ownerIndex($corpid, $userName);
- return self::returnValue($data);
- }
- /**
- * 配置邀请入群规则
- * */
- public function setInviteRule(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'title' => 'required|string',
- 'invite_config' => 'required|string',
- 'is_for_all' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params = array();
- $ruleId = $request->input('rule_id');
- $params['admin_id'] = $request->input('admin_id', 1);
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['corpid'] = $request->input('corpid');
- $params['is_for_all'] = $request->input('is_for_all');// 是否通用于全部员工 0:否 1:是
- $params['users'] = $request->input('users');// 使用成员,当通用于全部员工是,该字段可为空
- $params['title'] = $request->input('title');
- $params['join_type'] = $request->input('join_type', 1);// 进群方式 1顺序进群 2随机进群
- $params['invite_config'] = $request->input('invite_config');// 渠道群管理
- $params['customer_filter'] = $request->input('customer_filter');// 客户筛选 0:全部客户 1:筛选客户
- $params['filter_type'] = $request->input('filter_type', 1);// 筛选用户方式 1客户添加N小时后拉群 2按指定添加起止时间筛选
- $params['add_time_st'] = $request->input('add_time_st');// 客户添加时间筛选的起始时间
- $params['add_time_et'] = $request->input('add_time_et');// 客户添加时间筛选的截止时间
- $params['add_time_later'] = $request->input('add_time_later');// 添加客服多久后拉群,单位:小时
- $params['invite_type'] = $request->input('invite_type');// 邀请类型。1直接邀请 2定时邀请
- $params['invite_time'] = $request->input('invite_time');// 邀请入群时间点
- $params['owner_type'] = $request->input('owner_type');// 群主类型 1.本群主群聊 2.指定其他群主群聊
- $params['announcement'] = $request->input('announcement');// 群公告
- $params['pay_status'] = $request->input('pay_status');// 是否付费
- $params['pay_num_min'] = $request->input('pay_num_min');// 最小付费次数
- $params['pay_num_max'] = $request->input('pay_num_max');// 最大付费次数
- // 标签筛选方式 0未设置标签筛选 1所选标签满足其一 2所选标签全部满足 3无任何标签
- $params['tag_screen_type'] = $request->input('tag_screen_type', 0);
- $params['tag_list'] = $request->input('tag_list');
- $params['gender'] = $request->input('gender');// 客户性别 0未知 1男性 2女性
- $params['upper_limit'] = $request->input('upper_limit');// 建群数量上限
- $params['continuously_attract_groups'] = $request->input('continuously_attract_groups', 0);// 是否为持续拉取客户入群任务 1是 0否
- $params['supplementary_invite_time'] = $request->input('supplementary_invite_time');// 补充邀请入群时间点
- $params['supplementary_invite'] = $request->input('supplementary_invite', 0); // 补充邀请入群开启状态 1开启 0关闭
- $params['supplementary_invite_cycle'] = $request->input('supplementary_invite_cycle', 1);// 补充邀请入群时间间隔(单位天)
- # 设置新用户邀请入群规则
- $errNo = ChatGroupService::setInviteRule($ruleId, $params);
- Log::logInfo('配置邀请入群规则', [
- 'rule_id' => $ruleId, 'params' => $params, 'errno' => $errNo
- ], 'setInviteRule');
- return self::returnValue([], $errNo);
- }
- /**
- * 邀请入群规则列表
- * */
- public function inviteRuleList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $userId = $request->input('user_id');
- $status = $request->input('status');
- $keyword = $request->input('keyword');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- # 获取列表
- list($list, $count) = ChatGroupService::getInviteRuleList($corpid, $userId, $sysGroupId, $keyword, $status, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 邀请入群规则详情
- * */
- public function inviteRuleDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- # 获取规则详情
- $detail = ChatGroupService::inviteRuleDetail($ruleId, $sysGroupId);
- return self::returnValue($detail);
- }
- /**
- * 删除邀请入群规则
- * */
- public function inviteRuleDel(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- # 删除规则
- $errno = ChatGroupService::inviteRuleDel($ruleId, $sysGroupId, $adminId);
- return self::returnValue([], $errno);
- }
- /**
- * 修改邀请入群规则状态
- * */
- public function inviteRuleStatusChange(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- 'status' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $status = $request->input('status');
- $ruleId = $request->input('rule_id');
- $errno = ChatGroupService::updateRuleStatus($ruleId, $adminId, $status, $sysGroupId);
- return self::returnValue([], $errno);
- }
- public function resetSupplementaryInviteTime(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- $errno = ChatGroupService::resetSupplementaryInviteTime($ruleId, $adminId, $sysGroupId);
- return self::returnValue([], $errno);
- }
- /**
- * 客户群数据--按客户群统计
- * */
- public function chatGroupStatistic(Request $request)
- {
- $sysGroupId = $request->input('sys_group_id');
- $keyword = $request->input('keyword');
- $corpid = $request->input('corpid');
- $owner = $request->input('owner');
- $minMember = $request->input('min_member');
- $maxMember = $request->input('max_member');
- $ownerList = $request->input('owner_list');
- $createTimeSt = $request->input('create_time_st');
- $createTimeEt = $request->input('create_time_et');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- # 数据统计
- list($list, $count) = ChatGroupService::chatGroupStatistic(
- $sysGroupId, $owner, $ownerList, $keyword, $corpid, $createTimeSt, $createTimeEt,
- $minMember, $maxMember, $page, $pageSize
- );
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 客户群数据概览--按客户群统计
- * */
- public function chatGroupCondition(Request $request)
- {
- $sysGroupId = $request->input('sys_group_id');
- $owner = $request->input('owner');
- $ownerList = $request->input('owner_list');
- $corpid = $request->input('corpid');
- $createTimeSt = $request->input('create_time_st');
- $createTimeEt = $request->input('create_time_et');
- $minMember = $request->input('min_member');
- $maxMember = $request->input('max_member');
- # 数据汇总
- $data = ChatGroupService::chatGroupCondition(
- $sysGroupId, $owner, $ownerList, $corpid, $createTimeSt, $createTimeEt, $minMember, $maxMember
- );
- return self::returnValue($data);
- }
- public static function syncCorpChatGroup(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- list($res, $code) = ChatGroupService::syncCorpChatGroup($corpid);
- return self::returnValue($res, $code);
- }
- # 接收客户端上传的待创建群聊信息
- public function receiveCreateChatGroupData(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'corpid' => 'required|string',
- 'user_name' => 'required|string',
- 'group_list' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $corpid = $request->input('corpid');
- $userName = $request->input('user_name');
- $groupList = $request->input('group_list');
- list($response, $errcode) = ChatGroupService::receiveCreateChatGroupData($deviceId, $corpid, $userName, $groupList);
- Log::logInfo('接收待创建群聊任务', [
- 'device_id' => $deviceId,
- 'corpid' => $corpid,
- 'user_name' => $userName,
- 'group_list' => $groupList,
- 'response' => $response
- ], 'receiveCreateChatGroupData');
- return self::returnValue($response, $errcode);
- }
- public function getCreateGroupTask(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $taskList = ChatGroupService::getCreateGroupTask($deviceId);
- Log::logInfo('创建群聊任务返回', [
- 'device_id' => $deviceId,
- 'response' => $taskList
- ], 'getCreateGroupTask');
- return self::returnValue($taskList);
- }
- # 添加客户群欢迎语素材
- public function setWelcomeTemplate(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'name' => 'required|string',
- 'content' => ['required_without:attachments', 'nullable'],
- 'attachments' => ['required_without:content', 'nullable'],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params = array();
- $params['corpid'] = $request->input('corpid');
- $params['admin_id'] = $request->input('admin_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['template_id'] = $request->input('template_id');
- $params['name'] = $request->input('name');
- $params['content'] = $request->input('content');
- $params['attachments'] = $request->input('attachments');
- $error = 0;
- ChatGroupService::setWelcomeTemplate($params, $error);
- return self::returnValue('', $error);
- }
- # 客户群欢迎语素材列表
- public function welcomeTemplateList(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $keyword = $request->input('keyword');
- $creatorId = $request->input('creator_id');
- $page = $request->input('page');
- $pageSize = $request->input('page_size');
- list($list, $count) = ChatGroupService::welcomeTemplateList($corpid, $sysGroupId, $keyword, $creatorId, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- # 客户群欢迎语素材详情
- public function welcomeTemplateDetail(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'template_id' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $templateId = $request->input('template_id');
- $data = ChatGroupService::welcomeTemplateDetail($sysGroupId, $corpid, $templateId);
- return self::returnValue($data);
- }
- # 删除客户群欢迎语素材
- public function delWelcomeTemplate(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'template_id' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $templateId = $request->input('template_id');
- $errcode = 0;
- ChatGroupService::delWelcomeTemplate($sysGroupId, $corpid, $templateId, $errcode);
- return self::returnValue('', $errcode);
- }
- # 转发客服列表
- public function forwardMemberList(Request $request) {
- $sysGroupId = $request->input('sys_group_id');
- $keyword = $request->input('keyword');
- $list = AndroidToolService::getForwardMemberList($sysGroupId, $keyword);
- return self::returnValue($list);
- }
- # 配置创建转发群聊规则
- public function setForwardChatGroupCreateRule(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'title' => 'required|string',
- 'template_group_name' => 'required|string',
- 'group_num' => 'required',
- 'create_type' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params = array();
- $ruleId = $request->input('rule_id');
- $params['admin_id'] = $request->input('admin_id', 1);
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['corpid'] = $request->input('corpid');
- $params['is_for_all'] = $request->input('is_for_all');
- $params['users'] = $request->input('users');// 使用成员,当通用于全部员工是,该字段可为空
- $params['title'] = $request->input('title');// 规则名称
- $params['create_type'] = $request->input('create_type');// 邀请类型。1直接邀请 2定时邀请
- $params['do_time'] = $request->input('do_time');// 邀请入群时间点
- $params['template_group_name'] = $request->input('template_group_name');// 模板群聊名称
- $params['group_num'] = $request->input('group_num', 1);// 创建群聊数
- $params['forward_users'] = $request->input('forward_users');// 转发客服(系统自增ID列表)
- # 设置新用户邀请入群规则
- $errNo = ChatGroupService::setForwardChatGroupCreateRule($ruleId, $params);
- Log::logInfo('配置转发消息客服入群规则', [
- 'rule_id' => $ruleId, 'params' => $params, 'errno' => $errNo
- ], 'setForwardChatGroupCreateRule');
- return self::returnValue([], $errNo);
- }
- # 转发群聊创建规则列表
- public function forwardChatGroupCreateRuleList(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $userId = $request->input('user_id');
- $status = $request->input('status');
- $keyword = $request->input('keyword');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- # 获取列表
- list($list, $count) = ChatGroupService::forwardChatGroupCreateRuleList($corpid, $userId, $sysGroupId, $keyword, $status, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- # 转发群聊创建规则详情
- public function forwardChatGroupCreateRuleDetail(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- # 获取规则详情
- $detail = ChatGroupService::forwardChatGroupCreateRuleDetail($ruleId);
- return self::returnValue($detail);
- }
- # 转发群聊创建规则状态调整
- public function forwardChatGroupCreateRuleChangeStatus(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'rule_id' => 'required|integer',
- 'status' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $status = $request->input('status');
- $ruleId = $request->input('rule_id');
- $errno = ChatGroupService::forwardChatGroupCreateRuleChangeStatus($ruleId, $adminId, $status, $sysGroupId);
- return self::returnValue([], $errno);
- }
- # 转发群里哦啊创建规则删除
- public function forwardChatGroupCreateRuleDelete(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'rule_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- # 删除规则
- $errno = ChatGroupService::forwardChatGroupCreateRuleDelete($ruleId, $sysGroupId, $adminId);
- return self::returnValue([], $errno);
- }
- }
|