all(),[ 'corpid' => 'required|string', 'name' => 'required|string', 'send_type' => ['required', Rule::in([1, 2])], 'send_time' => 'required|date_format:Y-m-d H:i:s', 'chat_type' => ['nullable', Rule::in([1, 2])], 'content' => ['required_without:attachments', 'nullable'], 'attachments' => ['required_without:content', 'nullable'], 'add_time_start' => 'nullable|date_format:Y-m-d H:i:s', 'add_time_end' => 'nullable|date_format:Y-m-d H:i:s', '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['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['chat_type'] = $request->input('chat_type', 1); // 1:single,表示发送给客户 2:group表示发送给客户群 $params['customer_filter'] = $request->input('customer_filter'); // 0:全部客户 1:筛选客户 $params['content'] = $request->input('content'); $params['attachments'] = $request->input('attachments'); $params['gender'] = $request->input('gender'); // 客户性别 0未知 1男性 2女性 $params['is_customize_time'] = $request->input('is_customize_time', 0); // 是否自定义了客户添加时间 $params['timeline'] = $request->input('timeline', 0); // 时间线 单位:小时 $params['add_time_start'] = $request->input('add_time_start'); $params['add_time_end'] = $request->input('add_time_end'); // 标签筛选方式 0未设置标签筛选 1所选标签满足其一 2所选标签全部满足 3无任何标签 $params['tag_screen_type'] = $request->input('tag_screen_type', 0); $params['tag_list'] = $request->input('tag_list'); $params['exclude_tag_list'] = $request->input('exclude_tag_list'); $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'); // 最大付费次数 $params['operate_type'] = $request->input('operate_type', 1);# 运营类型 1单主体 2多主体 $params['add_days_later'] = $request->input('add_days_later'); // 添加客服x天之后(非只能推送客户) $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 = MassMsgRuleService::setRule($ruleId, $params); return self::returnValue([], $errNo); } public function getLicenseExpirationUserList(Request $request) { $params['corpid'] = $request->input('corpid'); $params['senders'] = $request->input('senders'); // 群发账号,为空代表全部群发账号 $params['operator_group_id'] = $request->input('operator_group_id');// 运营组ID $params['multiple_senders'] = $request->input('multiple_senders'); $params['is_operation'] = $request->input('is_operation'); $params['operate_type'] = $request->input('operate_type', 1); if(1 == $params['operate_type']){ $userList = MassMsgRuleService::getLicenseExpirationUserList($params); $userList = [$userList]; } else { $userList = MassMsgRuleService::getMultipleCorpLicenseExpirationUserList($params); } return self::returnValue($userList); } /** * 查询满足对应条件的外部联系人数量 * */ public function customerMatchCount(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'add_time_start' => 'nullable|date_format:Y-m-d H:i:s', 'add_time_end' => 'nullable|date_format:Y-m-d H:i:s', '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(); $params['corpid'] = $request->input('corpid'); $params['senders'] = $request->input('senders'); // 群发账号,为空代表全部群发账号 $params['customer_filter'] = $request->input('customer_filter'); // 0:全部客户 1:筛选客户 $params['gender'] = $request->input('gender'); // 客户性别 0未知 1男性 2女性 $params['is_customize_time'] = $request->input('is_customize_time', 1); // 是否自定义了客户添加时间 $params['timeline'] = $request->input('timeline', 0); // 时间线 单位:小时 $params['add_time_start'] = $request->input('add_time_start'); $params['add_time_end'] = $request->input('add_time_end'); $params['send_time'] = $request->input('send_time'); $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'); // 是否付费 $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); $params['add_days_later'] = $request->input('add_days_later'); $params['operator_group_id'] = $request->input('operator_group_id');// 运营组ID $params['multiple_senders'] = $request->input('multiple_senders'); $params['is_operation'] = $request->input('is_operation'); $total = 0; if(1 == $params['operate_type']){ $errNo = MassMsgRuleService::getCustomerMatchCount($params, $total); } else { $errNo = MassMsgRuleService::getMultipleCorpCustomerMatchCount($params, $total); } return self::returnValue(['total' => $total], $errNo); } /* * 群发消息列表 * */ 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'); $keyword = $request->input('keyword'); $sendTimeStart = $request->input('send_time_start'); $sendTimeEnd = $request->input('send_time_end'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); $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) = MassMsgRuleService::ruleList( $corpid, $creatorId, $keyword, $sendTimeStart, $sendTimeEnd, $createTimeStart,$createTimeEnd,$sortColumn,$sortMethod, $page, $pageSize, $errno ); 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 = MassMsgRuleService::ruleDetail($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 = MassMsgRuleService::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 = MassMsgRuleService::noticeUser($corpid, $ruleId); return self::returnValue([], $errno); } /* * 群发消息数据概览 * @param Request $request * @return array */ public function overview(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'); $res = MassMsgRuleService::overview($corpid, $ruleId); return self::returnValue( $res , 0 ); } /* * 群发消息发送成员名单 * @param Request $request * @return array */ public function sender_list(Request $request){ $support_type = ['all','sent','unsent','fail']; //支持的查询类型 $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'type' => Rule::in($support_type) ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $type = $request->input("type",$support_type[0]); $page = $request->input("page",1); $page_size = $request->input("page_size",20); $keyword = $request->input("keyword"); list($total,$list) = MassMsgRuleService::sender_list($corpid, $ruleId,$type,$keyword,$page,$page_size); return self::returnPageValue($list,$total,$page_size,$page); } /* * 群发消息发送成员名单 - 导出 * @param Request $request * @return array */ public function sender_list_export(Request $request){ $support_type = ['all','sent','unsent','fail']; //支持的查询类型 $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'type' => Rule::in($support_type) ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $type = $request->input("type",$support_type[0]); $keyword = $request->input("keyword"); MassMsgRuleService::sender_list_export($corpid, $ruleId,$type,$keyword); } /* * 获取群发详情-客户列表 * @param Request $request * @return array */ public function massSendCustList(Request $request) { $validator = \Validator::make($request->all(),[ 'rule_id' => 'required|int', 'sender' => 'nullable|string', 'name' => 'nullable|string', 'type' => 'nullable|int|in:0,1,2,3,4' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $rule_id = $request->input('rule_id'); $sender = $request->input('sender'); $name = $request->input('name'); $type = $request->input('type'); $senderCorpid = $request->input('sender_corpid'); $page = $request->input('page', 1); $pagesize = (int)$request->input('page_size', 20); list($data, $total) = MassMsgRuleService::massSendCustList($rule_id, $sender, $name, $type, $page, $pagesize, $senderCorpid); 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', 'sender' => 'nullable|string', 'name' => 'nullable|string', 'type' => 'nullable|int|in:0,1,2,3,4' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $rule_id = $request->input('rule_id'); $sender = $request->input('sender'); $name = $request->input('name'); $type = $request->input('type'); $senderCorpid = $request->input('sender_corpid'); MassMsgRuleService::massSendCustListExport($rule_id, $sender, $name, $type, $senderCorpid); } /** * 安卓客服端获取待确认群发消息列表 * */ public function senderConfirmList(Request $request) { $validator = \Validator::make($request->all(),[ 'device_id' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $deviceId = $request->input('device_id'); # 获取待确认的群发消息 $msgList = MassMsgService::senderConfirmList($deviceId); return self::returnValue(['list' => $msgList]); } public function sendNoticeList(Request $request) { $validator = \Validator::make($request->all(),[ 'start_date' => 'nullable|date', 'end_date' => 'nullable|date' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['sys_group_id'] = $request->input('sys_group_id'); $params['start_date'] = $request->input('start_date'); $params['end_date'] = $request->input('end_date'); $params['corp_id'] = $request->input('corp_id'); $params['user_name'] = $request->input('user_name'); $params['send_status'] = $request->input('send_status'); $params['msg_type'] = $request->input('msg_type'); $page = $request->input('page', 1); $pageSize = $request->input('page_size'); list($data, $count) = MassMsgService::sendNoticeList($params, $page, $pageSize); return self::returnPageValue($data, $count, $pageSize, $page); } public function sendNoticeListNew(Request $request) { $validator = \Validator::make($request->all(),[ 'start_date' => 'nullable|date', 'end_date' => 'nullable|date', 'msg_type' => 'required|in:1,2,3,4' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params['sys_group_id'] = $request->input('sys_group_id'); $params['start_date'] = $request->input('start_date'); $params['end_date'] = $request->input('end_date'); $params['corp_id'] = $request->input('corp_id'); $params['user_name'] = $request->input('user_name'); $params['msg_type'] = $request->input('msg_type'); $page = $request->input('page', 1); $pageSize = $request->input('page_size'); list($data, $count) = MassMsgService::sendNoticeListNew($params, $page, $pageSize); return self::returnPageValue($data, $count, $pageSize, $page); } }