Jelajahi Sumber

统计相关更新

shish 6 tahun lalu
induk
melakukan
14a0e33e79

+ 13 - 0
biz/stat/classes/StatOrderMonthClass.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\stat\classes;
+
+use Yii;
+use biz\base\classes\BaseClass;
+
+class StatOrderMonthClass extends BaseClass
+{
+	
+	public static $baseFile = '\biz\stat\models\StatOrderMonth';
+
+}

+ 13 - 0
biz/stat/models/StatOrderMonth.php

@@ -0,0 +1,13 @@
+<?php
+namespace biz\stat\models;
+use biz\base\models\Base;
+
+class StatOrderMonth extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhStatOrderMonth';
+	}
+
+}

+ 13 - 0
biz/stat/services/StatOrderMonthService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\stat\services;
+
+use biz\base\services\BaseService;
+use Yii;
+
+class StatOrderMonthService extends BaseService
+{
+	
+	public static $baseFile = '\biz\stat\classes\StatOrderMonthClass';
+	
+}

+ 99 - 1
console/controllers/UpgradeController.php

@@ -10,6 +10,12 @@ use biz\merchant\services\MerchantExtendService;
 use biz\merchant\services\MerchantService;
 use biz\order\services\OrderGoodsService;
 use biz\order\services\OrderService;
+use biz\stat\models\StatOrderMonth;
+use biz\stat\services\StatIncomeMonthService;
+use biz\stat\services\StatIncomeSourceMonthService;
+use biz\stat\services\StatIncomeSourceService;
+use biz\stat\services\StatOrderMonthService;
+use biz\stat\services\StatOrderService;
 use biz\user\services\UserAssetService;
 use biz\user\services\UserCapitalService;
 use biz\user\services\UserGrowthService;
@@ -826,7 +832,52 @@ ALTER TABLE `xhMerchantCapital` MODIFY `io` TINYINT NOT NULL DEFAULT 0 COMMENT '
 		}
 		$sql = "ALTER TABLE `xhUserGrowth` MODIFY `relateId` INT NOT NULL DEFAULT 0 COMMENT '关联id';";
 		Yii::$app->db->createCommand($sql)->execute();
-
+		
+		
+		//统计相关
+		//xhStatIncomeMonth
+		$list = StatIncomeMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatIncomeMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatIncomeSourceMonth
+		$list = StatIncomeSourceMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatIncomeSourceMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatOrder
+		$list = StatOrderService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$id = $val['id'];
+				$date = date("Ymd", $val['time']);
+				StatOrderService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatOrderMonth
+		$list = StatOrderMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatOrderMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		
 		if ($num == 2) {
 			$this->actionInit2();
 		}
@@ -926,11 +977,58 @@ ALTER TABLE `xhMerchantCapital` MODIFY `io` TINYINT NOT NULL DEFAULT 0 COMMENT '
 			}
 		}
 		
+		
 	}
 	
 	//重新拉取并保存国兰客户的头像和图片 shish 2020.1.12
 	public function actionSyncAvatar()
 	{
+		
+		//统计相关
+		//xhStatIncomeMonth
+		$list = StatIncomeMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatIncomeMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatIncomeSourceMonth
+		$list = StatIncomeSourceMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatIncomeSourceMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatOrder
+		$list = StatOrderService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$id = $val['id'];
+				$date = date("Ymd", $val['time']);
+				StatOrderService::updateById($id, ['time' => $date]);
+			}
+		}
+		//xhStatOrderMonth
+		$list = StatOrderMonthService::getAllByCondition([], null, '*');
+		if (!empty($list)) {
+			foreach ($list as $val) {
+				$year = $val['year'];
+				$month = $val['month'];
+				$date = date("Ym", strtotime($year . '-' . $month . '-' . '1'));
+				$id = $val['id'];
+				StatOrderMonthService::updateById($id, ['time' => $date]);
+			}
+		}
+		die;
+		
 		UserService::syncAvatar(12358);
 	}
 	

+ 0 - 1
sql2.txt

@@ -1 +0,0 @@
-统计表的变更 注意线上哪些统计相关的表有数据,要转化(注意里面涉及的表)!!!