shish пре 5 година
родитељ
комит
e5d30c9c0f

+ 15 - 0
app-ghs/controllers/ConsoleController.php

@@ -52,12 +52,27 @@ class ConsoleController extends BaseController
             ['name' => '改价', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
             ['name' => '全部', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
         ];
+
+        //当月的收入
+        $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
+        //上个月收入
+        $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
+        //最近7天收入变化趋势
+        $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
+        $incomeStat = [
+            'month' => $currentMonthIncome,
+            'week' => 999,
+            'previousMonth' => $previousMonthIncome,
+            'list' => $latestIncome,
+        ];
+
         util::success([
             'asset' => $asset,
             'notice' => $notice,
             'todayData' => $todayData,
             'mainMenu' => $mainMenu,
             'menu' => $menu,
+            'incomeStat' => $incomeStat,
         ]);
     }
 

+ 4 - 4
biz-hd/stat/services/StatIncomeMonthService.php

@@ -12,19 +12,19 @@ class StatIncomeMonthService extends BaseService
 	public static $baseFile = '\bizHd\stat\classes\StatIncomeMonthClass';
 	
 	//获取当前月份的收入 ssh 2020.2.2
-	public static function getCurrentMonthIncome($merchantId)
+	public static function getCurrentMonthIncome($shopId)
 	{
 		$month = date("Ym");
-		$return = StatIncomeMonthClass::getByCondition(['merchantId' => $merchantId, 'time' => $month]);
+		$return = StatIncomeMonthClass::getByCondition(['shopId' => $shopId, 'time' => $month]);
 		$income = isset($return['amount']) ? $return['amount'] : 0;
 		return $income;
 	}
 
 	//上个月收入 ssh 2020.2.2
-	public static function getPreviousMonthIncome($merchantId)
+	public static function getPreviousMonthIncome($shopId)
 	{
 		$month = date("Ym", mktime(0, 0, 0, date("m") - 1, 1, date("Y")));
-		$return = StatIncomeMonthClass::getByCondition(['merchantId' => $merchantId, 'time' => $month]);
+		$return = StatIncomeMonthClass::getByCondition(['shopId' => $shopId, 'time' => $month]);
 		$income = isset($return['amount']) ? $return['amount'] : 0;
 		return $income;
 	}

+ 4 - 4
biz-hd/stat/services/StatIncomeService.php

@@ -35,19 +35,19 @@ class StatIncomeService extends BaseService
 	}
 
 	//获取最近的收入情况 ssh 2019.9.21
-	public static function getLatestIncome($start, $end, $merchantId)
+	public static function getLatestIncome($start, $end, $shopId)
 	{
-		$list = self::getAllList('*', ['merchantId' => $merchantId, 'time' => ['between', [$start, $end]]], 'time asc');
+		$list = self::getAllList('*', ['shopId' => $shopId, 'time' => ['between', [$start, $end]]], 'time asc');
 		return $list;
 	}
 
 	//最近7天收入情况 ssh 2020.2.2
-	public static function getLatestSevenDay($merchantId)
+	public static function getLatestSevenDay($shopId)
 	{
 		$return = dateUtil::getDate(1);
 		$start = $return[0];
 		$end = $return[1];
-		$list = self::getLatestIncome($start, $end, $merchantId);
+		$list = self::getLatestIncome($start, $end, $shopId);
 		$data = [];
 		if (!empty($list)) {
 			foreach ($list as $key => $val) {