request->get('id'); $shopAdmin = ShopAdminClass::getAdminInfo($id); if (empty($shopAdmin)) { util::fail('没有找到员工'); } if (getenv('YII_ENV', 'local') == 'production') { util::fail('生产环境不能执行删除操作'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $adminId = $shopAdmin['adminId'] ?? 0; $sjId = $shopAdmin['sjId'] ?? 0; $sj = SjClass::getById($sjId, true); if (!empty($sj)) { $sj->delete(); } $apply = ApplyClass::getByCondition(['sjId' => $sjId], true); if (!empty($apply)) { $apply->delete(); } $admin = AdminClass::getById($adminId, true); if (!empty($admin)) { $admin->delete(); } $shopAdmin = ShopAdminClass::getById($id, true); if (!empty($shopAdmin)) { $shopAdmin->delete(); } $ghsList = GhsClass::getAllByCondition(['ownSjId' => $sjId], null, '*', null, true); if (!empty($ghsList)) { foreach ($ghsList as $ghs) { $customId = $ghs->customId; $ghs->delete(); $current = CustomClass::getById($customId, true); if (!empty($current)) { $current->delete(); } } } $customList = CustomClass::getAllByCondition(['ownSjId' => $sjId], null, '*', null, true); if (!empty($customList)) { foreach ($customList as $custom) { $ghsId = $custom->ghsId; $custom->delete(); $current = GhsClass::getById($ghsId, true); if (!empty($current)) { $current->delete(); } } } $transaction->commit(); util::complete(); } catch (Exception $exception) { $transaction->rollBack(); util::fail("删除失败"); } } }