where('status', 1)->first(); if(!empty($keyAdmin)){ if(!empty($keyCorp)) { $adminInfo = Admin::where('username', $keyAdmin)->where('corp_id', $corpInfo['corp_id'])->first(); $adminIds[] = $adminInfo['id']; } else { $adminInfo = Admin::where('username', $keyAdmin)->first(); $adminIds[] = $adminInfo['id']; } } else { $adminIds = Admin::where('corp_id', $corpInfo['corp_id'])->pluck('id'); } //获取企业或管理员的行为日志 $curl = env('APP_LOG_URL').'/EventLog/statistics?event_type='.$keyEvent."&admin_ids=".json_encode(collect($adminIds)->toArray()).'&start_time='.$startTime.'&end_time='.$endTime; $corpData = Api::curl($curl); $corpData = json_decode($corpData,true); $data = []; foreach($corpData as $k=>$v){ $adminInfo = Admin::where('id', $v['admin_id'])->first(); $data[$k]['visit_name'] = $adminInfo['name']; switch ($v['event']){ case 'changeScene1': $data[$k]['event_type'] = '体验案例1'; break; case 'changeScene2': $data[$k]['event_type'] = '体验案例2'; break; case 'changeScene3': $data[$k]['event_type'] = '体验案例3'; break; case 'changeScene4': $data[$k]['event_type'] = '体验案例4'; break; case 'openClick1': $data[$k]['event_type'] = '点击付费购买体验版'; break; case 'openClick10': $data[$k]['event_type'] = '点击付费购买专业版'; break; case 'openClick100': $data[$k]['event_type'] = '点击付费购买企业版'; break; case 'chatClick1': $data[$k]['event_type'] = '头部客服访问'; break; case 'chatClick2': $data[$k]['event_type'] = '图标客服访问'; break; } $data[$k]['visit_time'] = date('Y-m-d H:i:s', $v['create_time']); } } else { $type = 'all'; //不存在搜索条件,则搜索全部企业的总计信息 $corpIds = Admin::groupBy('corp_id')->pluck('corp_id'); foreach($corpIds as $corpId){ if($corpId == 0){ continue; } $corpAdminIds = Admin::where('corp_id', $corpId)->pluck('id'); $curl = env('APP_LOG_URL').'/EventLog/statistics?event_type='.$keyEvent."&admin_ids=".json_encode(collect($corpAdminIds)->toArray()).'&start_time='.$startTime.'&end_time='.$endTime; $res = Api::curl($curl); $corpInfo = Corps::where('corp_id', $corpId)->first(); $data[$corpId]['corp_short_name'] = $corpInfo['corp_short_name']; $data[$corpId]['agh_corp_id'] = $corpInfo['source_id']; $data[$corpId]['register_time'] = date('Y-m-d H:i:s', $corpInfo['register_time']); $data[$corpId]['clickCount'] = count(json_decode($res, true)); } } return Api::arr(config('code.success'), trans('msg.success'), $data); } /** * 获取订单信息 * @param $params * @return mixed */ public static function orderList($params){ $sql = Orders::where('status', 1)->whereBetween('create_time', [$params['order_start_time'], $params['order_end_time']]); if(!empty($params['corp_name'])){ $corpIds = Corps::where('corp_name', 'like', '%'.$params['corp_name'].'%')->pluck('corp_id'); $sql = $sql->whereIn('corp_id', $corpIds); } $data = $sql->orderBy('create_time')->get(); foreach($data as $k=>$v){ $data[$k]['corp_name'] = Corps::where('corp_id', $v['corp_id'])->value('corp_name'); $data[$k]['admin_name'] = Admin::where('id', $v['admin_id'])->value('name'); if($params['vip_start_time'] > $v['create_time'] + 30*3600*24*$v['months'] || $params['vip_end_time'] < $v['create_time'] + 30*3600*24*$v['months']){ unset($data[$k]); } } return $data; } } ?>