Просмотр исходного кода

Merge branch 'master-new-dev-wf' of wugg/phpstock into master-new

wufeng 2 лет назад
Родитель
Сommit
c762cee8e7

+ 12 - 5
app/abutment/controller/Consult.php

@@ -2,6 +2,7 @@
 
 namespace app\abutment\controller;
 
+use app\admin\common\User;
 use app\admin\model\ActionLog;
 use app\admin\model\ProcessOrder;
 use think\facade\Db;
@@ -162,7 +163,9 @@ class Consult extends HomeBaseController
             $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo'] : "";
         }
         if ($zxorder['depart'] > 0) {
-            $zxinfo['departinfo'] = GetPart($zxorder['depart']);
+            $userCommon = new User();
+            $rs = $userCommon->handle('ciinfo', ['id' => $zxorder['depart']]);
+            $zxinfo['departinfo'] = $rs['data'] ?? [];
         }
         if ($zxorder['platform_code'] > 0) {
             $palt = Db::name("platform")->where(["id" => $zxorder['platform_code']])->find();
@@ -549,13 +552,17 @@ class Consult extends HomeBaseController
         $page = $page >= $total ? $total : $page;
         $list = Db::name('consult_bids')
             ->alias('cb')
-            ->field('cb.*,u.itemid')
-            ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
+            ->field('cb.*')
             ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
             ->where($where)
             ->page($page, $size)
             ->order('cb.addtime', 'desc')
-            ->cursor();
+            ->select()
+            ->toArray();
+
+        $all_createrid = array_column($list,'createrid');
+        $item = get_company_name_by_uid($all_createrid);
+
         $data = [];
         foreach ($list as $value) {
             $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
@@ -624,7 +631,7 @@ class Consult extends HomeBaseController
 //                $addr= GetAddr(json_encode($temp));
 //                $value['origin_addr'] = $addr;
 //            }
-            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $value['company_name'] = $item[$value['createrid']] ?? '';
             $data[] = $value;
         }
         return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);

+ 12 - 7
app/abutment/controller/Good.php

@@ -143,13 +143,15 @@ class Good extends HomeBaseController
         $page = $page >= $total ? $total : $page;
         $list = Db::name('good_basic')
             ->alias('gb')
-            ->field('gb.*,u.itemid')
-            ->leftJoin("depart_user u", "u.uid=gb.chargerid AND u.is_del=0")
             ->where($where)
             ->page($page, $size)
             ->order("addtime desc")
             ->select()
             ->toArray();
+
+        $all_createrid = array_column($list,'chargerid');
+        $item = get_company_name_by_uid($all_createrid);
+
         $data = [];
 
         //查询一下这些spucode是否在平台上成功上线
@@ -178,7 +180,7 @@ class Good extends HomeBaseController
             //如果一个spucode在任意平台上线,那么就视为它上线,即手动把它的is_online值改为1
             if (isset($exam_statuss[$value['spuCode']]) || isset($exam_status_yz[$value['spuCode']])) $value['is_online'] = 1;
 
-            $value['charger_company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $value['charger_company_name'] = $item[$value['chargerid']]??'';
 
             $data[] = $value;
         }
@@ -1510,14 +1512,17 @@ class Good extends HomeBaseController
         $where[] = ['g.id', 'in', $ids];
         $list = Db::name("gold_price1")
             ->alias('g')
-            ->field('g.*,u.itemid')
-            ->leftJoin("depart_user u", "u.uid=g.action_id AND u.is_del=0")
             ->where($where)
-            ->cursor();
+            ->select()
+            ->toArray();
+
+        $all_createrid = array_column($list,'action_id');
+        $item = get_company_name_by_uid($all_createrid);
+
         $data = [];
         foreach ($list as $value) {
             $value['type_cn'] = $this->gold[$value['type']];
-            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $value['company_name'] = $item[$value['action_id']]??'';
             $data[] = $value;
         }
         return json_show(0, "获取成功", $data);

+ 16 - 12
app/abutment/controller/Index.php

@@ -89,17 +89,19 @@ class Index extends HomeBaseController
         $page = $page >= $total ? $total : $page;
         $list = Db::name('brand')
             ->alias('b')
-            ->field('b.*,u.itemid')
-            ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
             ->where($where)
-            ->append(['company_name'])
-            ->withAttr('company_name', function ($val, $data) {
-                return implode('/', array_column(GetPart($data['itemid']), 'name'));
-            })
             ->page($page, $size)
             ->order("addtime desc,id desc")
             ->select()
             ->toArray();
