ConsoleController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. if (isset($this->shop) && !empty($this->shop)) {
  54. //今天访客
  55. $todayVisit = StatVisitService::getTodayVisitNum($this->shopId);
  56. //今天开单
  57. $orderData = StatOrderService::getTodayNum($this->shopId);
  58. $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
  59. //今天收入
  60. $incomeData = StatIncomeService::getTodayNum($this->shopId);
  61. $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
  62. //今天新学员数
  63. $newStudent = StatStudentClass::getTodayNum($this->shop);
  64. //今日概况
  65. } else {
  66. $todayVisit = 0;
  67. $todayIncome = 0.00;
  68. $todayOrder = 0;
  69. $newStudent = 0;
  70. }
  71. $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
  72. $incomeStat = [];
  73. if (httpUtil::isMiniProgram() == false) {
  74. //当月的收入
  75. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  76. //上个月收入
  77. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  78. //最近7天收入变化趋势
  79. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  80. $incomeStat = [
  81. 'month' => $currentMonthIncome,
  82. 'week' => 999,
  83. 'previousMonth' => $previousMonthIncome,
  84. 'list' => $latestIncome,
  85. ];
  86. }
  87. $visitStat = [
  88. 'month' => 1999,
  89. 'week' => 999,
  90. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  91. ];
  92. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  93. util::success([
  94. 'asset' => $shop,
  95. 'notice' => $notice,
  96. 'todayData' => $todayData,
  97. 'visitStat' => $visitStat,
  98. 'incomeStat' => $incomeStat,
  99. ]);
  100. }
  101. //常用初始化
  102. public function actionInit()
  103. {
  104. $dict = dict::get();
  105. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  106. util::success(['dict' => $dict, 'shop' => $shop]);
  107. }
  108. }