WorkbenchLogic.php 6.5 KB

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