|
|
@@ -33,25 +33,32 @@ class ShopAdminController extends BaseController
|
|
|
if (getenv('YII_ENV', 'local') == 'production') {
|
|
|
util::fail('生产环境不能执行删除操作');
|
|
|
}
|
|
|
- $adminId = $shopAdmin['adminId'] ?? 0;
|
|
|
- $sjId = $shopAdmin['merchantId'] ?? 0;
|
|
|
- $sj = SjClass::getById($sjId, true);
|
|
|
- if (!empty($sj)) {
|
|
|
- $sj->delete();
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $adminId = $shopAdmin['adminId'] ?? 0;
|
|
|
+ $sjId = $shopAdmin['merchantId'] ?? 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();
|
|
|
+ }
|
|
|
+ util::complete();
|
|
|
+ } catch (Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail("删除失败");
|
|
|
}
|
|
|
- $apply = ApplyClass::getByCondition(['sjId' => $sjId], true);
|
|
|
- if (!empty($apply)) {
|
|
|
- $apply->delete();
|
|
|
- }
|
|
|
- $admin = AdminClass::getById($adminId);
|
|
|
- if (!empty($admin)) {
|
|
|
- $admin->delete();
|
|
|
- }
|
|
|
- $shopAdmin = ShopAdminClass::getById($id);
|
|
|
- if (!empty($shopAdmin)) {
|
|
|
- $shopAdmin->delete();
|
|
|
- }
|
|
|
- util::complete();
|
|
|
}
|
|
|
|
|
|
}
|