ConsoleController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\stat\classes\StatSaleClass;
  4. use biz\stat\services\StatOutService;
  5. use bizHd\stat\classes\StatViewClass;
  6. use bizHd\stat\classes\StatVisitClass;
  7. use bizHd\stat\services\StatIncomeMonthService;
  8. use bizHd\stat\services\StatIncomeService;
  9. use bizHd\stat\services\StatUserService;
  10. use common\components\dict;
  11. use common\components\httpUtil;
  12. use common\components\util;
  13. class ConsoleController extends BaseController
  14. {
  15. public $guestAccess = ['init', 'profile'];
  16. //概况 ssh 2019.12.19
  17. public function actionProfile()
  18. {
  19. $notice = [
  20. //['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '查看', 'page' => '/admin/recharge/renew'],
  21. //['title' => '新手使用教程(视频)', 'action' => '查看', 'page' => '/admin/jc/index'],
  22. ];
  23. //今天客户与粉丝数
  24. $userData = StatUserService::getTodayNum($this->shopId);
  25. $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
  26. //今天销售
  27. $sale = StatSaleClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
  28. $todaySale = $sale['amount'] ?? 0;
  29. $orderNum = $sale['num'] ?? 0;
  30. //2021.4.14 linqh 今日支出
  31. $outData = StatOutService::getTodayNum($this->shopId);
  32. $todayOut = $outData['amount'] ?? '0.00';
  33. //访客数
  34. $visitCustom = StatVisitClass::getVisitNum($this->shop);
  35. $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
  36. $incomeStat = [];
  37. if (httpUtil::isMiniProgram() == false) {
  38. //当月的收入
  39. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  40. //上个月收入
  41. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  42. //最近7天收入变化趋势
  43. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  44. $incomeStat = [
  45. 'month' => $currentMonthIncome,
  46. 'week' => 999,
  47. 'previousMonth' => $previousMonthIncome,
  48. 'list' => $latestIncome,
  49. ];
  50. }
  51. $shopInfo = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  52. $menu = [
  53. ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
  54. ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
  55. ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
  56. ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
  57. ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
  58. ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
  59. ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
  60. ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"]
  61. ];
  62. $agent = $shopInfo['agentLevel'] ?? 0;
  63. if ($agent == 1) {
  64. //代理商显示邀请开店按钮
  65. $menu = [
  66. ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
  67. ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
  68. ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
  69. ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
  70. ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
  71. ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
  72. ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
  73. ["name" => "邀请开店", "img" => "ghs/home/yqyl.png", "url" => "/pagesInvite/list"]
  74. ];
  75. }
  76. util::success([
  77. 'asset' => $shopInfo,
  78. 'notice' => $notice,
  79. 'todayData' => $todayData,
  80. 'incomeStat' => $incomeStat,
  81. 'menu' => $menu,
  82. ]);
  83. }
  84. //常用初始化
  85. public function actionInit()
  86. {
  87. $dict = dict::get();
  88. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  89. util::success(['dict' => $dict, 'shop' => $shop]);
  90. }
  91. }