| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace console\controllers;
- use biz\admin\classes\AdminClass;
- use biz\ghs\classes\GhsClass;
- use biz\shop\classes\ShopAdminClass;
- use biz\shop\classes\ShopClass;
- use biz\sj\classes\SjClass;
- use bizGhs\custom\classes\CustomClass;
- use bizHd\saas\classes\ApplyClass;
- use common\components\util;
- use yii\console\Controller;
- class SjController extends Controller
- {
- // 删除账号 ssh 2021.2.27
- // ./yii sj/del 17061583291 15280215347
- // ./yii.bat sj/del 17061583291 15280215347
- public function actionDel()
- {
- if (getenv('YII_ENV') == 'production') {
- echo "线上不允许操作";
- util::stop();
- }
- global $argv;
- foreach ($argv as $key => $item) {
- if ($key > 1) {
- $mobile = $item;
- $shopList = ShopClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
- if (!empty($shopList)) {
- foreach ($shopList as $shop) {
- $merchantName = $shop->merchantName ?? '';
- if (!empty($merchantName)) {
- SjClass::deleteByCondition(['name' => $merchantName]);
- }
- $sjId = $shop->sjId ?? 0;
- $shop->delete();
- if (!empty($sjId)) {
- $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();
- }
- }
- }
- }
- }
- }
- ApplyClass::deleteByCondition(['mobile' => $mobile]);
- $adminList = AdminClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
- if (!empty($adminList)) {
- foreach ($adminList as $admin) {
- $adminId = $admin->id ?? 0;
- ShopAdminClass::deleteByCondition(['adminId' => $adminId]);
- $admin->delete();
- }
- }
- }
- }
- }
- }
|