ConsoleController.php 3.8 KB

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