ConsoleController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace hd\controllers;
  3. use biz\sj\classes\SjClass;
  4. use biz\sj\services\MerchantAssetService;
  5. use biz\stat\classes\StatSaleClass;
  6. use biz\stat\services\StatOutService;
  7. use bizHd\stat\classes\StatStudentClass;
  8. use bizHd\stat\services\StatIncomeMonthService;
  9. use bizHd\stat\services\StatIncomeService;
  10. use bizHd\stat\services\StatOrderService;
  11. use bizHd\stat\services\StatUserService;
  12. use bizHd\stat\services\StatVisitService;
  13. use common\components\dict;
  14. use common\components\httpUtil;
  15. use common\components\util;
  16. use Yii;
  17. class ConsoleController extends BaseController
  18. {
  19. public $guestAccess = ['init', 'profile'];
  20. //概况 ssh 2019.12.19
  21. public function actionProfile()
  22. {
  23. $get = Yii::$app->request->get();
  24. $isMini = $get['isMini'] ?? 0;
  25. $notice = [];
  26. $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
  27. $deadline = $sj['deadline'] ?? 0;
  28. $current = time();
  29. $remain = strtotime($deadline) - $current;
  30. if ($remain <= 1296000) {
  31. //是否有充值免费续期权限
  32. $hasRight = SjClass::hasRechargeRenewRight($sj, $this->sjExtend);
  33. if ($hasRight) {
  34. $title = '您的试用期已结束,点此免费续期';
  35. if ($remain > 0) {
  36. $num = ceil($remain / 86400);
  37. $title = "您的试用期还有{$num}天,点此免费续期";
  38. }
  39. } else {
  40. if ($remain > 0) {
  41. $num = ceil($remain / 86400);
  42. $title = "您的试用期还有{$num}天,请及时续费";
  43. }
  44. }
  45. }
  46. //引导关注公众号
  47. $admin = $this->admin;
  48. if ($isMini == 1 && !empty($admin)) {
  49. $miniOpenId = $admin['miniOpenId'] ?? '';
  50. if (empty($miniOpenId)) {
  51. $notice = [['title' => '绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']];
  52. }
  53. }
  54. $todayVisit = 0;
  55. $todaySale = 0.00;
  56. $orderNum = 0;
  57. if (isset($this->shop) && !empty($this->shop)) {
  58. //今天销售
  59. $sale = StatSaleClass::getByCondition(['mainId' => $this->mainId, 'time' => date('Ymd')]);
  60. $todaySale = $sale['amount'] ?? 0;
  61. $orderNum = $sale['num'] ?? 0;
  62. }
  63. //2021.4.14 lqh 今日支出
  64. $outData = StatOutService::getTodayNum($this->mainId);
  65. $todayOut = $outData['amount'] ?? '0.00';
  66. $todayData = ['visit' => $todayVisit, 'income' => $todaySale, 'order' => $orderNum, 'out' => $todayOut];
  67. $incomeStat = [];
  68. $visitStat = [
  69. 'month' => 1999,
  70. 'week' => 999,
  71. 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
  72. ];
  73. //是否已经提醒小程序名称变更
  74. $cacheKey = 'change_mini_name_remind_' . $this->shopAdminId;
  75. $hasRemindChangeAppName = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  76. $hasRemindChange = 1;
  77. if (empty($hasRemindChangeAppName)) {
  78. if (!empty($this->shopAdminId)) {
  79. $hasRemindChange = 0;
  80. }
  81. }
  82. util::success([
  83. 'asset' => $this->main,
  84. 'notice' => $notice,
  85. 'todayData' => $todayData,
  86. 'visitStat' => $visitStat,
  87. 'incomeStat' => $incomeStat,
  88. 'hasRemindChangeAppName' => $hasRemindChange,
  89. ]);
  90. }
  91. //常用初始化
  92. public function actionInit()
  93. {
  94. $dict = dict::get();
  95. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  96. util::success(['dict' => $dict, 'shop' => $shop]);
  97. }
  98. }