ConsoleController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. $notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/admin/recharge/renew']]);
  36. } else {
  37. $title = '您的试用期已结束,请及时续费';
  38. if ($remain > 0) {
  39. $num = ceil($remain / 86400);
  40. $title = "您的试用期还有{$num}天,请及时续费";
  41. }
  42. $notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/pagesClient/official/renewal']]);
  43. }
  44. }
  45. //引导关注公众号
  46. $admin = $this->admin;
  47. $subscribe = $admin['subscribe'] ?? 0;
  48. if ($subscribe == 0) {
  49. $notice = array_merge($notice, [['title' => '您还未开启提醒,无法接收新订单通知', 'action' => '开启', 'page' => '/pagesClient/official/warn']]);
  50. }
  51. if (isset($this->shop) && !empty($this->shop)) {
  52. //今天访客
  53. $todayVisit = StatVisitService::getTodayVisitNum($this->shopId);
  54. //今天开单
  55. $orderData = StatOrderService::getTodayNum($this->shopId);
  56. $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
  57. //今天收入
  58. $incomeData = StatIncomeService::getTodayNum($this->shopId);
  59. $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
  60. //今天新学员数
  61. $newStudent = StatStudentClass::getTodayNum($this->shop);
  62. //今日概况
  63. } else {
  64. $todayVisit = 0;
  65. $todayIncome = 0.00;
  66. $todayOrder = 0;
  67. $newStudent = 0;
  68. }
  69. $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
  70. $incomeStat = [];
  71. if (httpUtil::isMiniProgram() == false) {
  72. //当月的收入
  73. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  74. //上个月收入
  75. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  76. //最近7天收入变化趋势
  77. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  78. $incomeStat = [
  79. 'month' => $currentMonthIncome,
  80. 'week' => 999,
  81. 'previousMonth' => $previousMonthIncome,
  82. 'list' => $latestIncome,
  83. ];
  84. }
  85. $visitStat = [
  86. 'month' => 1999,
  87. 'week' => 999,
  88. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  89. ];
  90. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  91. util::success([
  92. 'asset' => $shop,
  93. 'notice' => $notice,
  94. 'todayData' => $todayData,
  95. 'visitStat' => $visitStat,
  96. 'incomeStat' => $incomeStat,
  97. ]);
  98. }
  99. //常用初始化
  100. public function actionInit()
  101. {
  102. $dict = dict::get();
  103. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  104. util::success(['dict' => $dict, 'shop' => $shop]);
  105. }
  106. }