ConsoleController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace hd\controllers;
  3. use biz\sj\classes\SjClass;
  4. use biz\sj\services\MerchantAssetService;
  5. use bizHd\stat\classes\StatStudentClass;
  6. use bizHd\stat\services\StatIncomeMonthService;
  7. use bizHd\stat\services\StatIncomeService;
  8. use bizHd\stat\services\StatOrderService;
  9. use bizHd\stat\services\StatUserService;
  10. use bizHd\stat\services\StatVisitService;
  11. use common\components\dict;
  12. use common\components\httpUtil;
  13. use common\components\util;
  14. class ConsoleController extends BaseController
  15. {
  16. public $guestAccess = ['init', 'profile'];
  17. //概况 ssh 2019.12.19
  18. public function actionProfile()
  19. {
  20. //试用期到期时间
  21. $notice = [];
  22. $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
  23. $deadline = $sj['deadline'] ?? 0;
  24. $current = time();
  25. $remain = strtotime($deadline) - $current;
  26. if ($remain <= 1296000) {
  27. //是否有充值免费续期权限
  28. $hasRight = SjClass::hasRechargeRenewRight($sj, $this->sjExtend);
  29. if ($hasRight) {
  30. $title = '您的试用期已结束,点此免费续期';
  31. if ($remain > 0) {
  32. $num = ceil($remain / 86400);
  33. $title = "您的试用期还有{$num}天,点此免费续期";
  34. }
  35. //暂时关闭续期提示
  36. //$notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/admin/recharge/renew']]);
  37. } else {
  38. $title = '您的试用期已结束,请及时续费';
  39. if ($remain > 0) {
  40. $num = ceil($remain / 86400);
  41. $title = "您的试用期还有{$num}天,请及时续费";
  42. }
  43. //暂时关闭续期提示
  44. //$notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/pagesClient/official/renewal']]);
  45. }
  46. }
  47. //引导关注公众号
  48. $admin = $this->admin;
  49. $subscribe = $admin['subscribe'] ?? 0;
  50. if ($subscribe == 0) {
  51. //$notice = array_merge($notice, [['title' => '开启提醒,批发店花材做特价及时通知您', 'action' => '开启', 'page' => '/pagesClient/official/warn']]);
  52. }
  53. $notice = [['title' => '打开小程序自动登录后台', 'action' => '启用', 'page' => '/admin/staff/miniAutoLogin']];
  54. if (isset($this->shop) && !empty($this->shop)) {
  55. //今天访客
  56. $todayVisit = 0;
  57. //今天开单
  58. $orderData = StatOrderService::getTodayNum($this->shopId);
  59. $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
  60. //今天收入
  61. $incomeData = StatIncomeService::getTodayNum($this->shopId);
  62. $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
  63. //今天新学员数
  64. $newStudent = StatStudentClass::getTodayNum($this->shop);
  65. //今日概况
  66. } else {
  67. $todayVisit = 0;
  68. $todayIncome = 0.00;
  69. $todayOrder = 0;
  70. $newStudent = 0;
  71. }
  72. $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
  73. $incomeStat = [];
  74. if (httpUtil::isMiniProgram() == false) {
  75. //当月的收入
  76. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  77. //上个月收入
  78. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  79. //最近7天收入变化趋势
  80. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  81. $incomeStat = [
  82. 'month' => $currentMonthIncome,
  83. 'week' => 999,
  84. 'previousMonth' => $previousMonthIncome,
  85. 'list' => $latestIncome,
  86. ];
  87. }
  88. $visitStat = [
  89. 'month' => 1999,
  90. 'week' => 999,
  91. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  92. ];
  93. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  94. util::success([
  95. 'asset' => $shop,
  96. 'notice' => $notice,
  97. 'todayData' => $todayData,
  98. 'visitStat' => $visitStat,
  99. 'incomeStat' => $incomeStat,
  100. ]);
  101. }
  102. //常用初始化
  103. public function actionInit()
  104. {
  105. $dict = dict::get();
  106. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  107. util::success(['dict' => $dict, 'shop' => $shop]);
  108. }
  109. }