ConsoleController.php 5.1 KB

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