ConsoleController.php 4.9 KB

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