Browse Source

Merge branch 'dev-wf' of wugg/useraccount into dev

wufeng 2 years ago
parent
commit
d2bdfec5ca
3 changed files with 757 additions and 0 deletions
  1. 6 0
      app/common.php
  2. 733 0
      app/controller/Headquarters.php
  3. 18 0
      route/app.php

+ 6 - 0
app/common.php

@@ -75,4 +75,10 @@ if(!function_exists("checkToken")){
         }
         return  false;
 	}
+}
+
+if(!function_exists('GetPart')){
+    function GetPart(int $item_id=0){
+        return '';
+    }
 }

+ 733 - 0
app/controller/Headquarters.php

@@ -0,0 +1,733 @@
+<?php
+
+namespace app\controller;
+
+use app\BaseController;
+use app\model\Account;
+use app\model\AccountCompany;
+use think\Exception;
+use think\facade\Db;
+use think\facade\Validate;
+
+//【公司汇总】
+class Headquarters extends BaseController
+{
+
+    //列表
+    public function getList()
+    {
+        try {
+
+            $post = $this->request->only(['code' => '', 'name' => '', 'status' => '', 'page' => 1, 'size' => 10, 'level' => '', 'account_id' => '', 'other'], 'post');
+            $condition = [['is_del', '=', 0]];
+
+            if ($post['code'] != '') $condition[] = ['code', 'like', "%{$post['code']}%"];
+            if ($post['name'] != '') $condition[] = ['name', 'like', "%{$post['name']}%"];
+            if ($post['status'] != '') $condition[] = ['status', '=', $post['status']];
+            if ($post['level'] != '') {
+                $companyCode = Db::name('account_company')
+                    ->where(['account_id' => $post['account_id'], 'is_del' => 0, 'status' => 1])
+                    ->column('companyCode');
+                $condition[] = ['code', 'in', $companyCode];
+            }
+            //兼容原有各个接口的筛选
+            $count = Db::name('headquarters')
+                ->where($condition)
+                ->count('id');
+
+            $list = Db::name('headquarters')
+                ->field('id,code,name,type,status,addtime')
+                ->where($condition)
+                ->page($post['page'], $post['size'])
+                ->order(['addtime' => 'desc', 'id' => 'desc'])
+                ->select()
+                ->toArray();
+
+            return json_show(0, '获取成功', ['list' => $list, 'count' => $count]);
+
+        } catch (Exception $exception) {
+            return json_show(1005, $exception->getMessage());
+        }
+    }
+
+    //添加
+    public function add()
+    {
+        $post = $this->request->filter('trim')->post();
+        Db::startTrans();
+
+        try {
+
+            switch ($post['type']) {
+                case 1:
+                    Db::name('business')->insert($post['data']);
+                    break;
+                case 2:
+                    Db::name('company_info')->insert($post['data']);
+                    break;
+                case 3:
+                    Db::name('supplier')->insert($post['data']);
+                    break;
+            }
+
+            Db::name('headquarters')
+                ->insert([
+                    'code' => $post['code'],
+                    'name' => $post['name'],
+                    'type' => $post['type'],
+                    'invoice_title' => $post['invoice_title'],
+                    'invoice_people' => $post['invoice_people'],
+                    'invoice_addr' => $post['invoice_addr'],
+                    'invoice_code' => $post['invoice_code'],
+                    'invoice_bank' => $post['invoice_bank'],
+                    'invoice_bankNo' => $post['invoice_bankNo'],
+                    'invoice_img' => $post['invoice_img'],
+                    'remark' => $post['remark'],
+                    'status' => $post['status'],
+                    'is_del' => 0,
+                    'creater' => $post['creater'],
+                    'createrid' => $post['createrid'],
+                    'addtime' => date('Y-m-d H:i:s'),
+                    'updater' => $post['updater'],
+                    'updaterid' => $post['updaterid'],
+                    'updater' => date('Y-m-d H:i:s'),
+                ]);
+
+            Db::commit();
+
+            return json_show(0, '添加成功');
+
+        } catch (Exception $e) {
+            Db::rollback();
+            return json_show(1002, '添加失败,' . $e->getMessage());
+        }
+    }
+
+    //编辑
+    public function update()
+    {
+        $post = $this->request->filter('trim')->post();
+
+        Db::startTrans();
+
+        try {
+
+            switch ($post['type']) {
+                case 1:
+                    Db::name('business')->where(['companyNo' => $post['data']['companyNo'], 'is_del' => 0])->update($post['data']);
+                    break;
+                case 2:
+                    Db::name('company_info')->where(['companyNo' => $post['data']['companyNo'], 'is_del' => 0])->update($post['data']);
+                    break;
+                case 3:
+                    Db::name('supplier')->where(['code' => $post['data']['code'], 'is_del' => 0])->update($post['data']);
+                    break;
+            }
+
+            Db::name('headquarters')
+                ->where(['code' => $post['code'], 'is_del' => 0])
+                ->update([
+                    'code' => $post['code'],
+                    'name' => $post['name'],
+                    'type' => $post['type'],
+                    'invoice_title' => $post['invoice_title'],
+                    'invoice_people' => $post['invoice_people'],
+                    'invoice_addr' => $post['invoice_addr'],
+                    'invoice_code' => $post['invoice_code'],
+                    'invoice_bank' => $post['invoice_bank'],
+                    'invoice_bankNo' => $post['invoice_bankNo'],
+                    'invoice_img' => $post['invoice_img'],
+                    'remark' => $post['remark'],
+                    'updater' => $post['updater'],
+                    'updaterid' => $post['updaterid'],
+                    'updater' => date('Y-m-d H:i:s'),
+                ]);
+
+            Db::commit();
+
+            return json_show(0, '修改成功');
+
+        } catch (Exception $e) {
+            Db::rollback();
+            return json_show(1002, '修改失败,' . $e->getMessage());
+        }
+    }
+
+    //详情
+    public function info()
+    {
+        $code = $this->request->post('code', '', 'trim');
+        if ($code == '') return json_show(1003, "参数 code 不能为空");
+
+        $res = Db::name('headquarters')
+            ->field(true)
+            ->where(['code' => $code, 'is_del' => 0])
+            ->findOrEmpty();
+        if (empty($res)) return json_show(1004, '未找到相关汇总信息');
+
+
+        switch ($res['type']) {
+            case 1:
+                $child = Db::name('business')
+                    ->field(true)
+                    ->where(['companyNo' => $code, 'is_del' => 0])
+                    ->findOrEmpty();
+                break;
+            case 2:
+                $child = Db::name('company_info')
+                    ->where(['companyNo' => $code, 'is_del' => 0])
+                    ->findOrEmpty();
+                break;
+            case 3:
+                $child = Db::name('supplier')
+                    ->where(['code' => $code, 'is_del' => 0])
+                    ->findOrEmpty();
+                break;
+        }
+
+        $res['child'] = $child;
+
+        return json_show(0, '获取成功', $res);
+    }
+
+    //删除
+    public function delete()
+    {
+
+        $param = $this->request->only(['ids', 'type', 'updater', 'updaterid'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'ids' => 'require|array|max:100',
+            'type|类别' => 'require|number|in:1,2,3',
+            'updater|操作人' => 'require|max:255',
+            'updaterid|操作人id' => 'require|number|gt:0',
+        ]);
+
+        if (!$val->check($param)) return json_show(1004, $val->getError());
+
+        Db::startTrans();
+
+        try {
+            $date = date('Y-m-d H:i:s');
+
+            $codes = [];
+            switch ($param['type']) {
+                case 1:
+
+                    $where = [['is_del', '=', 0], ['id', 'in', $param['ids']]];
+                    $codes = Db::name('business')->where($where)->column('companyNo');
+                    Db::name('business')->where($where)->update(['is_del' => 1, 'updatetime' => $date]);
+                    break;
+                case 2:
+                    Db::name('company_info')
+                        ->where('is_del', 0)
+                        ->whereIn('companyNo', $param['codes'])
+                        ->update(['is_del' => 1, 'updatetime' => $date]);
+                    break;
+                case 3:
+                    $where = [['is_del', '=', 0], ['id', 'in', $param['ids']]];
+                    $codes = Db::name('supplier')->where($where)->column('code');
+                    Db::name('supplier')->where($where)->update(['is_del' => 1, 'updatetime' => $date]);
+                    break;
+            }
+
+            Db::name('headquarters')
+                ->where('is_del', 0)
+                ->whereIn('code', $codes)
+                ->update([
+                    'is_del' => 1,
+                    'updater' => $param['updater'],
+                    'updaterid' => $param['updaterid'],
+                    'updatetime' => date('Y-m-d H:i:s')
+                ]);
+
+            Db::commit();
+            return json_show(0, '删除成功');
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1005, '删除失败,' . $exception->getMessage());
+        }
+
+    }
+
+    //启禁用
+    public function status()
+    {
+
+        $param = $this->request->only(['id', 'type', 'status', 'updater', 'updaterid'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'id' => 'require|number|gt:0',
+            'type|类别' => 'require|number|in:1,2,3',
+            'status|状态' => 'require|number|in:0,1',
+            'updater|操作人' => 'require|max:255',
+            'updaterid|操作人id' => 'require|number|gt:0',
+        ]);
+
+        if (!$val->check($param)) return json_show(1004, $val->getError());
+
+        Db::startTrans();
+
+        try {
+
+            $date = date('Y-m-d H:i:s');
+
+            $code = '';
+            switch ($param['type']) {
+                case 1:
+                    $tmp = Db::name('business')
+                        ->field('id,companyNo code,status')
+                        ->where(['id' => $param['id'], 'is_del' => 0])
+                        ->findOrEmpty();
+                    if (empty($tmp)) throw new Exception('未找到对应数据');
+                    if ($tmp['status'] == $param['status']) throw new Exception('操作重复');
+
+
+                    Db::name('business')
+                        ->where(['id' => $param['id'], 'is_del' => 0])
+                        ->where('status', '<>', $param['status'])
+                        ->update([
+                            'status' => $param['status'],
+                            'updatetime' => $date
+                        ]);
+                    break;
+                case 2:
+                    Db::name('company_info')
+                        ->where(['companyNo' => $param['data']['companyNo'], 'is_del' => 0])
+                        ->where('status', '<>', $param['status'])
+                        ->update([
+                            'status' => $param['status'],
+                            'updatetime' => $date
+                        ]);
+                    break;
+                case 3:
+                    $tmp = Db::name('supplier')
+                        ->where(['id' => $param['id'], 'is_del' => 0])
+                        ->field('id,code,status')
+                        ->findOrEmpty();
+                    if (empty($tmp)) throw new Exception('该供应商不存在');
+                    if ($tmp['status'] == $param['status']) throw new Exception('操作重复');
+
+                    Db::name('supplier')
+                        ->where(['id' => $param['id'], 'is_del' => 0])
+                        ->where('status', '<>', $param['status'])
+                        ->update([
+                            'status' => $param['status'],
+                            'updatetime' => $date
+                        ]);
+                    break;
+            }
+
+
+            Db::name('headquarters')
+                ->where(['code' => $tmp['code'], 'is_del' => 0])
+                ->where('status', '<>', $param['status'])
+                ->update([
+                    'status' => $param['status'],
+                    'updater' => $param['updater'],
+                    'updaterid' => $param['updaterid'],
+                    'updatetime' => $date
+                ]);
+
+            Db::commit();
+            return json_show(0, '操作成功');
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1005, '操作失败,' . $exception->getMessage());
+        }
+
+    }
+
+
+    //业务企业
+    public function bGetList()
+    {
+        $param = $this->request->only([
+            'page' => 1,
+            'size' => 10,
+            'company' => '',
+            'status' => '',
+            'creater' => '',
+            'start' => '',
+            'end' => '',
+            'company_name' => '',
+        ], 'post', 'trim');
+
+        $where = [['a.is_del', "=", 0]];
+        if ($param['company'] !== "") $where[] = ["a.company", "like", '%' . $param['company'] . '%'];
+        if ($param['status'] !== "") $where[] = ["a.status", '=', $param['status']];
+        if ($param['creater'] !== "") $where[] = ["a.creater", "like", '%' . $param['creater'] . '%'];
+        if ($param['start'] !== "") $where[] = ["a.addtime", '>=', $param['start']];
+        if ($param['end'] !== "") $where[] = ["a.addtime", '<=', $param['end'] . ' 23:59:59'];
+//       if ($param['company_name'] !== "")  $where[] = ["a.createrid", 'in', $param['company_name']];
+
+        $count = Db::name('business')
+            ->alias('a')
+//           ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
+            ->where($where)
+            ->count('a.id');
+
+        $list = Db::name('business')
+            ->alias('a')
+            ->field(true)
+//           ->field('a.*,u.itemid')
+//           ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($param['page'], $param['size'])
+            ->order(['addtime' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+//       $all_codes = Db::name('supplier_contact')
+//           ->whereIn('code', array_column($list, 'code'))
+//           ->column("id,contactor,mobile", 'code');
+
+        //获取开通账号的供应商
+//       $account = checkHasAccountBySupplierNos(array_column($list,'code'));
+
+        foreach ($list as &$value) {
+            $value['company_name'] = '';
+        }
+        return json_show("0", "获取成功", ['list' => $list, 'count' => $count]);
+    }
+
+    public function bCreate()
+    {
+        $param = $this->request->filter('trim')->post('');
+
+        Db::startTrans();
+        try {
+
+            $tmp = Db::name('business')
+                ->field('id')
+                ->where(['company' => $param['company'], 'is_del' => 0])
+                ->findOrEmpty();
+            if (!empty($tmp)) throw new Exception('该公司名称已存在');
+
+            Db::name('business')->insert($param);
+
+            Db::name('headquarters')->insert([
+                'code' => $param['companyNo'],
+                'name' => $param['company'],
+                'type' => 1,
+                'invoice_title' => '',
+                'invoice_people' => '',
+                'invoice_addr' => $param['inv_addr'],
+                'invoice_mobile' => $param['mobile'],
+                'invoice_code' => $param['inv_code'],
+                'invoice_bank' => $param['inv_bank'],
+                'invoice_bankNo' => $param['inv_bankNo'],
+                'invoice_img' => $param['license_img'],
+                'remark' => '',
+                'status' => $param['status'],
+                'is_del' => $param['is_del'],
+                'creater' => $param['creater'],
+                'createrid' => $param['createrid'],
+                'addtime' => $param['addtime'],
+                'updater' => $param['creater'],
+                'updaterid' => $param['createrid'],
+                'updatetime' => $param['updatetime'],
+            ]);
+
+            Db::commit();
+            return json_show(0, '添加成功');
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1003, $exception->getMessage());
+        }
+
+    }
+
+    public function bInfo()
+    {
+        $companyNo = $this->request->post('companyNo', '', 'trim');
+        if ($companyNo == "") return json_show(1004, "参数ompanyNo不能为空");
+
+        $info = Db::name('business')
+            ->alias('a')
+            ->field('a.*,b.company_type')
+            ->leftJoin('company_type b', 'b.id=a.type AND b.is_del=0')
+            ->where(['a.companyNo' => $companyNo, 'a.is_del' => 0])
+            ->findOrEmpty();
+
+        if (empty($info)) return json_show(1002, "未找到数据");
+        return json_show(0, '获取成功', $info);
+    }
+
+    public function bEdit()
+    {
+        $param = $this->request->filter('trim')->post('');
+
+        Db::startTrans();
+        try {
+
+            $info = Db::name('business')
+                ->field('id,companyNo')
+                ->where(['id' => $param['id'], 'is_del' => 0])
+                ->findOrEmpty();
+            if (empty($info)) throw new Exception('未找到数据');
+
+            $tmp = Db::name('business')
+                ->field('id')
+                ->where(['company' => $param['company'], 'is_del' => 0])
+                ->where('id', '<>', $param['id'])
+                ->findOrEmpty();
+            if (!empty($tmp)) throw new Exception('该公司名称已存在');
+
+            Db::name('business')
+                ->where(['id' => $param['id'], 'is_del' => 0])
+                ->update($param);
+
+            Db::name('headquarters')
+                ->where(['code' => $info['companyNo'], 'is_del' => 0])
+                ->update([
+                    'name' => $param['company'],
+                    'type' => 1,
+                    'invoice_title' => '',
+                    'invoice_people' => '',
+                    'invoice_addr' => $param['inv_addr'],
+                    'invoice_mobile' => $param['mobile'],
+                    'invoice_code' => $param['inv_code'],
+                    'invoice_bank' => $param['inv_bank'],
+                    'invoice_bankNo' => $param['inv_bankNo'],
+                    'invoice_img' => $param['license_img'],
+                    'remark' => '',
+                    'status' => $param['status'],
+                    'is_del' => $param['is_del'],
+                    'updater' => $param['creater'],
+                    'updaterid' => $param['createrid'],
+                    'updatetime' => $param['updatetime'],
+                ]);
+
+            Db::commit();
+            return json_show(0, '修改成功');
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1003, $exception->getMessage());
+        }
+
+    }
+
+    public function bTitle()
+    {
+        $param = $this->request->only(['company_type' => '', 'status' => ''], 'post', 'trim');
+        $rs = Db::name('company_type')->where('is_del', 0);
+        if ($param['company_type'] != '') $rs->whereLike('company_type', '%' . $param['company_type'] . '%');
+        if ($param['status'] != '') $rs->where('status', $param['status']);
+
+        $list = $rs->select()->toArray();
+
+        return json_show(0, '获取成功', $list);
+    }
+
+    //供应商
+    public function sGetList()
+    {
+
+        $param = $this->request->only(['page' => 1, 'size' => 10, 'name' => '', 'code' => '', 'creater' => '', 'person' => '', 'status' => '', 'ocr_status' => '', 'start' => '', 'end' => '', 'company_name' => '', 'is_platform' => ''], 'post', 'trim');
+
+        $where = [['s.is_del', "=", 0]];
+        if ($param['name'] !== "") $where[] = ["s.name", "like", '%' . $param['name'] . '%'];
+        if ($param['code'] !== "") $where[] = ["s.code", "like", '%' . $param['code'] . '%'];
+        if ($param['creater'] !== "") $where[] = ["s.creater", "like", '%' . $param['creater'] . '%'];
+        if ($param['person'] !== "") $where[] = ["s.person", "like", '%' . $param['person'] . '%'];
+        if ($param['status'] !== "") $where[] = ["s.status", '=', $param['status']];
+        if ($param['ocr_status'] !== "") $where[] = ["s.ocr_status", '=', $param['ocr_status']];
+        if ($param['start'] !== "") $where[] = ["s.addtime", '>=', $param['start']];
+        if ($param['end'] !== "") $where[] = ["s.addtime", '<=', $param['end'] . ' 23:59:59'];
+        if ($param['is_platform'] !== "") $where[] = ["s.is_platform", '=', $param['is_platform']];
+//       if ($param['company_name'] !== "")  $where[] = ["s.createrid", 'in', $param['company_name']];
+
+        $count = Db::name('supplier')
+            ->alias('s')
+//           ->leftJoin("depart_user u", "u.uid=s.createrid AND u.is_del=0")
+            ->where($where)
+            ->count('s.id');
+
+        $list = Db::name('supplier')
+            ->alias('s')
+            ->field(true)
+//           ->field('s.*,u.itemid')
+//           ->leftJoin("depart_user u", "u.uid=s.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($param['page'], $param['size'])
+            ->order("addtime desc")
+            ->select()
+            ->toArray();
+
+//       $all_codes = Db::name('supplier_contact')
+//           ->whereIn('code', array_column($list, 'code'))
+//           ->column("id,contactor,mobile", 'code');
+
+        //获取开通账号的供应商
+//       $account = checkHasAccountBySupplierNos(array_column($list,'code'));
+
+        foreach ($list as &$value) {
+            $value['company_name'] = '';
+        }
+        return json_show("0", "获取成功", ['list' => $list, 'count' => $count]);
+    }
+
+    public function sCreate()
+    {
+        $param = $this->request->only(['data', 'contact'], 'post', 'trim');
+        $val = Validate::rule([
+            'data|供应商数据' => 'require|array',
+            'contact|联系人' => 'require|array',
+        ]);
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+        Db::startTrans();
+        try {
+
+            $tmp = Db::name('supplier')
+                ->field('id')
+                ->where(['name' => $param['data']['name'], 'is_del' => 0])
+                ->findOrEmpty();
+            if (!empty($tmp)) throw new Exception('该供应商名称已存在');
+
+            $id = Db::name('supplier')->insertGetId($param['data']);
+
+            Db::name('supplier_contact')->insert($param['contact']);
+
+            Db::name('headquarters')->insert([
+                'code' => $param['data']['code'],
+                'name' => $param['data']['name'],
+                'type' => 3,
+                'invoice_title' => '',
+                'invoice_people' => '',
+                'invoice_addr' => '',
+                'invoice_mobile' => $param['contact']['mobile'],
+                'invoice_code' => '',
+                'invoice_bank' => '',
+                'invoice_bankNo' => '',
+                'invoice_img' => $param['data']['license_img'],
+                'remark' => $param['data']['remark'],
+                'status' => $param['data']['status'],
+                'is_del' => $param['data']['is_del'],
+                'creater' => $param['data']['creater'],
+                'createrid' => $param['data']['createrid'],
+                'addtime' => $param['data']['addtime'],
+                'updater' => $param['data']['creater'],
+                'updaterid' => $param['data']['createrid'],
+                'updatetime' => $param['data']['updatetime'],
+            ]);
+
+            Db::commit();
+            return json_show(0, '添加成功', ['id' => $id]);
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1003, $exception->getMessage());
+        }
+
+    }
+
+    public function sInfo()
+    {
+        $code = $this->request->post('code', '', 'trim');
+        if ($code == "") return json_show(1004, "参数code不能为空");
+
+        $info = Db::name('supplier')
+            ->alias('a')
+            ->field('a.*,b.contactor,b.mobile,b.position,b.email,b.telephone')
+            ->leftJoin('supplier_contact b', 'b.code=a.code AND b.is_del=0')
+            ->where(['a.code' => $code, 'a.is_del' => 0])
+            ->findOrEmpty();
+
+        if (empty($info)) return json_show(1002, "未找到数据");
+        return json_show(0, '获取成功', $info);
+    }
+
+    public function sEdit()
+    {
+        $param = $this->request->only(['data', 'contact'], 'post', 'trim');
+        $val = Validate::rule([
+            'data|供应商数据' => 'require|array',
+            'contact|联系人' => 'require|array',
+        ]);
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+        Db::startTrans();
+        try {
+
+            $tmp = Db::name('supplier')
+                ->field('id')
+                ->where(['name' => $param['data']['name'], 'is_del' => 0])
+                ->where('id', '<>', $param['data']['id'])
+                ->findOrEmpty();
+            if (!empty($tmp)) throw new Exception('该供应商名称已存在');
+
+            $id = Db::name('supplier')
+                ->where(['id' => $param['data']['id'], 'is_del' => 0])
+                ->update($param['data']);
+
+            $tmp = Db::name('supplier_contact')
+                ->field('id')
+                ->where(['code' => $param['contact']['code'], 'is_del' => 0])
+                ->findOrEmpty();
+
+            if (empty($tmp)) Db::name('supplier_contact')->insert(array_merge($param['contact'], ['addtime' => $param['contact']['updatetime']]));
+            else Db::name('supplier_contact')->where(['id' => $tmp['id'], 'is_del' => 0])->update($param['contact']);
+
+            Db::name('headquarters')
+                ->where(['code' => $param['data']['code'], 'is_del' => 0])
+                ->update([
+                    'name' => $param['data']['name'],
+                    'type' => 3,
+                    'invoice_title' => '',
+                    'invoice_people' => '',
+                    'invoice_addr' => '',
+                    'invoice_mobile' => $param['contact']['mobile'],
+                    'invoice_code' => '',
+                    'invoice_bank' => '',
+                    'invoice_bankNo' => '',
+                    'invoice_img' => $param['data']['license_img'],
+                    'remark' => $param['data']['remark'],
+                    'is_del' => $param['data']['is_del'],
+                    'updater' => $param['data']['creater'],
+                    'updaterid' => $param['data']['createrid'],
+                    'updatetime' => $param['data']['updatetime'],
+                ]);
+
+            Db::commit();
+            return json_show(0, '修改成功', ['id' => $id]);
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(1003, $exception->getMessage());
+        }
+
+    }
+
+    public function cTitle()
+    {
+        $param = $this->request->only([
+            'page' => 1,
+            'size' => 10,
+            'companyNo' => '',
+            'companyName' => '',
+            'itemid' => '',
+        ], 'post', 'trim');
+
+        $where [] = ['is_del', "=", 0];
+        if ($param['companyNo'] != '') $where[] = ['companyNo', 'like', '%' . $param['companyNo'] . '%'];
+        if ($param['companyName'] != '') $where[] = ['companyName', 'like', '%' . $param['companyName'] . '%'];
+        if ($param['itemid'] != '') $where[] = ['itemid', '=', $param['itemid']];
+
+        $count = Db::name('customer_info')
+            ->where($where)
+            ->count('id');
+
+        $item = Db::name('customer_info')
+            ->where($where)
+            ->field("id,companyNo,companyName,LENGTH(companyName) as weight")
+            ->order(['weight' => 'asc', 'id' => 'desc'])
+            ->page($param['page'], $param['size'])
+            ->select()
+            ->toArray();
+
+        return json_show(0, "获取成功", ['item' => $item, 'count' => $count]);
+
+    }
+
+
+}

