|
|
@@ -8,6 +8,7 @@ use bizHd\saas\classes\ApplyClass;
|
|
|
use bizHd\saas\services\ApplyService;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
+use common\components\orderSn;
|
|
|
use common\components\stringUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
@@ -19,14 +20,6 @@ class GhsController extends BaseController
|
|
|
public function actionAdd()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- $mobile = $post['mobile'] ?? '';
|
|
|
- $confirmMobile = $post['confirmMobile'];
|
|
|
- if (stringUtil::isMobile($mobile) == false) {
|
|
|
- util::fail(' 请填写正确的手机号');
|
|
|
- }
|
|
|
- if ($mobile != $confirmMobile) {
|
|
|
- util::fail('二次号码填写不一致');
|
|
|
- }
|
|
|
$name = $post['name'] ?? '';
|
|
|
if (empty($name)) {
|
|
|
util::fail('名称不能为空');
|
|
|
@@ -34,37 +27,39 @@ class GhsController extends BaseController
|
|
|
if (stringUtil::getWordNum($name) > 8) {
|
|
|
util::fail('名称不能超过8个汉字');
|
|
|
}
|
|
|
- $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
|
|
|
- if (!empty($has)) {
|
|
|
-
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- $shopId = $this->shopId;
|
|
|
- $currentShopId = $has['shopId'] ?? 0;
|
|
|
- if (empty($currentShopId)) {
|
|
|
- util::fail('添加失败');
|
|
|
- }
|
|
|
- $hasGhs = GhsClass::getByCondition(['ownShopId' => $this->shopId, 'shopId' => $currentShopId], true);
|
|
|
- if (!empty($hasGhs)) {
|
|
|
- $name = $hasGhs->name ?? '';
|
|
|
- util::fail("手机已添加过了,供货商名称:【{$name}】");
|
|
|
- }
|
|
|
- $ghs = \biz\ghs\classes\GhsClass::build($currentShopId, $shopId, 1);
|
|
|
- $ghs['avatar'] = imgUtil::groupImg($ghs['avatar']);
|
|
|
- $transaction->commit();
|
|
|
- util::success($ghs);
|
|
|
- } catch (\Exception $exception) {
|
|
|
- $transaction->rollBack();
|
|
|
- Yii::info("添加供货商没有成功:" . $exception->getMessage());
|
|
|
- util::fail('添加供货商没有成功');
|
|
|
- }
|
|
|
- util::fail('添加失败,请联系管理员');
|
|
|
- }
|
|
|
+// $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
|
|
|
+// if (!empty($has)) {
|
|
|
+//
|
|
|
+// $connection = Yii::$app->db;
|
|
|
+// $transaction = $connection->beginTransaction();
|
|
|
+// try {
|
|
|
+// $shopId = $this->shopId;
|
|
|
+// $currentShopId = $has['shopId'] ?? 0;
|
|
|
+// if (empty($currentShopId)) {
|
|
|
+// util::fail('添加失败');
|
|
|
+// }
|
|
|
+// $hasGhs = GhsClass::getByCondition(['ownShopId' => $this->shopId, 'shopId' => $currentShopId], true);
|
|
|
+// if (!empty($hasGhs)) {
|
|
|
+// $name = $hasGhs->name ?? '';
|
|
|
+// util::fail("手机已添加过了,供货商名称:【{$name}】");
|
|
|
+// }
|
|
|
+// $ghs = \biz\ghs\classes\GhsClass::build($currentShopId, $shopId, 1);
|
|
|
+// $ghs['avatar'] = imgUtil::groupImg($ghs['avatar']);
|
|
|
+// $transaction->commit();
|
|
|
+// util::success($ghs);
|
|
|
+// } catch (\Exception $exception) {
|
|
|
+// $transaction->rollBack();
|
|
|
+// Yii::info("添加供货商没有成功:" . $exception->getMessage());
|
|
|
+// util::fail('添加供货商没有成功');
|
|
|
+// }
|
|
|
+// util::fail('添加失败,请联系管理员');
|
|
|
+// }
|
|
|
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
+ //获取虚拟手机号
|
|
|
+ $mobile = orderSn::getMobileSn();
|
|
|
$sjId = $this->sjId;
|
|
|
$shopId = $this->shopId;
|
|
|
$sjName = $this->sj->name ?? '';
|