Browse Source

名称已经存在

shish 3 years ago
parent
commit
b0a520805a
1 changed files with 11 additions and 0 deletions
  1. 11 0
      app-ghs/controllers/GhsController.php

+ 11 - 0
app-ghs/controllers/GhsController.php

@@ -28,6 +28,17 @@ class GhsController extends BaseController
         if (stringUtil::getWordNum($name) > 8) {
         if (stringUtil::getWordNum($name) > 8) {
             util::fail('名称不能超过8个汉字');
             util::fail('名称不能超过8个汉字');
         }
         }
+
+        $hasGhsList = GhsClass::getAllByCondition(['ownShopId' => $this->shopId], null, '*', null, true);
+        if (!empty($hasGhsList)) {
+            foreach ($hasGhsList as $hasGhs) {
+                $hasGhsName = $hasGhs->name ?? '';
+                if ($hasGhsName == $name) {
+                    util::fail('名称已经存在了');
+                }
+            }
+        }
+
 //        $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
 //        $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
 //        if (!empty($has)) {
 //        if (!empty($has)) {
 //
 //