$name, 'mobile' => $mobile]; } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); if (getenv('YII_ENV') == 'production') { $masterShopId = 4892; } else { $masterShopId = 36523; } $master = ShopClass::getById($masterShopId, true); if (empty($master)) { util::stop('没有找到主人的门店'); } if (empty($customList)) { util::stop('没有需要添加的客户'); } try { foreach ($customList as $info) { $shopName = $info['name'] ?? ''; $mobile = $info['mobile'] ?? 0; $post = []; $post['introSjId'] = $master->sjId ?? 0; $post['introShopId'] = $master->id ?? 0; $post['introSjName'] = $master->merchantName ?? ''; $post['introStyle'] = SjClass::STYLE_SUPPLIER; $post['name'] = $shopName; $post['mobile'] = $mobile; if (empty($shopName)) { $transaction->rollBack(); util::stop('1'); } if (stringUtil::isMobile($mobile) == false) { $transaction->rollBack(); util::stop('2'); } if (stringUtil::getWordNum($shopName) > 8) { $transaction->rollBack(); util::stop('3'); } $has = ApplyClass::getByCondition(['mobile' => $mobile]); if (!empty($has)) { $transaction->rollBack(); util::stop('4'); } $hasShop = ShopClass::getByCondition(['mobile' => $mobile]); if (!empty($hasShop)) { $transaction->rollBack(); util::stop('5'); } $adminName = $post['adminName'] ?? ''; $miniOpenId = $post['miniOpenId'] ?? ''; $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId]; $fromApp = dict::getDict('userSourceGetId', 'app', 'id'); $admin = AdminClass::replaceAdmin($adminInfo, $fromApp); $adminId = $admin['id'] ?? 0; $post['adminId'] = $adminId; $post['adminName'] = $admin['name'] ?? ''; $post['long'] = isset($post['longitude']) ? $post['longitude'] : ''; $post['lat'] = isset($post['latitude']) ? $post['latitude'] : ''; $post['from'] = ApplyClass::FROM_RETAIL; $post['style'] = SjClass::STYLE_RETAIL; //增加或更新申请 $respond = ApplyService::replaceRetail($post); $id = $respond['id'] ?? 0; //后继代码,要用到此参数 Yii::$app->params['ptStyle'] = 2; ApplyService::pass($id, '批发商手动添加'); } $transaction->commit(); } catch (\Exception $exception) { $transaction->rollBack(); } } }