|
|
@@ -0,0 +1,65 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace console\controllers;
|
|
|
+
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
+use biz\stat\classes\StatItemClass;
|
|
|
+use biz\stat\classes\StatItemMonthClass;
|
|
|
+use yii\console\Controller;
|
|
|
+use Yii;
|
|
|
+
|
|
|
+class StatItemController extends Controller
|
|
|
+{
|
|
|
+
|
|
|
+ // ./yii stat-item/bc
|
|
|
+ public function actionBc()
|
|
|
+ {
|
|
|
+
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $list = ShopClass::getAllByCondition(['id>' => 0], null, '*', 'id');
|
|
|
+ $map = [];
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $shopId => $shop) {
|
|
|
+ $mainId = $shop['mainId'] ?? 0;
|
|
|
+ $map[$shopId] = $mainId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $statList = StatItemClass::getAllByCondition(['id>' => 0], null, '*', null, true);
|
|
|
+ if (!empty($statList)) {
|
|
|
+ foreach ($statList as $stat) {
|
|
|
+ $currentMainId = $stat->mainId ?? 0;
|
|
|
+ if (!empty($currentMainId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $currentShopId = $stat->shopId ?? 0;
|
|
|
+ if (empty($currentShopId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $newMainId = $map[$currentShopId] ?? 0;
|
|
|
+ $stat->mainId = $newMainId;
|
|
|
+ $stat->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $statList = StatItemMonthClass::getAllByCondition(['id>' => 0], null, '*', null, true);
|
|
|
+ if (!empty($statList)) {
|
|
|
+ foreach ($statList as $stat) {
|
|
|
+ $currentMainId = $stat->mainId ?? 0;
|
|
|
+ if (!empty($currentMainId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $currentShopId = $stat->shopId ?? 0;
|
|
|
+ if (empty($currentShopId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $newMainId = $map[$currentShopId] ?? 0;
|
|
|
+ $stat->mainId = $newMainId;
|
|
|
+ $stat->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|