WorkbenchLogic.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\logic;
  15. use app\common\logic\BaseLogic;
  16. use app\common\service\ConfigService;
  17. use app\common\service\FileService;
  18. use app\common\model\asset\AssetInfo;
  19. /**
  20. * 工作台
  21. * Class WorkbenchLogic
  22. * @package app\adminapi\logic
  23. */
  24. class WorkbenchLogic extends BaseLogic
  25. {
  26. /**
  27. * @notes 工作套
  28. * @param $adminInfo
  29. * @return array
  30. * @author 段誉
  31. * @date 2021/12/29 15:58
  32. */
  33. public static function index()
  34. {
  35. return [
  36. // 版本信息
  37. 'version' => self::versionInfo(),
  38. // 今日数据
  39. 'today' => self::today(),
  40. // 常用功能
  41. 'menu' => self::menu(),
  42. // 近15日访客数
  43. 'visitor' => self::visitor(),
  44. // 服务支持
  45. 'support' => self::support(),
  46. // 销售数据
  47. 'sale' => self::sale()
  48. ];
  49. }
  50. /**
  51. * @notes 常用功能
  52. * @return array[]
  53. * @author 段誉
  54. * @date 2021/12/29 16:40
  55. */
  56. public static function menu(): array
  57. {
  58. return [
  59. [
  60. 'name' => '管理员',
  61. 'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
  62. 'url' => '/permission/admin'
  63. ],
  64. [
  65. 'name' => '角色管理',
  66. 'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
  67. 'url' => '/permission/role'
  68. ],
  69. [
  70. 'name' => '部门管理',
  71. 'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
  72. 'url' => '/organization/department'
  73. ],
  74. [
  75. 'name' => '字典管理',
  76. 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
  77. 'url' => '/dev_tools/dict'
  78. ],
  79. [
  80. 'name' => '代码生成器',
  81. 'image' => FileService::getFileUrl(config('project.default_image.menu_generator')),
  82. 'url' => '/dev_tools/code'
  83. ],
  84. [
  85. 'name' => '素材中心',
  86. 'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
  87. 'url' => '/material/index'
  88. ],
  89. [
  90. 'name' => '菜单权限',
  91. 'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
  92. 'url' => '/permission/menu'
  93. ],
  94. [
  95. 'name' => '网站信息',
  96. 'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
  97. 'url' => '/setting/website/information'
  98. ],
  99. ];
  100. }
  101. /**
  102. * @notes 版本信息
  103. * @return array
  104. * @author 段誉
  105. * @date 2021/12/29 16:08
  106. */
  107. public static function versionInfo(): array
  108. {
  109. return [
  110. 'version' => config('project.version'),
  111. 'website' => config('project.website.url'),
  112. 'name' => ConfigService::get('website', 'name'),
  113. 'based' => 'vue3.x、ElementUI、MySQL',
  114. 'channel' => [
  115. 'website' => 'https://www.likeadmin.cn',
  116. 'gitee' => 'https://gitee.com/likeadmin/likeadmin_php',
  117. ]
  118. ];
  119. }
  120. /**
  121. * @notes 今日数据
  122. * @return int[]
  123. * @author 段誉
  124. * @date 2021/12/29 16:15
  125. */
  126. public static function today(): array
  127. {
  128. return [
  129. 'time' => date('Y-m-d H:i:s'),
  130. // 今日销售额
  131. 'today_sales' => 100,
  132. // 总销售额
  133. 'total_sales' => 1000,
  134. // 今日访问量
  135. 'today_visitor' => 10,
  136. // 总访问量
  137. 'total_visitor' => 100,
  138. // 今日新增用户量
  139. 'today_new_user' => 30,
  140. // 总用户量
  141. 'total_new_user' => 3000,
  142. // 订单量 (笔)
  143. 'order_num' => 12,
  144. // 总订单量
  145. 'order_sum' => 255
  146. ];
  147. }
  148. /**
  149. * @notes 访问数
  150. * @return array
  151. * @author 段誉
  152. * @date 2021/12/29 16:57
  153. */
  154. public static function visitor(): array
  155. {
  156. $num = [];
  157. $date = [];
  158. for ($i = 0; $i < 15; $i++) {
  159. $where_start = strtotime("- " . $i . "day");
  160. $date[] = date('m/d', $where_start);
  161. $search_date = date('Y-m-d', $where_start);
  162. // $where['lease_status'] = 3;
  163. $where['lease_expiration_time'] =$search_date;
  164. // var_dump($where);
  165. // var_dump('-----');
  166. // $asset_number = AssetInfo::where($where)->count();
  167. $num[$i] = rand(0,100);
  168. }
  169. // var_dump($num);die;
  170. return [
  171. 'date' => $date,
  172. 'list' => [
  173. ['name' => '访客数', 'data' => $num]
  174. ]
  175. ];
  176. }
  177. /**
  178. * @notes 访问数
  179. * @return array
  180. * @author 段誉
  181. * @date 2021/12/29 16:57
  182. */
  183. public static function sale(): array
  184. {
  185. $num = [];
  186. $date = [];
  187. for ($i = 0; $i < 7; $i++) {
  188. $where_start = strtotime("- " . $i . "day");
  189. $date[] = date('m/d', $where_start);
  190. $num[$i] = rand(30, 200);
  191. }
  192. return [
  193. 'date' => $date,
  194. 'list' => [
  195. ['name' => '销售量', 'data' => $num]
  196. ]
  197. ];
  198. }
  199. /**
  200. * @notes 服务支持
  201. * @return array[]
  202. * @author 段誉
  203. * @date 2022/7/18 11:18
  204. */
  205. public static function support()
  206. {
  207. return [
  208. [
  209. 'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
  210. 'title' => '官方公众号',
  211. 'desc' => '关注官方公众号',
  212. ],
  213. [
  214. 'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
  215. 'title' => '添加企业客服微信',
  216. 'desc' => '想了解更多请添加客服',
  217. ]
  218. ];
  219. }
  220. }