ConsoleController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace hd\controllers;
  3. use biz\sj\classes\SjClass;
  4. use biz\sj\services\MerchantAssetService;
  5. use bizHd\stat\services\StatIncomeMonthService;
  6. use bizHd\stat\services\StatIncomeService;
  7. use bizHd\stat\services\StatOrderService;
  8. use bizHd\stat\services\StatUserService;
  9. use bizHd\stat\services\StatVisitService;
  10. use common\components\dict;
  11. use common\components\httpUtil;
  12. use common\components\util;
  13. class ConsoleController extends BaseController
  14. {
  15. public $guestAccess = ['init', 'profile'];
  16. //概况 ssh 2019.12.19
  17. public function actionProfile()
  18. {
  19. //试用期到期时间
  20. $notice = [];
  21. $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
  22. $deadline = $sj['deadline'] ?? 0;
  23. $current = time();
  24. $remain = strtotime($deadline) - $current;
  25. if ($remain <= 1296000) {
  26. //是否有充值免费续期权限
  27. $hasRight = SjClass::hasRechargeRenewRight($sj, $this->sjExtend);
  28. if ($hasRight) {
  29. $title = '您的试用期已到,点击免费续期1年';
  30. if ($remain > 0) {
  31. $num = ceil($remain / 86400);
  32. $title = "您的试用期还有{$num}天,点击免费续期";
  33. }
  34. $notice = array_merge($notice, [['title' => $title, 'action' => '查看', 'page' => '/admin/recharge/renew']]);
  35. } else {
  36. $title = '您的试用期已到,请及时续费';
  37. if ($remain > 0) {
  38. $num = ceil($remain / 86400);
  39. $title = "您的试用期还有{$num}天,请及时续费";
  40. }
  41. $notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/pagesClient/official/renewal']]);
  42. }
  43. }
  44. //今天访客
  45. $todayVisit = StatVisitService::getTodayVisitNum($this->shopId);
  46. //今天开单
  47. $orderData = StatOrderService::getTodayNum($this->shopId);
  48. $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
  49. //今天收入
  50. $incomeData = StatIncomeService::getTodayNum($this->shopId);
  51. $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
  52. //今日概况
  53. $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => 1];
  54. $incomeStat = [];
  55. if (httpUtil::isMiniProgram() == false) {
  56. //当月的收入
  57. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  58. //上个月收入
  59. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  60. //最近7天收入变化趋势
  61. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  62. $incomeStat = [
  63. 'month' => $currentMonthIncome,
  64. 'week' => 999,
  65. 'previousMonth' => $previousMonthIncome,
  66. 'list' => $latestIncome,
  67. ];
  68. }
  69. $visitStat = [
  70. 'month' => 1999,
  71. 'week' => 999,
  72. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  73. ];
  74. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  75. util::success([
  76. 'asset' => $shop,
  77. 'notice' => $notice,
  78. 'todayData' => $todayData,
  79. 'visitStat' => $visitStat,
  80. 'incomeStat' => $incomeStat,
  81. ]);
  82. }
  83. //常用初始化
  84. public function actionInit()
  85. {
  86. $dict = dict::get();
  87. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  88. util::success(['dict' => $dict, 'shop' => $shop]);
  89. }
  90. }