| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\adminapi\logic;
- use app\common\logic\BaseLogic;
- use app\common\service\ConfigService;
- use app\common\service\FileService;
- use app\common\model\asset\AssetInfo;
- use function Qiniu\arraySort;
- /**
- * 工作台
- * Class WorkbenchLogic
- * @package app\adminapi\logic
- */
- class WorkbenchLogic extends BaseLogic
- {
- /**
- * @notes 工作套
- * @param $adminInfo
- * @return array
- * @author 段誉
- * @date 2021/12/29 15:58
- */
- public static function index()
- {
- return [
- // 版本信息
- 'version' => self::versionInfo(),
- // 今日数据
- 'today' => self::today(),
- // 常用功能
- 'menu' => self::menu(),
- // 近15日访客数
- 'visitor' => self::visitor(),
- // 服务支持
- 'support' => self::support(),
- // 销售数据
- 'sale' => self::sale()
- ];
- }
- /**
- * @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
- {
- 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 = [];
- $j=16;
- for ($i = 0; $i < 15; $i++) {
- $where_start = strtotime("- " . $i . "day");
- $date[] = date('m/d', $where_start);
- $search_date[$j] = date('Y-m-d', $where_start);
- $j--;
- }
- array_multisort( $search_date); // 先按年龄排序,再按名字排
- foreach($search_date as $k=>$v){
- $where = [];
- $where[] = ['lease_status','=',3];
- $where[] = ['lease_expiration_time','<',$v];
- $asset_number = AssetInfo::where($where)->count();
- $num[$k] = $asset_number;
- }
- return [
- 'date' => $date,
- 'list' => [
- ['name' => '访客数', 'data' => $num]
- ]
- ];
- }
- /**
- * @notes 访问数
- * @return array
- * @author 段誉
- * @date 2021/12/29 16:57
- */
- public static function sale(): array
- {
- $num = [];
- $date = [];
- $j=7;
- for ($i = 0; $i < 7; $i++) {
- $where_start = strtotime("- " . $i . "day");
- $date[] = date('m/d', $where_start);
- $search_date[$j] = date('Y-m-d', $where_start);
- $j--;
- }
- array_multisort( $search_date); // 先按年龄排序,再按名字排
- foreach($search_date as $k=>$v){
- $where = [];
- $end_time = strtotime($v.' 23:59:59');
- $where[] = ['lease_status','=',2];
- $where[] = ['create_time','<',$end_time];
- $asset_number = AssetInfo::where($where)->count();
- $num[$k] = $asset_number;
- }
- 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' => '想了解更多请添加客服',
- ]
- ];
- }
- }
|