Ver Fonte

细节优化

wufeng há 2 anos atrás
pai
commit
c75547df13
2 ficheiros alterados com 13 adições e 10 exclusões
  1. 12 9
      app/controller/CompanyItem.php
  2. 1 1
      app/controller/Headquarters.php

+ 12 - 9
app/controller/CompanyItem.php

@@ -148,7 +148,7 @@ class CompanyItem extends BaseController
     public function update()
     {
 
-        $param = $this->request->only(['id', 'companyNo', 'name', 'pid', 'level' => 1, 'weight' => 1,], 'post', 'trim');
+        $param = $this->request->only(['id', 'companyNo', 'name', 'pid', 'level' => 1, 'weight' => 1], 'post', 'trim');
 
         $val = Validate::rule([
             'id' => 'require|number|gt:0',
@@ -236,14 +236,17 @@ class CompanyItem extends BaseController
             ->field('companyNo')
             ->where($where)
             ->group('companyNo')
-            ->buildSql();
+            ->column('companyNo');
 
-        $company = Db::name('headquarters')
-            ->field('id,code,name,type')
-            ->where('is_del', 0)
-            ->where('code IN ' . $companyNo)
-            ->select()
-            ->toArray();
+        $company_1 = Db::name('headquarters')
+            ->where(['is_del' => 0, 'code' => $companyNo])
+            ->column('id,code,name,type', 'code');
+
+        $company_2 = Db::name('headquarters')
+            ->where(['is_del' => 0, 'relation_code' => $companyNo])
+            ->column('id,relation_code code,name,type', 'relation_code');
+
+        $company = array_merge($company_1, $company_2);
 
         foreach ($company as &$value) {
             $value['child'] = Db::name('company_item')
@@ -257,7 +260,7 @@ class CompanyItem extends BaseController
             }
         }
 
-        return json_show(0, '获取成功', $company);
+        return json_show(0, '获取成功', array_values($company));
 
     }
 

+ 1 - 1
app/controller/Headquarters.php

@@ -456,7 +456,7 @@ class Headquarters extends BaseController
     public function bInfo()
     {
         $companyNo = $this->request->post('companyNo', '', 'trim');
-        if ($companyNo == "") return json_show(1004, "参数ompanyNo不能为空");
+        if ($companyNo == "") return json_show(1004, "参数companyNo不能为空");
 
         $info = Db::name('business')
             ->alias('a')