ConsoleController.php 4.2 KB

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