ConsoleController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\stat\classes\StatSaleClass;
  4. use biz\stat\services\StatOutService;
  5. use bizHd\stat\classes\StatViewClass;
  6. use bizHd\stat\services\StatIncomeMonthService;
  7. use bizHd\stat\services\StatIncomeService;
  8. use bizHd\stat\services\StatUserService;
  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', 'profile'];
  15. //概况 ssh 2019.12.19
  16. public function actionProfile()
  17. {
  18. $notice = [
  19. //['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '查看', 'page' => '/admin/recharge/renew'],
  20. ];
  21. //今天客户与粉丝数
  22. $userData = StatUserService::getTodayNum($this->shopId);
  23. $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
  24. //今天销售
  25. $sale = StatSaleClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
  26. $todaySale = $sale['amount'] ?? 0;
  27. $orderNum = $sale['num'] ?? 0;
  28. //2021.4.14 linqh 今日支出
  29. $outData = StatOutService::getTodayNum($this->shopId);
  30. $todayOut = $outData['amount'] ?? '0.00';
  31. $view = StatViewClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
  32. $viewNum = $view['riseNum'] ?? 0;
  33. $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'view' => $viewNum];
  34. $incomeStat = [];
  35. if (httpUtil::isMiniProgram() == false) {
  36. //当月的收入
  37. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  38. //上个月收入
  39. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  40. //最近7天收入变化趋势
  41. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  42. $incomeStat = [
  43. 'month' => $currentMonthIncome,
  44. 'week' => 999,
  45. 'previousMonth' => $previousMonthIncome,
  46. 'list' => $latestIncome,
  47. ];
  48. }
  49. $asset = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  50. util::success([
  51. 'asset' => $asset,
  52. 'notice' => $notice,
  53. 'todayData' => $todayData,
  54. 'incomeStat' => $incomeStat,
  55. ]);
  56. }
  57. //常用初始化
  58. public function actionInit()
  59. {
  60. $dict = dict::get();
  61. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  62. util::success(['dict' => $dict, 'shop' => $shop]);
  63. }
  64. }