ConsoleController.php 3.0 KB

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