Dashboard.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare (strict_types = 1);
  11. namespace app\admin\controller;
  12. use app\common\model\Admin;
  13. use app\common\model\delivery\Text;
  14. use app\common\model\MoneyLog;
  15. use app\common\model\StockDetail;
  16. use app\common\model\StockConfig;
  17. use app\common\library\Date;
  18. use app\common\controller\Backend;
  19. use think\annotation\route\Route;
  20. use think\facade\Db;
  21. /**
  22. * 控制台
  23. */
  24. class Dashboard extends Backend
  25. {
  26. public function _initialize()
  27. {
  28. parent::_initialize();
  29. }
  30. /**
  31. * 查看
  32. */
  33. #[Route('GET','dashboard/index')]
  34. public function index(StockConfig $stockConfig, StockDetail $stockDetail, MoneyLog $moneyLog)
  35. {
  36. if($this->request->isAjax()){
  37. //顶部统计
  38. $moneyLog = $moneyLog::getCountBalance();
  39. $panel=[
  40. rand(100,1000),
  41. rand(100,1000),
  42. $moneyLog['balance'], // 当前结余(所有收入-支出)
  43. rand(100,1000),
  44. ];
  45. $variety = [];
  46. $box = [];
  47. $material = [];
  48. $list = $stockConfig->where('status', $stockConfig::StatusNormal)->field('id,type_id,title')->orderRaw("field('variety_name','packing_box','material')")->select();
  49. foreach ($list as $item) {
  50. switch ($item['type_id']) {
  51. case $stockConfig::VarietyName:
  52. $variety[] = [
  53. 'name' => $item->title,
  54. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  55. ];
  56. break;
  57. case $stockConfig::PackingBox:
  58. $box[] = [
  59. 'name' => $item->title,
  60. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  61. ];
  62. break;
  63. case $stockConfig::Material:
  64. $material[] = [
  65. 'name' => $item->title,
  66. 'num' => $stockDetail->where('key', $item['id'])->value('num')
  67. ];
  68. break;
  69. }
  70. }
  71. $this->success('',compact('panel','variety','box','material'));
  72. }
  73. return $this->fetch();
  74. }
  75. #[Route('GET','dashboard/platform1')]
  76. public function platform1()
  77. {
  78. return $this->fetch();
  79. }
  80. #[Route('GET','dashboard/platform2')]
  81. public function platform2()
  82. {
  83. return $this->fetch();
  84. }
  85. }