+
+        $all_createrid = array_column($list,'createrid');
+        $item = get_company_name_by_uid($all_createrid);
+
+        foreach ($list as &$value){
+            $value['company_name']=$item[$value['createrid']]??'';
+        }
+
         return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
     }
 
@@ -207,16 +209,18 @@ class Index extends HomeBaseController
             ->alias('b')
             ->where($where)
             ->page($page, $size)
-            ->field("b.id,b.company,b.companyNo,b.status,b.creater,b.addtime,b.type,u.itemid")
-            ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
+            ->field("b.id,b.company,b.companyNo,b.status,b.creater,b.addtime,b.type")
             ->order("addtime desc")
-            ->append(['company_name'])
-            ->withAttr('company_name', function ($val, $data) {
-                return implode('/', array_column(GetPart($data['itemid']), 'name'));
-            })
             ->select()
             ->toArray();
 
+        $all_createrid = array_column($list, 'createrid');
+        $item = get_company_name_by_uid($all_createrid);
+
+        foreach ($list as &$value) {
+            $value['company_name'] = $item[$value['createrid']] ?? '';
+        }
+
         return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
     }
 

+ 7 - 4
app/abutment/controller/Order.php

@@ -134,15 +134,18 @@ class Order extends HomeBaseController
             ->alias('po')
             ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
             ->leftJoin('sale s', 's.orderCode=on.orderCode')
-            ->leftJoin("depart_user u", "u.uid=po.cgder_id AND u.is_del=0")
-            ->field('po.*,on.orderCode,u.itemid')
+            ->field('po.*,on.orderCode')
             ->where($where)
             ->where(function ($query) use ($where) {
                 $query->whereOr([['po.order_type', '<>', 1], ['po.order_source', '=', 0]]);
             })
             ->page($page, $size)
             ->order("po.addtime desc")
-            ->cursor();
+            ->select()
+            ->toArray();
+
+        $all_createrid = array_column($list,'cgder_id');
+        $item = get_company_name_by_uid($all_createrid);
 
         $data = [];
         foreach ($list as $value) {
@@ -193,7 +196,7 @@ class Order extends HomeBaseController
             $value['total_fee'] = round($value['total_fee'] - $value['th_fee'], 2);
             //补充orderCode
 //            $value['orderCode']=isset($all_orderCodes[$value['cgdNo']])?$all_orderCodes[$value['cgdNo']]:'';
-            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $value['company_name'] = $item[$value['cgder_id']]??'';
             $data[] = $value;
         }
         return json_show(0, "获取成功", ["list" => $data, "count" => $count]);

+ 6 - 3
app/abutment/controller/Sale.php

@@ -108,13 +108,16 @@ class Sale extends HomeBaseController
             ->join("warehouse_info n", "n.wsm_code=a.wsm_code AND n.is_del=0", "left")
             ->leftJoin("order_send os", "os.outCode=a.outCode")
             ->leftJoin("purchease_order wpo", "wpo.cgdNo=os.cgdNo")
-            ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
             ->field("a.*,b.order_type,b.order_source,b.good_name,b.good_code,b.skuCode,b.supplierNo,b.customer_code,v.companyName,b.origin_price,b.sale_price,b.total_price,os.cgdNo,u.itemid")
             ->where($where)
 //            ->where($condition)
             ->order("addtime desc")
             ->page($page, $size)
-            ->cursor();
+            ->select()
+            ->toArray();
+
+        $all_createrid = array_column($list,'apply_id');
+        $item = get_company_name_by_uid($all_createrid);
 
         $data = [];
         foreach ($list as $value) {
@@ -141,7 +144,7 @@ class Sale extends HomeBaseController
             $value['contactor'] = isset($addr['contactor']) ? $addr['contactor'] : "";
             $value['mobile'] = isset($addr['mobile']) ? $addr['mobile'] : "";
             $value['can'] = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
-            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $value['company_name'] = $item[$value['apply_id']]??'';
             $value['sendtime'] = $value['status'] < 2 ? '' : $value['sendtime'];
             $data[] = $value;
         }

+ 252 - 143
app/admin/controller/Orderuse.php

@@ -2,170 +2,279 @@
 
 namespace app\admin\controller;
 
-use app\BaseController;
 use think\App;
 use think\facade\Db;
+use think\facade\Validate;
 
 //订单用途
