self::versionInfo(), // 今日数据 'today' => self::today(), // 常用功能 'menu' => self::menu(), // 近15日访客数 'visitor' => self::visitor(), // 服务支持 'support' => self::support(), // 销售数据 'sale' => self::sale(), 'income'=>self::income(), 'customer'=>self::customer(), 'new_customer'=> 0, 'total_visitor'=> self::getTotalVistor(), //农机手 'agricultural_data'=> self::agricultural(), 'bake_data'=> self::bake(), 'air_data'=> self::air(), ]; } public static function getServiceInfo($type,$area_id){ return [ 'service'=>self::service($type,$area_id), ]; } public static function getProductionInfo($area_id,$start_time,$end_time){ return ['chat_data'=>self::production($area_id,$start_time,$end_time)]; } /** * @notes 常用功能 * @return array[] * @author 段誉 * @date 2021/12/29 16:40 */ public static function menu(): array { return [ [ 'name' => '管理员', 'image' => FileService::getFileUrl(config('project.default_image.menu_admin')), 'url' => '/permission/admin' ], [ 'name' => '角色管理', 'image' => FileService::getFileUrl(config('project.default_image.menu_role')), 'url' => '/permission/role' ], [ 'name' => '部门管理', 'image' => FileService::getFileUrl(config('project.default_image.menu_dept')), 'url' => '/organization/department' ], [ 'name' => '字典管理', 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')), 'url' => '/dev_tools/dict' ], [ 'name' => '代码生成器', 'image' => FileService::getFileUrl(config('project.default_image.menu_generator')), 'url' => '/dev_tools/code' ], [ 'name' => '素材中心', 'image' => FileService::getFileUrl(config('project.default_image.menu_file')), 'url' => '/material/index' ], [ 'name' => '菜单权限', 'image' => FileService::getFileUrl(config('project.default_image.menu_auth')), 'url' => '/permission/menu' ], [ 'name' => '网站信息', 'image' => FileService::getFileUrl(config('project.default_image.menu_web')), 'url' => '/setting/website/information' ], ]; } /** * @notes 版本信息 * @return array * @author 段誉 * @date 2021/12/29 16:08 */ public static function versionInfo(): array { return [ 'version' => config('project.version'), 'website' => config('project.website.url'), 'name' => ConfigService::get('website', 'name'), 'based' => 'vue3.x、ElementUI、MySQL', 'channel' => [ 'website' => 'https://www.likeadmin.cn', 'gitee' => 'https://gitee.com/likeadmin/likeadmin_php', ] ]; } /** * @notes 今日数据 * @return int[] * @author 段誉 * @date 2021/12/29 16:15 */ public static function today(): array { $now = date('Y-m-d',time()); $start_time = $now.' 00:00:00'; // $articleInfo = Article::field('sum(click_actual) as totalvisito') return [ 'time' => date('Y-m-d H:i:s'), // 今日销售额 'today_sales' => 100, // 总销售额 'total_sales' => 1000, // 今日访问量 'today_visitor' => 10, // 总访问量 'total_visitor' => 100, // 今日新增用户量 'today_new_user' => 30, // 总用户量 'total_new_user' => 3000, // 订单量 (笔) 'order_num' => 12, // 总订单量 'order_sum' => 255 ]; } /** * @notes 访问数 * @return array * @author 段誉 * @date 2021/12/29 16:57 */ public static function visitor(): array { $num = []; $date = []; for ($i = 0; $i < 15; $i++) { $where_start = strtotime("- " . $i . "day"); $date[] = date('m/d', $where_start); $num[$i] = rand(0, 100); } return [ 'date' => $date, 'list' => [ ['name' => '访客数', 'data' => $num] ] ]; } /** * @notes 访问数 * @return array * @author 段誉 * @date 2021/12/29 16:57 */ public static function sale(): array { $num = []; $date = []; for ($i = 0; $i < 7; $i++) { $where_start = strtotime("- " . $i . "day"); $date[] = date('m/d', $where_start); $num[$i] = rand(30, 200); } return [ 'date' => $date, 'list' => [ ['name' => '销售量', 'data' => $num] ] ]; } /** * @notes 服务支持 * @return array[] * @author 段誉 * @date 2022/7/18 11:18 */ public static function support() { return [ [ 'image' => FileService::getFileUrl(config('project.default_image.qq_group')), 'title' => '官方公众号', 'desc' => '关注官方公众号', ], [ 'image' => FileService::getFileUrl(config('project.default_image.customer_service')), 'title' => '添加企业客服微信', 'desc' => '想了解更多请添加客服', ] ]; } /* * 收益 * **/ public static function income(){ $where=[]; $now = time(); $start_time = date('Y-m-d',$now).' 00:00:00'; $where[]=['pay_status','=',1]; $total_income = RechargeOrder::where($where)->sum('order_amount'); $where[]=['pay_time','>=',strtotime($start_time)]; $today_income = RechargeOrder::where($where)->sum('order_amount'); $data['total_income']=$total_income; $data['today_income']=$today_income; return ($data); } /* * 客户总数 * */ public static function customer(){ $userCount = User::count(); return $userCount; } public static function service($type=1,$area_id=''){ $where = []; $where[]=['type','=',$type]; $where[]=['status','=',1]; if(!empty($area_id)){ $where[] = ['area_id', 'like','%'. ',' . $area_id. ',' .'%']; } $userCount = UserService::where($where)->count(); switch ($type){ case 1 : $type_desc='农机手'; break; case 2: $type_desc='烘干服务'; break; case 3: $type_desc='飞防服务'; break; } return ['type_desc'=>$type_desc,'count'=>$userCount]; } public static function production($area_id,$start_time,$end_time){ $where = []; $where[]=['sdi.type','=',1]; $where[]=['sdi.status','=',2]; if($area_id){ } if($start_time <> '' && $end_time <> ''){ $where[] = ['sdi.create_time', 'between', [strtotime($start_time),strtotime($end_time. ' 23:59:59')]]; }else{ if($start_time<>''){ $where[]=['sdi.create_time','>=',strtotime($start_time)]; } if($end_time <> ''){ $where[]=['sdi.create_time','<=',strtotime($end_time. ' 23:59:59')]; } } $supply_demand_list = SupplyDemandInfo::alias('sdi') ->leftJoin('supply_demand_cate sdc','sdc.id = sdi.cate_id') ->field('sdi.cate_id,sdc.name,sum(sdi.number) total_num') ->where($where)->group('sdi.cate_id')->select()->toArray(); $name = []; $value = [] ; if($supply_demand_list){ $name = array_column($supply_demand_list,'name'); $value = array_column($supply_demand_list,'total_num'); } $data=['name'=>$name,'value'=>$value]; return $data; } public static function agricultural(){ $nowYear = date('Y'); $nowMonth = date('n'); $monthData = []; $monthArr = []; for ($i = 1; $i <= $nowMonth; $i++) { array_push($monthArr, $i); $monthFat = $i . '月'; array_push($monthData, $monthFat); } $data['monthData'] = $monthData; $valueData=[]; foreach($monthArr as &$v){ $date_arr = getMonthFirstAndLastDay($nowYear,$v); $lastDate = $date_arr['lastDay']; $lasttime = strtotime($date_arr['lastDay'].' 23:59:59'); $where=[]; $where[]=['type','=',1]; $where[]=['status','=',1]; $where[]=['create_time','<=',$lasttime]; $count = UserService::where($where)->count(); $valueData[]=$count; } $data['valueData'] = $valueData; return $data; } public static function bake(){ $nowYear = date('Y'); $nowMonth = date('n'); $monthData = []; $monthArr = []; for ($i = 1; $i <= $nowMonth; $i++) { array_push($monthArr, $i); $monthFat = $i . '月'; array_push($monthData, $monthFat); } $data['monthData'] = $monthData; $valueData=[]; foreach($monthArr as &$v){ $date_arr = getMonthFirstAndLastDay($nowYear,$v); $lastDate = $date_arr['lastDay']; $lasttime = strtotime($date_arr['lastDay'].' 23:59:59'); $where=[]; $where[]=['type','=',2]; $where[]=['status','=',1]; $where[]=['create_time','<=',$lasttime]; $count = UserService::where($where)->count(); $valueData[]=$count; } $data['valueData'] = $valueData; return $data; } public static function air(){ $nowYear = date('Y'); $nowMonth = date('n'); $monthData = []; $monthArr = []; for ($i = 1; $i <= $nowMonth; $i++) { array_push($monthArr, $i); $monthFat = $i . '月'; array_push($monthData, $monthFat); } $data['monthData'] = $monthData; $valueData=[]; foreach($monthArr as &$v){ $date_arr = getMonthFirstAndLastDay($nowYear,$v); $lastDate = $date_arr['lastDay']; $lasttime = strtotime($date_arr['lastDay'].' 23:59:59'); $where=[]; $where[]=['type','=',3]; $where[]=['status','=',1]; $where[]=['create_time','<=',$lasttime]; $count = UserService::where($where)->count(); $valueData[]=$count; } $data['valueData'] = $valueData; return $data; } public static function getTotalVistor(){ $number = 0; $where['is_show'] =1; $count = Article::where($where)->field('sum(click_actual) total_vistor')->find(); if($count){ $number = $count['total_vistor']; } return $number; } }