+ 18 - 0
route/app.php

@@ -37,3 +37,21 @@ Route::rule('userCompanyList', 'admin/UserCompany/getList');
 Route::rule('userCompanyInfo', 'admin/UserCompany/info');
 Route::rule('userCompanyUpdate', 'admin/UserCompany/update');
 Route::rule('userCompanyStatus', 'admin/UserCompany/status');
+
+//公司汇总
+Route::rule('hqAdd', 'Headquarters/add');
+Route::rule('hqList', 'Headquarters/getList');
+Route::rule('hqUpdate', 'Headquarters/update');
+Route::rule('hqInfo', 'Headquarters/info');
+Route::rule('bGetList', 'Headquarters/bGetList');
+Route::rule('bCreate', 'Headquarters/bCreate');
+Route::rule('bInfo', 'Headquarters/bInfo');
+Route::rule('bEdit', 'Headquarters/bEdit');
+Route::rule('bTitle', 'Headquarters/bTitle');
+Route::rule('sGetList', 'Headquarters/sGetList');
+Route::rule('sCreate', 'Headquarters/sCreate');
+Route::rule('sInfo', 'Headquarters/sInfo');
+Route::rule('sEdit', 'Headquarters/sEdit');
+Route::rule('cTitle', 'Headquarters/cTitle');
+Route::rule('delete', 'Headquarters/delete');
+Route::rule('status', 'Headquarters/status');