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'); $status = $request->input('status'); $data = DjUserService::userList($corpid, $userName, $status); return self::returnValue($data); } public function users(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'); $isActive = $request->input('is_active'); $userIds = $request->input('user_ids'); $departmentList = $request->input('department_list'); $appId = $request->input('app_id'); $accountId = $request->input('account_id'); $operatorId = $request->input('operator_id');// 运营人员ID $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); $expireDays = $request->input('expire_days'); list($data, $count, $yesterdayAdd, $yesterdayLoss, $customerCount) = DjUserService::users( $corpid, $userName, $userIds, $departmentList, $page, $pageSize, $isActive, $appId, $accountId, $operatorId, $expireDays ); $extra = ['user_count' => $count, 'user_add_yesterday' => $yesterdayAdd, 'user_loss_yesterday' => $yesterdayLoss , 'customer_count' => $customerCount]; return self::returnPageValue($data, $count, $pageSize, $page, $extra); } /** * 成员详情 * @param Request $request * @return array */ public function user_info(Request $request){ $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'user_id' => 'required' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $user_id = $request->input('user_id'); $res = DjUserService::user_info($corpid,$user_id); return self::returnValue($res); } /** * 成员会话统计 * @param Request $request * @return array */ public function conversation_report(Request $request){ $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'user_id' => 'required' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $user_id = $request->input('user_id'); $begin_date = $request->input('begin_date',date("Y-m-d",strtotime("-1days"))); $end_date = $request->input('end_date',date("Y-m-d",strtotime("-1days"))); $list = DjUserService::conversation_report($corpid, $user_id, $begin_date, $end_date); return self::returnValue(['list'=>$list]); } /** * 成员会话报表汇总 * @param Request $request * @return array */ public function conversation_report_total(Request $request){ $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'user_id' => 'required' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $user_id = $request->input('user_id'); $begin_date = $request->input('begin_date',date("Y-m-d",strtotime("-1days"))); $end_date = $request->input('end_date',date("Y-m-d",strtotime("-1days"))); $total = DjUserService::conversation_report_total($corpid, $user_id, $begin_date, $end_date); return self::returnValue(['total'=>$total]); } public function departments(Request $request) { $corpid = $request->input('corpid'); $data = DjUserService::departments($corpid); return self::returnValue($data); } public function bindUserAdqAccountId(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'user_id' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $userId = $request->input('user_id'); $accountId = $request->input('account_id'); $sysGroupId = $request->input('sys_group_id'); $appId = $request->input('app_id'); $operatorId = $request->input('operator_id'); list($res, $code) = DjUserService::bindUserAdqAccountId($corpid, $userId, $accountId, $sysGroupId, $appId , $operatorId); return self::returnValue($res, $code); } /** * 获取成员可分配许可数量 * */ public function licenseCount(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $count = LicenseService::getLicenseCount($corpid); return self::returnValue(['count' => $count]); } /** * 分配许可 * */ public function activeAccount(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'userid' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $userid = $request->input('userid'); $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $isSysAdmin = $request->input('is_system_admin'); # 分配许可 $errMsg = null; $errno = LicenseService::activeAccount($corpid, $userid, $adminId, $sysGroupId, $isSysAdmin, $errMsg); return self::returnValue([], $errno, $errMsg); } /** * 批量分配许可 * */ public function batchActiveAccount(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'userid_list' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $useridList = $request->input('userid_list'); $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $isSysAdmin = $request->input('is_system_admin'); # 分配许可 $errMsg = []; $success = $failed = 0; $errno = LicenseService::batchActiveAccount($corpid, $useridList, $adminId, $sysGroupId, $isSysAdmin, $errMsg, $success, $failed); if(!$errno) { return self::returnValue(['fail_list' => $errMsg, 'success' => $success, 'failed' => $failed]); } return self::returnValue([], $errno, $errMsg); } /** * 转移许可 * */ public function transfer(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required', 'handover_userid' => 'required', 'takeover_userid' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $handoverUserid = $request->input('handover_userid'); $takeoverUserid = $request->input('takeover_userid'); $adminId = $request->input('admin_id'); $sysGroupId = $request->input('sys_group_id'); $isSysAdmin = $request->input('is_system_admin'); # 分配许可 $errMsg = null; $errno = LicenseService::transfer($corpid, $handoverUserid, $takeoverUserid, $adminId, $sysGroupId, $isSysAdmin, $errMsg); return self::returnValue([], $errno, $errMsg); } public function updateUserStatus(Request $request) { $validator = \Validator::make($request->all(),[ 'corp_id' => 'required', 'user_id' => 'required', 'status' => 'required|in:1, 2, 3', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corp_id'); $userId = $request->input('user_id'); $status = $request->input('status'); $errcode = 0; $res = DjUserService::updateUserStatus($corpid, $userId, $status, $errcode); return self::returnValue($res, $errcode); } public function nearExpiredUserList(Request $request) { $validator = \Validator::make($request->all(),[ 'corp_id' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $sysGroupId = $request->input('sys_group_id'); if(!in_array($sysGroupId, [2, 3])) { $list = []; } else { $list = DjUserService::nearExpiredUserList($corpid); } return self::returnValue($list); } # 创建客服许可续期任务 public function createRenewalJob(Request $request) { $validator = \Validator::make($request->all(),[ 'account_list' => 'required|array', 'title' => 'required', 'type' => ['nullable', Rule::in([1, 2])], ]); // Log::logInfo('打印请求参数', $request->all(), 'createRenewalJobParams'); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); $type = $request->input('type', 2); $title = $request->input('title'); $accountList = $request->input('account_list'); list($res, $code) = DjUserService::createRenewalJob($sysGroupId, $adminId, $title, $type, $accountList); return self::returnValue($res, $code); } # 客服许可续期任务列表 public function renewalJobList(Request $request) { $validator = \Validator::make($request->all(),[ 'page' => 'required|numeric', 'page_size' => 'required|numeric' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sysGroupId = $request->input('sys_group_id'); $title = $request->input('title'); $status = $request->input('status'); $page = $request->input('page'); $pageSize = $request->input('page_size'); $errno = 0; list($data, $count) = DjUserService::renewalJobList($sysGroupId, $title, $status, $page, $pageSize, $errno); if($errno) return self::returnValue([], $errno); return self::returnPageValue($data, $count, $pageSize, $page); } # 客服许可任务详情 public function renewalJobDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'rule_id' => 'required|numeric' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sysGroupId = $request->input('sys_group_id'); $ruleId = $request->input('rule_id'); $errno = 0; $data = DjUserService::renewalJobDetail($ruleId, $errno); return self::returnValue($data, $errno); } # 取消许可续期任务 public static function cancelRenewalJob(Request $request) { $validator = \Validator::make($request->all(),[ 'rule_id' => 'required|numeric' ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sysGroupId = $request->input('sys_group_id'); $ruleId = $request->input('rule_id'); $errno = 0; $res = DjUserService::cancelRenewalJob($ruleId, $errno); return self::returnValue($res, $errno); } }