-class Orderuse extends BaseController
+class Orderuse extends Base
 {
-    public $post="";
-    public function __construct(App $app)
+
+    public function create()
     {
-        parent::__construct($app);
-        $this->post=$this->request->post();
-    }
-    public function create(){
-        $order_use = isset($this->post['order_use']) && $this->post['order_use']!=="" ? trim($this->post['order_use']):"";
-        if($order_use==""){
-            return error_show(1002,"参数order_use不能为空");
-        }
-        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
-        if($token==''){
-            return error_show(1005,"参数token不能为空");
-        }
-        $user =GetUserInfo($token);
-        if(empty($user)||$user['code']!=0){
-            return error_show(1002,"创建人数据不存在");
-        }
-        $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
-        $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
-        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"0";
-        $data =[
-            "order_use"=>$order_use,
-            "creater"=>$creater,
-            "createrid"=>$createrid,
-            "status"=>0,
-            "is_del"=>0,
-            "addtime"=>date("Y-m-d H:i:s"),
-            "updatetime"=>date("Y-m-d H:i:s")
-        ];
-        $datainfo = Db::name('order_use')->insert($data);
-        if($datainfo){
-            return error_show(0,"新建成功");
-        }else{
-            return error_show(1002,"新建失败");
-        }
+
+        $param = $this->request->only(['companyNo', 'companyName', 'order_use'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'companyNo|公司编码' => 'require|length:18',
+            'companyName|公司名称' => 'require|max:255',
+            'order_use|订单用途' => 'require|max:255',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+//        $order_use = isset($this->post['order_use']) && $this->post['order_use']!=="" ? trim($this->post['order_use']):"";
+//        if($order_use==""){
+//            return error_show(1002,"参数order_use不能为空");
+//        }
+//        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
+//        if($token==''){
+//            return error_show(1005,"参数token不能为空");
+//        }
+//        $user =GetUserInfo($token);
+//        if(empty($user)||$user['code']!=0){
+//            return error_show(1002,"创建人数据不存在");
+//        }
+//        $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+//        $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+//        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"0";
+//        $data =[
+//            "order_use"=>$order_use,
+//            "creater"=>$creater,
+//            "createrid"=>$createrid,
+//            "status"=>0,
+//            "is_del"=>0,
+//            "addtime"=>date("Y-m-d H:i:s"),
+//            "updatetime"=>date("Y-m-d H:i:s")
+//        ];
+
+        $tmp = Db::name('order_use')
+            ->field('id')
+            ->where([
+                'is_del' => 0,
+                'companyNo' => $param['companyNo'],
+                'order_use' => $param['order_use'],
+            ])
+            ->findOrEmpty();
+        if (!empty($tmp)) return json_show(1004, '同一公司下该订单用途已存在');
+
+        $datainfo = Db::name('order_use')->insert([
+            "companyNo" => $param['companyNo'],
+            "companyName" => $param['companyName'],
+            "order_use" => $param['order_use'],
+            "creater" => $this->uname,
+            "createrid" => $this->uid,
+            "status" => 0,
+            "is_del" => 0,
+            "addtime" => date("Y-m-d H:i:s"),
+            "updatetime" => date("Y-m-d H:i:s")
+        ]);
+
+        return $datainfo ? app_show(0, "新建成功") : error_show(1002, "新建失败");
+//        if($datainfo){
+//            return error_show(0,"新建成功");
+//        }else{
+//            return error_show(1002,"新建失败");
+//        }
     }
-    public function list(){
-        $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
-        $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
-        $where =[['ou.is_del',"=",0]];
-        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
-        if($status !==""){
-            $where [] = ['ou.status',"=",$status];
-        }
-        $order_use = isset($this->post['order_use']) && $this->post['order_use'] !=="" ? trim($this->post['order_use']):"";
-        if($order_use !==""){
-            $where [] =['ou.order_use',"like","%$order_use%"];
-        }
-        $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
-        if($creater !==""){
-            $where [] =['ou.creater',"like","%$creater%"];
-        }
-        $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
-        if($start!==""){
-            $where[]=['ou.addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
-        }
-        $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
-        if($end!==""){
-            $where[]=['ou.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
-        }
-        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
-        if ($company_name !== "") $where[] = ["ou.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+    public function list()
+    {
+
+        $param = $this->request->only([
+            'page' => 1,
+            'size' => 10,
+            'status' => '',
+            'order_use' => '',
+            'creater' => '',
+            'start' => '',
+            'end' => '',
+            'company_name' => '',
+            'companyNo' => '',
+        ], 'post', 'trim');
+
+//        $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
+//        $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
+        $where = [['is_del', "=", 0]];
+//        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($param['status'] !== "") $where [] = ['status', "=", $param['status']];
+
+//        $order_use = isset($this->post['order_use']) && $this->post['order_use'] !== "" ? trim($this->post['order_use']) : "";
+        if ($param['order_use'] !== "") $where [] = ['order_use', "like", '%' . $param['order_use'] . '%'];
+
+//        $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
+        if ($param['creater'] !== "") $where [] = ['creater', "like", '%' . $param['creater'] . '%'];
+
+//        $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
+        if ($param['start'] !== "") $where[] = ['addtime', ">=", date('Y-m-d H:i:s', strtotime($param['start']))];
+
+//        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
+        if ($param['end'] !== "") $where[] = ['addtime', "<", date('Y-m-d H:i:s', strtotime($param['end']) + 24 * 3600)];
+
+//        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($param['company_name'] !== "") $where[] = ["createrid", 'in', get_company_item_user_by_name($param['company_name'])];
+        if ($param['companyNo'] !== "") $where[] = ["companyNo", '=', $param['companyNo']];
 
         $count = Db::name('order_use')
-            ->alias('ou')
             ->where($where)
-            ->count();
-        $total = ceil($count / $size);
-        $page = $page >= $total ? $total :$page;
+            ->count('id');
+
         $list = Db::name('order_use')
-            ->alias('ou')
             ->where($where)
-            ->page($page, $size)
-            ->order("addtime desc")
+            ->page($param['page'], $param['size'])
+            ->order(['addtime' => 'desc', 'id' => 'desc'])
             ->select()
             ->toArray();
-        $all_createrid = array_column($list,'createrid');
+
+        //补全部门信息
+        $all_createrid = array_column($list, 'createrid');
         $item = get_company_name_by_uid($all_createrid);
 
-        foreach ($list as &$value){
-            $val['company_name']=$item[$value['createrid']]??'';
+        foreach ($list as &$value) {
+            $val['company_name'] = $item[$value['createrid']] ?? '';
         }
         return app_show(0, "获取成功", ["list" => $list, "count" => $count]);
     }
-    public function edit(){
-        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
-        if($id==""){
-            return error_show(1002,"参数id不能为空");
-        }
-        $info =Db::name('order_use')->where(['id'=>$id,'is_del'=>0])->find();
-        if($info==""){
-            return error_show(1004,"未找到数据");
-        }
-        $order_use = isset($this->post['order_use']) && $this->post['order_use'] !==""? trim($this->post['order_use']):"";
-        if ($order_use==""){
-            return error_show(1002,"参数order_use不能为空");
-        }
-        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"0";
-        $data =[
-            "id"=>$id,
-            "order_use"=>$order_use,
-            "is_del"=>0,
-            "updatetime"=>date("Y-m-d H:i:s")
-        ];
-        $datainfo = Db::name("order_use")->save($data);
-        if($datainfo){
-            return error_show(0,"编辑成功");
-        }else{
-            return error_show(1002,"编辑失败");
-        }
+
+    public function edit()
+    {
+        $param = $this->request->only(['id', 'companyNo', 'companyName', 'order_use'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'id' => 'require|number|gt:0',
+            'companyNo|公司编码' => 'require|length:18',
+            'companyName|公司名称' => 'require|max:255',
+            'order_use|订单用途' => 'require|max:255',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+
+//        $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
+//        if ($id == "") {
+//            return error_show(1002, "参数id不能为空");
+//        }
+//        $info = Db::name('order_use')->where(['id' => $id, 'is_del' => 0])->find();
+//        if ($info == "") {
+//            return error_show(1004, "未找到数据");
+//        }
+//        $order_use = isset($this->post['order_use']) && $this->post['order_use'] !== "" ? trim($this->post['order_use']) : "";
+//        if ($order_use == "") {
+//            return error_show(1002, "参数order_use不能为空");
+//        }
+//        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
+//        $data = [
+//            "id" => $id,
+//            "order_use" => $order_use,
+//            "is_del" => 0,
+//            "updatetime" => date("Y-m-d H:i:s")
+//        ];
+
+        $tmp = Db::name('order_use')
+            ->field('id')
+            ->where([
+                'is_del' => 0,
+                'companyNo' => $param['companyNo'],
+                'order_use' => $param['order_use'],
+            ])
+            ->where('id', '<>', $param['id'])
+            ->findOrEmpty();
+        if (!empty($tmp)) return json_show(1004, '同一公司下该订单用途已存在');
+
+
+        $datainfo = Db::name("order_use")
+            ->where(['is_del' => 0, 'id' => $param['id']])
+            ->update([
+                "companyNo" => $param['companyNo'],
+                "companyName" => $param['companyName'],
+                "order_use" => $param['order_use'],
+                "updatetime" => date("Y-m-d H:i:s")
+            ]);
+
+        return $datainfo ? app_show(0, "编辑成功") : error_show(1002, "编辑失败");
+
+//        if ($datainfo) {
+//            return error_show(0, "编辑成功");
+//        } else {
+//            return error_show(1002, "编辑失败");
+//        }
     }
-    public function dele(){
-        $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
-        if($id==""){
-            return error_show(1002,"参数id不能为空");
-        }
-        $info = Db::name('order_use')->where(['id'=>$id,'is_del'=>0])->find();
-        if(empty($info)){
-            return error_show(1004,"未找到数据");
-        }
-        $item = Db::name('order_use')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("y-m-d H:i:s")]);
-        if($item){
-            return error_show(0,"删除成功");
-        }else{
-            return error_show(1002,"删除失败");
-        }
+
+    public function dele()
+    {
+        $id = $this->request->filter('trim')->post('id/d', 0);
+//        $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
+//        if ($id == "") {
+//            return error_show(1002, "参数id不能为空");
+//        }
+//        $info = Db::name('order_use')->where(['id' => $id, 'is_del' => 0])->find();
+//        if (empty($info)) {
+//            return error_show(1004, "未找到数据");
+//        }
+        $item = Db::name('order_use')
+            ->where(['is_del' => 0, 'id' => $id])
+            ->update(['is_del' => 1, 'updatetime' => date("Y-m-d H:i:s")]);
+
+        return $item ? app_show(0, "删除成功") : error_show(1002, "删除失败");
+//        if ($item) {
+//            return error_show(0, "删除成功");
+//        } else {
+//            return error_show(1002, "删除失败");
+//        }
     }
-    public function status(){
-        $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
-        if($id==""){
-            return error_show(1002,"参数id不能为空");
-        }
-        $info =  Db::name("order_use")->where([["id","=",$id],["is_del","=",0]])->find();
-        if(!$info){
-            return error_show(1002,"未找到对应数据");
-        }
-        $msg = $info['status']==0? "启用":"禁用";
-        $info['status'] = $info['status']==0?1:0;
-        $info['updatetime'] =date("Y-m-d H:i:s");
-        $in =Db::name("order_use")->save($info);
-        if($in){
-            return app_show(0,"{$msg}成功");
-        }else{
-            return error_show(1004,"{$msg}失败");
-        }
+
+    public function status()
+    {
+        $param = $this->request->only(['id', 'status'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'id' => 'require|number|gt:0',
+            'status|状态' => 'require|number|in:0,1',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+//        $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
+//        if ($id == "") {
+//            return error_show(1002, "参数id不能为空");
+//        }
+//        $info = Db::name("order_use")->where([["id", "=", $id], ["is_del", "=", 0]])->find();
+//        if (!$info) {
+//            return error_show(1002, "未找到对应数据");
+//        }
+//        $msg = $info['status'] == 0 ? "启用" : "禁用";
+//        $info['status'] = $info['status'] == 0 ? 1 : 0;
+//        $info['updatetime'] = date("Y-m-d H:i:s");
+        $in = Db::name("order_use")
+            ->where(['is_del' => 0, 'id' => $param['id']])
+            ->where('status', '<>', $param['status'])
+            ->update(['status' => $param['status'], 'updatetime' => date("Y-m-d H:i:s")]);
+
+        return $in ? app_show(0, "操作成功") : error_show(1004, "操作失败");
+//        if ($in) {
+//            return app_show(0, "{$msg}成功");
+//        } else {
+//            return error_show(1004, "{$msg}失败");
+//        }
     }
-    public function info(){
-        $id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
-        if($id==""){
-            return error_show(1002,"参数id不能为空");
-        }
-        $info = Db::name('order_use')->where(['id'=>$id,'is_del'=>0])->find();
-        if(empty($info)){
-            return error_show(1004,'未找到数据');
-        }
-        return  app_show(0,"获取成功",$info);
+
+    public function info()
+    {
+        $id = $this->request->filter('trim')->post('id/d', 0);
+
+//        $id = isset($this->post['id']) && $this->post['id'] !== "" ? trim($this->post['id']) : "";
+//        if ($id == "") {
+//            return error_show(1002, "参数id不能为空");
+//        }
+        $info = Db::name('order_use')
+            ->where(['id' => $id, 'is_del' => 0])
+            ->findOrEmpty();
+//        if (empty($info)) {
+//            return error_show(1004, '未找到数据');
+//        }
+//        return app_show(0, "获取成功", $info);
+
+        return empty($info) ? error_show(1004, '未找到数据') : app_show(0, "获取成功", $info);
     }
+
 }

+ 2 - 2
app/admin/controller/Specs.php

@@ -38,7 +38,7 @@ class Specs extends Base
             ->field('id')
             ->where(['is_del'=>0,'spec_name'=>$spec_name])
             ->findOrEmpty();
-        if(!$tmp) return json_show(1004,'该规格值已存在');
+        if(!empty($tmp)) return json_show(1004,'该规格值已存在');
 
         $data = [
             "spec_name"=>$spec_name,
@@ -179,7 +179,7 @@ class Specs extends Base
             ->where(['is_del'=>0,'spec_name'=>$spec_name])
             ->where('id','<>',$id)
             ->findOrEmpty();
-        if(!$tmp) return json_show(1004,'该规格值已存在');
+        if(!empty($tmp)) return json_show(1004,'该规格值已存在');
 
         $data = [
             "id"=>$id,

+ 2 - 2
app/admin/controller/Unit.php

@@ -29,7 +29,7 @@ class Unit extends Base
             ->field('id')
             ->where(['is_del' => 0, "unit" => $param['unit']])
             ->findOrEmpty();
-        if (!$tmp) return json_show(1004, '该单位已存在');
+        if (!empty($tmp)) return json_show(1004, '该单位已存在');
 
 //        $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
 //        if($token==''){
@@ -151,7 +151,7 @@ class Unit extends Base
             ->where(['is_del' => 0, "unit" => $unit])
             ->where('id','<>',$id)
             ->findOrEmpty();
-        if (!$tmp) return json_show(1004, '该单位已存在');
+        if (!empty($tmp)) return json_show(1004, '该单位已存在');
 
         $data = [
             "id" => $id,

+ 11 - 5
app/txx/controller/Good.php

@@ -494,7 +494,10 @@ class Good extends BaseController
             ->where($where)
             ->page(intval($param['page']),intval($param['size']))
             ->order("b.addtime desc")
-            ->cursor();
+            ->select()
+            ->toArray();
+        $all_createrid = array_column($list,'purchase_id');
+        $item = get_company_name_by_uid($all_createrid);
         $data = [];
         $yzgood = new YzGood();
         foreach ($list as $value) {
@@ -534,8 +537,8 @@ class Good extends BaseController
             $value['stock_total'] = Db::name("good_stock")->where(['spuCode' => $value['spuCode'], "is_del" => 0])->sum("usable_stock");
             $value['exclusive'] = makeExcluse($value['is_exclusive']);
             $value['noble_name'] = isset($value['noble_metal']) && $value['noble_metal'] != 0 ? $this->noble[$value['noble_metal']] : "";
-            $itemid =Db::name("depart_user")->where(["uid"=>$value["purchase_id"],"is_del"=>0])->value("itemid",'');
-            $value['company_name'] = implode('/', array_column(GetPart($itemid), 'name'));
+//            $itemid =Db::name("depart_user")->where(["uid"=>$value["purchase_id"],"is_del"=>0])->value("itemid",'');
+            $value['company_name'] = $item[$value['purchase_id']]??'';
         	}else{
             	unset($value['brand_id']);
 			unset($value['good_unit']);
@@ -611,8 +614,11 @@ class Good extends BaseController
             $info['stock_total'] = Db::name("good_stock")->where(['spuCode' => $info['spuCode'], "is_del" => 0])->sum("usable_stock");
             $info['exclusive'] = makeExcluse($info['is_exclusive']);
             $info['noble_name'] = isset($info['noble_metal']) && $info['noble_metal'] != 0 ? $this->noble[$info['noble_metal']] : "";
-            $itemid =Db::name("depart_user")->where(["uid"=>$info["purchase_id"],"is_del"=>0])->value("itemid",'');
-            $info['company_name'] = implode('/', array_column(GetPart($itemid), 'name'));
+//            $itemid =Db::name("depart_user")->where(["uid"=>$info["purchase_id"],"is_del"=>0])->value("itemid",'');
+
+            $item = get_company_name_by_uid($info["purchase_id"]);
+            $info['company_name'] = $item??'';
+
         	}else{
 	    	unset($info['brand_id']);
 		    unset($info['good_unit']);