all(),[ 'corpid' => 'required|string', 'group_name' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['group_name'] = $request->input('group_name'); $params['sys_group_id'] = $request->input('sys_group_id'); list($res, $code) = ChatMenuService::createChatMenuGroup($params); return self::returnValue($res, $code); } public function chatMenuGroupList(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'sys_group_id' => 'required|int', 'keyword' => 'nullable|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['keyword'] = $request->input('keyword'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['page'] = $request->input('page', 1); $params['page_size'] = $request->input('page_size', 20); list($data, $count) = ChatMenuService::chatMenuGroupList($params); return self::returnPageValue($data, $count, $params['page_size'], $params['page']); } public function updateChatMenuGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'group_name' => 'required|string', 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['group_name'] = $request->input('group_name'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['group_id'] = $request->input('group_id'); list($res, $code) = ChatMenuService::updateChatMenuGroup($params); return self::returnValue($res, $code); } public function deleteChatMenuGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', 'type' => 'required|in:1,2' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['group_id'] = $request->input('group_id'); $params['type'] = $request->input('type', 1); list($res, $code) = ChatMenuService::deleteChatMenuGroup($params); return self::returnValue($res, $code); } public function updateChatMenuGroupSortOrder(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'operate_group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['operate_group_id'] = $request->input('operate_group_id'); $params['front_group_id'] = $request->input('front_group_id'); $params['behind_group_id'] = $request->input('behind_group_id'); $params['sys_group_id'] = $request->input('sys_group_id'); list($res, $code) = ChatMenuService::updateChatMenuGroupSortOrder($params); return self::returnValue($res, $code); } public function createChatMenuRule(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'title' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['group_id'] = $request->input('group_id'); $params['title'] = $request->input('title'); $params['corpid'] = $request->input('corpid'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['msg_data_list'] = $request->input('msg_data_list'); list($res, $code) = ChatMenuService::createChatMenuRule($params); return self::returnValue($res, $code); } public function chatMenuRuleList(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['title'] = $request->input('title'); $params['page'] = $request->input('page', 1); $params['page_size'] = $request->input('page_size', 20); $params['group_id'] = $request->input('group_id'); list($data, $count) = ChatMenuService::chatMenuRuleList($params); return self::returnPageValue($data, $count, $params['page_size'], $params['page']); } public function chatMenuRuleDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['rule_id'] = $request->input('rule_id'); list($data, $code) = ChatMenuService::chatMenuRuleDetail($params); return self::returnValue($data, $code); } public function updateChatMenuRule(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'title' => 'required|string', 'rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['group_id'] = $request->input('group_id'); $params['title'] = $request->input('title'); $params['corpid'] = $request->input('corpid'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['msg_data_list'] = $request->input('msg_data_list'); $params['rule_id'] = $request->input('rule_id'); list($res, $code) = ChatMenuService::updateChatMenuRule($params); return self::returnValue($res, $code); } public function deleteChatMenuRule(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['rule_id'] = $request->input('rule_id'); list($res, $code) = ChatMenuService::deleteChatMenuRule($params); return self::returnValue($res, $code); } public function updateChatMenuRuleSortOrder(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'operate_rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['operate_rule_id'] = $request->input('operate_rule_id'); $params['front_rule_id'] = $request->input('front_rule_id'); $params['behind_rule_id'] = $request->input('behind_rule_id'); $params['sys_group_id'] = $request->input('sys_group_id'); list($res, $code) = ChatMenuService::updateChatMenuRuleSortOrder($params); return self::returnValue($res, $code); } /** * 快捷话术分组信息 * */ public function chatMenuGroupListForH5(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'keyword' => 'nullable|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['keyword'] = $request->input('keyword'); $params['page'] = $request->input('page', 1); $params['page_size'] = $request->input('page_size', 20); list($data, $count) = ChatMenuService::chatMenuGroupList($params); return self::returnPageValue($data, $count, $params['page_size'], $params['page']); } /** * 快捷话术信息列表 * */ public function chatMenuListForH5(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['title'] = $request->input('title'); $params['group_id'] = $request->input('group_id'); $params['page'] = $request->input('page', 1); $params['page_size'] = $request->input('page_size', 20); list($data, $count) = ChatMenuService::chatMenuRuleListForH5($params); return self::returnPageValue($data, $count, $params['page_size'], $params['page']); } /** * 数据上报 * */ public function behaviorReport(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'user_id' => 'required|string', 'rule_id' => 'required|int', 'msg_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['user_id'] = $request->input('user_id'); $params['external_userid'] = $request->input('external_userid'); $params['rule_id'] = $request->input('rule_id'); $params['msg_id'] = $request->input('msg_id'); # 数据上报 $error = ChatMenuService::behaviorReport($params); return self::returnValue([], $error); } /** * 将消息处理成可发送的数据结构 * */ public function chatMessage(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'msg_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['corpid'] = $request->input('corpid'); $params['rule_id'] = $request->input('rule_id'); $params['msg_id'] = $request->input('msg_id'); $params['type'] = $request->input('type', 1); // 1快捷回复 2个人SOP # 消息处理成可发送的数据结构 $errno = 0; $msgInfo = ChatMenuService::getChatMessage($params, $errno); if($errno) return self::returnValue([], $errno); return self::returnValue(['data' => $msgInfo]); } /** * 获取外部联系人信息 * */ public function getCustomerInfo(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'external_userid' => 'required|string', 'user_id' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $externalUserid = $request->input('external_userid'); $userid = $request->input('user_id'); # 获取外部联系人信息 $userInfo = CustomerService::getCustomerInfo($corpid, $externalUserid, $userid); return self::returnValue(['user_info' => $userInfo]); } }