| 12345678910111213141516171819202122232425262728293031323334 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\commands;
- use yii\console\Controller;
- use yii\console\ExitCode;
- use app\models\User;
- class UserController extends Controller
- {
- /**
- * 重建用户关系
- * @return int Exit code
- */
- public function actionRebuild()
- {
- $stores = User::find()->select('store_id')->groupBy('store_id')->asArray()->all();
- foreach ($stores as $store) {
- $users = User::find()->where(['store_id' => $store['store_id']])->all();
- foreach ($users as $user) {
- echo 'store_id:' . $store['store_id'] . ' user_id:' . $user->id . ' => 重建中' . PHP_EOL;
- $user->rebuildTreePath();
- $user->getBehavior('oldTreePath')->rebuildTreePath();
- echo 'store_id:' . $store['store_id'] . ' user_id:' . $user->id . ' => 重建完成' . PHP_EOL;
- }
- }
- return ExitCode::OK;
- }
- }
|