ConsoleController.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. ['title' => '新手使用教程(视频)', 'action' => '查看', 'page' => '/admin/jc/index'],
  21. ];
  22. //今天客户与粉丝数
  23. $userData = StatUserService::getTodayNum($this->shopId);
  24. $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
  25. //今天销售
  26. $sale = StatSaleClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
  27. $todaySale = $sale['amount'] ?? 0;
  28. $orderNum = $sale['num'] ?? 0;
  29. //2021.4.14 linqh 今日支出
  30. $outData = StatOutService::getTodayNum($this->shopId);
  31. $todayOut = $outData['amount'] ?? '0.00';
  32. $view = StatViewClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
  33. $viewNum = $view['riseNum'] ?? 0;
  34. $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'view' => $viewNum];
  35. $incomeStat = [];
  36. if (httpUtil::isMiniProgram() == false) {
  37. //当月的收入
  38. $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
  39. //上个月收入
  40. $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
  41. //最近7天收入变化趋势
  42. $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
  43. $incomeStat = [
  44. 'month' => $currentMonthIncome,
  45. 'week' => 999,
  46. 'previousMonth' => $previousMonthIncome,
  47. 'list' => $latestIncome,
  48. ];
  49. }
  50. $asset = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  51. util::success([
  52. 'asset' => $asset,
  53. 'notice' => $notice,
  54. 'todayData' => $todayData,
  55. 'incomeStat' => $incomeStat,
  56. ]);
  57. }
  58. //常用初始化
  59. public function actionInit()
  60. {
  61. $dict = dict::get();
  62. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  63. util::success(['dict' => $dict, 'shop' => $shop]);
  64. }
  65. }