ConsoleController.php 4.9 KB

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