all(), [ 'corpid' => 'required|string', 'name' => 'required|string', 'send_conf' => 'required|string', 'content' => ['required_without:attachments', 'nullable'], 'attachments' => ['required_without:content', 'nullable'], 'tag_screen_type' => ['nullable', Rule::in([0, 1, 2, 3])], 'customer_filter' => ['nullable', Rule::in([0, 1])], 'pay_status' => ['nullable', Rule::in([0, 1])], 'pay_num_min' => 'nullable|int', 'pay_num_max' => 'nullable|int', ]); 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['group_id'] = $request->input('group_id', 0); $params['name'] = $request->input('name'); $params['send_conf'] = $request->input('send_conf'); // 发送时间配置 $params['is_all'] = $request->input('is_all', 0); // 是否应用于全部员工 0否 1是 $params['senders'] = $request->input('senders'); // 群发账号集合 $params['content'] = $request->input('content'); $params['attachments'] = $request->input('attachments'); $params['gender'] = $request->input('gender', 3); // 客户性别 0未知 1男性 2女性 3全部 $params['tag_screen_type'] = $request->input('tag_screen_type', 0); // 标签筛选方式 0未设置标签筛选 1所选标签满足其一 2所选标签全部满足 3无任何标签 $params['tag_list'] = $request->input('tag_list'); $params['exclude_tag_list'] = $request->input('exclude_tag_list'); // 付费情况 $params['pay_status'] = $request->input('pay_status'); // 是否付费 0:未付费 1:付费 $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数 $params['pay_num_max'] = $request->input('pay_num_max'); // 最大付费次数 $params['operate_type'] = $request->input('operate_type', 1);# 运营类型 1单主体 2多主体 $params['operator_group_id'] = $request->input('operator_group_id');// 运营组ID $params['multiple_senders'] = $request->input('multiple_senders'); $params['is_operation'] = $request->input('is_operation'); # 智能群发规则设置 $errNo = PeriodMassMsgService::setRule($ruleId, $params); return self::returnValue([], $errNo); } /** * 设置智能群发模板 * */ public function setTemplate(Request $request) { $validator = \Validator::make($request->all(), [ 'title' => 'required|string', 'send_conf' => 'required|string', 'content' => ['required_without:attachments', 'nullable'], 'attachments' => ['required_without:content', 'nullable'], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params = array(); $templateId = $request->input('template_id'); $params['admin_id'] = $request->input('admin_id'); $params['group_id'] = $request->input('group_id'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['title'] = $request->input('title'); $params['send_conf'] = $request->input('send_conf'); // 发送时间配置 $params['content'] = $request->input('content'); $params['attachments'] = $request->input('attachments'); # 智能群发模板配置 $errNo = PeriodMassMsgService::setTemplate($templateId, $params); return self::returnValue([], $errNo); } /** * 智能群发规则列表 * */ public function ruleLists(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', '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); } $groupId = $request->input('group_id', 0); $keyword = $request->input('keyword'); $corpid = $request->input('corpid'); $creatorId = $request->input('creator_id'); $createTimeStart = $request->input('create_time_start'); $createTimeEnd = $request->input('create_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取群发规则列表 $errno = 0; list($list, $count) = PeriodMassMsgService::ruleList( $groupId, $keyword, $corpid, $creatorId, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno ); # 获取分组名称 $groupName = PeriodMassMsgGroup::where('id', $groupId)->value('title'); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list, $count, $pageSize, $page, ['group_name' => $groupName ? $groupName : '未分组']); } /** * 智能群发模板列表 * */ public function templateList(Request $request) { $validator = \Validator::make($request->all(),[ '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); } $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $groupId = $request->input('group_id', 0); $title = $request->input('title'); $status = $request->input('status'); $createTimeStart = $request->input('create_time_start'); $createTimeEnd = $request->input('create_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取分组名称 $groupName = PeriodTempGroup::where('id', $groupId)->value('title'); # 获取智能群发模板列表 list($list, $count) = PeriodMassMsgService::templateList( $adminId, $sysGroupId, $groupId, $title, $createTimeStart,$createTimeEnd, $status, $page, $pageSize ); return self::returnPageValue($list, $count, $pageSize, $page, ['group_name' => $groupName ? $groupName : '未分组']); } /** * 智能群发规则详情 * */ 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 = PeriodMassMsgService::ruleDetail($corpid, $ruleId, $errno); return self::returnValue($detail, $errno); } /** * 智能群发模板详情 * */ public function templateDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'template_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $templateId = $request->input('template_id'); $sysGroupId = $request->input('sys_group_id'); # 获取智能群发规则详情 $errno = 0; $detail = PeriodMassMsgService::templateDetail($templateId, $sysGroupId, $adminId, $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); } $adminId = $request->input('admin_id'); $corpid = $request->input('corpid'); $status = $request->input('status'); $ruleId = $request->input('rule_id'); $errno = PeriodMassMsgService::updateRuleStatus($corpid, $ruleId, $status, $adminId); return self::returnValue([], $errno); } /** * 智能群发模板状态修改 * */ public function changeStatus(Request $request) { $validator = \Validator::make($request->all(),[ 'template_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'); $templateId = $request->input('template_id'); $errno = PeriodMassMsgService::templateChangeStatus($templateId, $adminId, $sysGroupId, $status); return self::returnValue([], $errno); } /** * 群发消息列表 * */ public function recordLists(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'send_time_start' => 'nullable|date_format:Y-m-d H:i:s', 'send_time_end' => 'nullable|date_format:Y-m-d H:i:s', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $sendTimeStart = $request->input('send_time_start'); $sendTimeEnd = $request->input('send_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); $sortColumn = $request->input('sort_column','send_time'); $sortMethod = $request->input('sort_method','desc'); # 获取群发规则列表 $errno = 0; list($list, $count) = PeriodMassMsgService::recordList( $corpid, $ruleId, $sendTimeStart, $sendTimeEnd, $sortColumn, $sortMethod, $page, $pageSize, $errno ); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list, $count, $pageSize, $page); } public function recordDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'send_num' => 'required|numeric', 'send_date' => 'required|date', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); # 获取群发消息详情 $errno = 0; $detail = PeriodMassMsgService::recordDetail($corpid, $ruleId, $sendNum, $sendDate, $errno); return self::returnValue($detail, $errno); } /** * 群发消息数据概览 * @param Request $request * @return array */ public function overview(Request $request){ $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'send_num' => 'required|numeric', 'send_date' => 'required|date' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); $res = PeriodMassMsgService::overview($corpid, $ruleId, $sendNum, $sendDate); return self::returnValue( $res , 0 ); } /** * 群发消息发送成员名单 * @param Request $request * @return array */ public function senderList(Request $request){ $support_type = ['all','sent','unsent','fail']; //支持的查询类型 $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'send_num' => 'required|numeric', 'send_date' => 'required|date', 'type' => Rule::in($support_type) ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); $type = $request->input("type",$support_type[0]); $page = $request->input("page",1); $pageSize = $request->input("page_size",20); $keyword = $request->input("keyword"); list($total,$list) = PeriodMassMsgService::senderList($corpid, $ruleId, $sendNum, $sendDate, $type, $keyword, $page, $pageSize); return self::returnPageValue($list,$total,$pageSize,$page); } /** * 群发消息发送成员名单 - 导出 * @param Request $request * @return array */ public function senderListExport(Request $request){ $support_type = ['all','sent','unsent','fail']; //支持的查询类型 $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'send_num' => 'required|numeric', 'send_date' => 'required|date', 'type' => Rule::in($support_type) ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); $type = $request->input("type",$support_type[0]); $keyword = $request->input("keyword"); PeriodMassMsgService::senderListExport($corpid, $ruleId, $sendNum, $sendDate, $type, $keyword); } /** * 获取群发详情-客户列表 * @param Request $request * @return array */ public function massSendCustList(Request $request) { $validator = \Validator::make($request->all(),[ 'rule_id' => 'required|int', 'send_num' => 'required|numeric', 'send_date' => 'required|date', 'sender' => 'nullable|string', 'name' => 'nullable|string', 'type' => 'nullable|int|in:0,1,2,3,4' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); $sender = $request->input('sender'); $name = $request->input('name'); $type = $request->input('type'); $page = $request->input('page', 1); $pageSize = (int)$request->input('page_size', 20); list($data, $total) = PeriodMassMsgService::massSendCustList($ruleId, $sendNum, $sendDate, $sender, $name, $type, $page, $pageSize); return self::returnPageValue($data, $total, $pageSize, $page); } /** * 获取群发详情-客户列表导出 * @param Request $request * @return array */ public function massSendCustListExport(Request $request) { $validator = \Validator::make($request->all(),[ 'rule_id' => 'required|int', 'send_num' => 'required|numeric', 'send_date' => 'required|date', 'sender' => 'nullable|string', 'name' => 'nullable|string', 'type' => 'nullable|int|in:0,1,2,3,4' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $ruleId = $request->input('rule_id'); $sendNum = $request->input('send_num'); $sendDate = $request->input('send_date'); $sender = $request->input('sender'); $name = $request->input('name'); $type = $request->input('type'); PeriodMassMsgService::massSendCustListExport($ruleId, $sendNum, $sendDate, $sender, $name, $type); } /** * 删除智能群发规则 * */ public function deleteRule(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 = PeriodMassMsgService::deleteRule($corpid, $ruleId); return self::returnValue([], $errno); } /** * 批量删除智能群发模板 * */ public function delTemplate(Request $request) { $validator = \Validator::make($request->all(),[ 'template_ids' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $templateIds = $request->input('template_ids'); $errno = PeriodMassMsgService::delTemplate($templateIds, $adminId); return self::returnValue([], $errno); } /** * 智能群发分组新建/编辑 * */ public function editGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'title' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $groupId = $request->input('group_id'); $operateType = $request->input('operate_type', 1); $isOperation = $request->input('is_operation', 0); $operatorGroupId = $request->input('operator_group_id'); $corpid = $request->input('corpid'); $isAll = $request->input('is_all', 0); $senders = $request->input('senders'); $multipleSenders = $request->input('multiple_senders'); $groupName = $request->input('title'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 创建/编辑 素材组 list($groupId, $errno) = PeriodMassMsgService::editGroup( $groupId, $groupName, $sysGroupId, $adminId, $operateType, $isOperation, $operatorGroupId, $corpid, $isAll, $senders, $multipleSenders ); return self::returnValue(['group_id' => $groupId], $errno); } /** * 智能群发分组新建/编辑 * */ public function editTempGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'title' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $groupId = $request->input('group_id'); $groupName = $request->input('title'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 创建/编辑 素材组 list($groupId, $errno) = PeriodMassMsgService::editTempGroup($groupId, $groupName, $sysGroupId, $adminId); return self::returnValue(['group_id' => $groupId], $errno); } /** * 分组禁用/启用 * */ public function changeGroupStatus(Request $request) { $validator = \Validator::make($request->all(),[ 'group_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'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::changeGroupStatus($groupId, $adminId, $sysGroupId, $status); return self::returnValue([], $errno); } /** * 模板分组禁用/启用 * */ public function changeTempGroupStatus(Request $request) { $validator = \Validator::make($request->all(),[ 'group_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'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::changeTempGroupStatus($groupId, $adminId, $sysGroupId, $status); return self::returnValue([], $errno); } /** * 分组删除 * */ public function delGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::delGroup($groupId, $adminId, $sysGroupId); return self::returnValue([], $errno); } /** * 模板分组删除 * */ public function delTempGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::delTempGroup($groupId, $adminId, $sysGroupId); return self::returnValue([], $errno); } /** * 智能推送分组列表 * */ public function groupList(Request $request) { $validator = \Validator::make($request->all(),[ '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); } $sysGroupId = $request->input('sys_group_id'); $creatorId = $request->input('creator_id'); $keyword = $request->input('keyword'); $status = $request->input('status'); $createTimeStart = $request->input('create_time_start'); $createTimeEnd = $request->input('create_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取群发规则列表 $errno = 0; list($list, $count) = PeriodMassMsgService::groupList( $sysGroupId, $creatorId, $status, $keyword, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno ); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 智能群发分组详情 * */ public function groupDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sysGroupId = $request->input('sys_group_id'); $groupId = $request->input('group_id'); $detail = PeriodMassMsgService::groupDetail($groupId, $sysGroupId); return self::returnValue($detail); } /** * 智能推送分组列表 * */ public function tempGroupList(Request $request) { $validator = \Validator::make($request->all(),[ '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); } $sysGroupId = $request->input('sys_group_id'); $creatorId = $request->input('creator_id'); $keyword = $request->input('keyword'); $status = $request->input('status'); $createTimeStart = $request->input('create_time_start'); $createTimeEnd = $request->input('create_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取群发规则列表 $errno = 0; list($list, $count) = PeriodMassMsgService::tempGroupList( $sysGroupId, $creatorId, $status, $keyword, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno ); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 批量移动分组 * */ public function changeGroupBatch(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', 'rule_ids' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $ruleIds = $request->input('rule_ids'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::changeGroupBatch($groupId, $sysGroupId, $adminId, $ruleIds); return self::returnValue([], $errno); } /** * 批量移动模板分组 * */ public function changeTempGroupBatch(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', 'rule_ids' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $ruleIds = $request->input('rule_ids'); $groupId = $request->input('group_id'); $errno = PeriodMassMsgService::changeTempGroupBatch($groupId, $sysGroupId, $adminId, $ruleIds); return self::returnValue([], $errno); } }