| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?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();
- }
- }
- }
- }
|