wang jun 3 years ago
parent
commit
3bc49ca5fc
2 changed files with 19 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 18 1
      application/index/logic/companylogic.php

+ 1 - 0
.gitignore

@@ -5,3 +5,4 @@
 thinkphp
 .env
 .DS_Store
+**/unuse

+ 18 - 1
application/index/logic/companylogic.php

@@ -24,6 +24,8 @@ class companylogic extends baselogic
         $list = [
             'newinfo' => [
                 ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+                ['name' => 'organization_code', 'title' => 'organization_code', 'type' => 'string'],
+                ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'],
             ],
             'getinfobyid' => [
                 ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
@@ -60,7 +62,22 @@ class companylogic extends baselogic
             return backarr(0, "非企业用户");
         }
         unset($arr['openid']);
-        $id = $m_c->insertData($arr);
+        $where = [];
+        $cinfo = [];
+        if (isset($arr['organization_code'])) {
+            $where['organization_code'] = $arr['organization_code'];
+        }
+        if (isset($arr['companyname'])) {
+            $where['companyname'] = $arr['companyname'];
+        }
+        if (empty(!$where)) {
+            $cinfo = $m_c->getinfo($where, ['id']);
+        }
+        if (empty($cinfo)) {
+            $id = $m_c->insertData($arr);
+        } else {
+            $id = $cinfo['id'];
+        }
         $updateDate = ['company_id' => $id];
         $row = $m_u->updatebyid($info['id'], $updateDate);
         return backarr(1, "新增成功", ['id' => $id]);