ConsoleController.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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'];
  16. //概况 ssh 2019.12.19
  17. public function actionProfile()
  18. {
  19. $asset = MerchantAssetService::getByMerchantId($this->sjId);
  20. //试用期到期时间
  21. $notice = [];
  22. $sj = $this->sj;
  23. $deadline = $sj['deadline'] ?? 0;
  24. $current = time();
  25. $remain = strtotime($deadline) - $current;
  26. if ($remain <= 1296000) {
  27. //是否有充值免费续期权限
  28. $hasRight = SjClass::hasRechargeRenewRight($this->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/index']]);
  43. }
  44. }
  45. //今天访客数
  46. $todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
  47. //今天客户与粉丝数
  48. $userData = StatUserService::getTodayNum($this->sjId);
  49. $todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
  50. $todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
  51. //今天订单数
  52. $orderData = StatOrderService::getTodayNum($this->sjId);
  53. $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
  54. //今天收入
  55. $incomeData = StatIncomeService::getTodayNum($this->sjId);
  56. $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
  57. $todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder];
  58. $incomeStat = [];
  59. if (httpUtil::isMiniProgram() == false) {
  60. //当月的收入
  61. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  62. //上个月收入
  63. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  64. //最近7天收入变化趋势
  65. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  66. $incomeStat = [
  67. 'month' => $currentMonthIncome,
  68. 'week' => 999,
  69. 'previousMonth' => $previousMonthIncome,
  70. 'list' => $latestIncome,
  71. ];
  72. }
  73. $visitStat = [
  74. 'month' => 1999,
  75. 'week' => 999,
  76. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  77. ];
  78. util::success([
  79. 'asset' => $asset,
  80. 'notice' => $notice,
  81. 'todayData' => $todayData,
  82. 'visitStat' => $visitStat,
  83. 'incomeStat' => $incomeStat,
  84. ]);
  85. }
  86. //常用初始化
  87. public function actionInit()
  88. {
  89. $dict = dict::get();
  90. $shop = $this->shop;
  91. util::success(['dict' => $dict, 'shop' => $shop]);
  92. }
  93. }