all(), [ 'corpid' => 'required|string', 'chat_id_list' => 'required|string', 'name' => 'required|string', 'group_id' => 'nullable|int', 'join_type' => ['required', Rule::in([1, 2])], 'is_limit' => ['required', Rule::in([0, 1])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params = []; $params['corpid'] = $request->input('corpid'); $params['admin_id'] = $request->input('admin_id'); $params['name'] = $request->input('name'); $params['group_id'] = $request->input('group_id'); $params['join_type'] = $request->input('join_type', 2); // 进群方式 1:顺序进群 2:随机进群 $params['is_limit'] = $request->input('is_limit'); // 是否设置加群上限 0:否 1:是 $params['user_list'] = $request->input('user_list'); // 生效成员。当客户点击客服时,会引导客户随机添加一名客服成员的企业微信 $params['leading_words'] = $request->input('leading_words'); // 引导语 $params['chat_id_list'] = json_decode($request->input('chat_id_list'), true); // 客户群ID列表 # 设置群活码规则 $errno = GroupChatJoinWayService::setRule($params); return self::returnValue([], $errno); } /** * 群活码编辑 * */ public function editRule(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'config_id' => 'required|string', 'chat_id_list' => 'required|string', 'name' => 'required|string', 'rule_id' => 'required|int', 'group_id' => 'nullable|int', 'join_type' => ['required', Rule::in([1, 2])], 'is_limit' => ['required', Rule::in([0, 1])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params = []; $ruleId = $request->input('rule_id'); $configId = $request->input('config_id'); $params['corpid'] = $request->input('corpid'); $params['admin_id'] = $request->input('admin_id'); $params['name'] = $request->input('name'); $params['group_id'] = $request->input('group_id'); $params['join_type'] = $request->input('join_type', 2); // 进群方式 1:顺序进群 2:随机进群 $params['is_limit'] = $request->input('is_limit'); // 是否设置加群上限 0:否 1:是 $params['user_list'] = $request->input('user_list'); // 生效成员。当客户点击客服时,会引导客户随机添加一名客服成员的企业微信 $params['leading_words'] = $request->input('leading_words'); // 引导语 $params['chat_id_list'] = json_decode($request->input('chat_id_list'), true); // 客户群ID列表 # 设置群活码规则 $errno = GroupChatJoinWayService::editRule($params, $ruleId, $configId); return self::returnValue([], $errno); } /** * 群活码规则列表 * */ public function ruleList(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $groupId = $request->input('group_id'); $name = $request->input('name'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); list($data, $total) = GroupChatJoinWayService::ruleList($corpid, $groupId, $name, $page, $pageSize); return self::returnPageValue($data, $total, $pageSize, $page); } /** * 群活码详情 * */ public function ruleDetail(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 获取群活码规则详情 $errno = 0; $detail = GroupChatJoinWayService::ruleDetail($corpid, $ruleId, $errno); return self::returnValue($detail, $errno); } /** * 群活码禁用 * */ public function delQrcode(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 群活码禁用 $errno = GroupChatJoinWayService::delQrcode($corpid, $ruleId); return self::returnValue([], $errno); } /** * 群活码总概数据 * */ public function condition(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 获取群活码总概数据 $data = GroupChatJoinWayService::getCondition($corpid, $ruleId); return self::returnValue($data); } /** * 群活码每日数据分析 * */ public function dailyReport(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', 'start_date' => 'required|date_format:Y-m-d', 'end_date' => 'required|date_format:Y-m-d', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $startDate = $request->input('start_date'); $endDate = $request->input('end_date'); # 群活码每日数据分析 $data = GroupChatJoinWayService::getDailyReport($corpid, $ruleId, $startDate, $endDate); return self::returnValue($data); } /** * 群活码扫码进群客户列表 * */ public function customerList(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $keyword = $request->input('keyword'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取群活码扫码进群客户列表 list($list, $count) = GroupChatJoinWayService::getMemberList($corpid, $ruleId, $keyword, $page, $pageSize); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 群活码配置群的数据分析 * */ public function analysis(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 群活码配置群的数据分析 $data = GroupChatJoinWayService::chatGroupAnalysis($corpid, $ruleId); return self::returnValue($data); } /** * 扫码数据上报 * */ public function scan(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 增加扫码次数 $errno = GroupChatJoinWayService::scanNumIncr($corpid, $ruleId); return self::returnValue([], $errno); } /** * 创建临时渠道码 * */ public function contactQrcode(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 生成临时渠道活码 $errno = 0; $data = GroupChatJoinWayService::createTempContactQrcode($corpid, $ruleId, $errno); return self::returnValue($data, $errno); } /** * 获取群组下的群活码规则数 * */ public function chatGroupCountOfGroup(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'group_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $groupId = $request->input('group_id'); $count = GroupChatJoinWayService::chatGroupCountOfGroup($corpid, $groupId); return self::returnValue(['count' => $count]); } /** * 群活码二维码 * */ public function detail(Request $request) { $validator = \Validator::make($request->all(), [ 'corpid' => 'required|string', 'rule_id' => 'required|int', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 获取群活码规则详情 $errno = 0; $qrcode = GroupChatJoinWayService::qrcodeDetail($corpid, $ruleId, $errno); return self::returnValue(['qrcode' => $qrcode], $errno); } }