wugg 2 rokov pred
rodič
commit
e41e85a99c

+ 7 - 1
app/admin/controller/Activity.php

@@ -62,8 +62,14 @@ class Activity extends Base
 //        if(!empty($role['write'])){
 //            $where[]=["ga.createrid","in",$role['write']];
 //        }
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['ga.createrid', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['ga.createrid', 'in', $role[DataGroupModel::$type_全部]];
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['ga.createrid', 'in',$arr];
+        }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["ga.createrid", 'in', get_company_item_user_by_name($company_name)];

+ 10 - 8
app/admin/controller/After.php

@@ -231,15 +231,17 @@ class After extends Base
         if($end!==""){
             $where[]=['a.addtime',"<=", $end];
         }
-        $condition='';
-//        $role=$this->checkRole();
-//        if(!empty($role['write']) && $this->uid!=""){
-//            // $where[]=["a.apply_id","in",$role['write']];
-//            $condition .="a.cgderid = {$this->uid} or a.apply_id in (".implode(',',$role['write']).")";
-//        }
+        $condition=[];
+		$hand = resign_hand_user($this->uid,0);
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $condition .="a.cgderid = {$this->uid} or a.person_id= {$this->uid} or a.apply_id in ("
-        .implode(',',$role[DataGroupModel::$type_全部]).")";
+        if (!empty($role[DataGroupModel::$type_全部])){
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+        	$condition[]= ["a.person_id","in",$hand];
+        	$condition[]= ["a.apply_id","in",$arr];
+        	$condition[]= ["a.cgderid","in",$hand];
+        }
+//        $condition .="a.cgderid in {$hand} or a.person_id in {$hand} or a.apply_id in ("
+//        .implode(',',$role[DataGroupModel::$type_全部]).")";
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];

+ 7 - 1
app/admin/controller/Allot.php

@@ -86,8 +86,14 @@ class Allot extends Base
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];
 
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['a.apply_id', 'in',$arr];
+        }
 
         $count = Db::name('allot_stock')
             ->alias('a')

+ 8 - 2
app/admin/controller/Check.php

@@ -211,8 +211,14 @@ public function list()
         $condition[]=["a.companyNo ","=",$companyNo ];
     }
 
-    $role = $this->checkDataShare();
-    if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+//    $role = $this->checkDataShare();
+//    if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+        $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['a.apply_id', 'in',$arr];
+        }
 
     $count = Db::name('good_check')
         ->alias('a')

+ 15 - 3
app/admin/controller/Consult.php

@@ -68,8 +68,14 @@ class Consult extends Base
 //        if(!empty($role['write'])){
 //            $where[]=["b.createrid","in",$role['write']];
 //        }
-        $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["b.createrid", "in", $role[DataGroupModel::$type_全部]];
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["b.createrid", "in", $role[DataGroupModel::$type_全部]];
+	    $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['b.createrid', 'in',$arr];
+        }
 
 //        if(!empty($role['platform']) ){
 //            $where[]=["b.platform_code","in",$role['platform']];
@@ -2093,8 +2099,14 @@ class Consult extends Base
 //        if(!empty($role['write'])){
 //            $where[]=["bo.createrid","in",$role['write']];
 //        }
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['bo.createrid', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['bo.createrid', 'in', $role[DataGroupModel::$type_全部]];
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['bo.createrid', 'in',$arr];
+        }
 
         $count=Db::name("bargain_order")
             ->alias('bo')

+ 10 - 3
app/admin/controller/Good.php

@@ -112,7 +112,11 @@ class Good extends Base
 //            $where[]=["a.createrid","in",$role['write']];
 //        }
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['b.createrid', 'in', $role[DataGroupModel::$type_全部]];
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['b.createrid', 'in',$arr];
+        }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
@@ -241,8 +245,11 @@ class Good extends Base
 //        $role = $this->checkRole();
 //        if (!empty($role['write'])) $where[] = ["a.createrid", "in", $role['write']];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['b.createrid', 'in', $role[DataGroupModel::$type_全部]];
-
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['b.createrid', 'in',$arr];
+        }
         if ($param['company_name'] !== '') $where[] = ["a.createrid", 'in', get_company_item_user_by_name($param['company_name'])];
 
         $count = Db::name('platform_youzan')

+ 7 - 2
app/admin/controller/GoodOfflineLog.php

@@ -21,9 +21,14 @@ class GoodOfflineLog extends Base
         if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
 		if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
         if ($param['good_name'] != '') $where[] = ['good_name', 'like', '%' . $param['good_name'] . '%'];
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["createrid", "in", $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["createrid", "in", $role[DataGroupModel::$type_全部]];
-
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['createrid', 'in',$arr];
+        }
 
 
         $count = Db::name('good_offline_log')->where($where)->count('id');

+ 17 - 9
app/admin/controller/Goodup.php

@@ -135,9 +135,15 @@ class Goodup extends Base
 //            }
 //        }
 //        $role=$this->checkRole();
-        $wheror=[];
-        $role = $this->checkDataShare();//取负责人字段
-        if(!empty($role[DataGroupModel::$type_全部]))  $wheror[]=["gb.chargerid","in",$role[DataGroupModel::$type_全部]];
+//        $wheror=[];
+//        $role = $this->checkDataShare();//取负责人字段
+//        if(!empty($role[DataGroupModel::$type_全部]))  $wheror[]=["gb.chargerid","in",$role[DataGroupModel::$type_全部]];
+        $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['gb.chargerid', 'in',$arr];
+        }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["gb.createrid", 'in', get_company_item_user_by_name($company_name)];
@@ -145,9 +151,10 @@ class Goodup extends Base
         $count = Db::name('good_basic')
             ->alias('gb')
             ->where($where)
-            ->where(function ($Query) use ($wheror) {
-                return $Query->whereOr($wheror);
-            })->count();
+//            ->where(function ($Query) use ($wheror) {
+//                return $Query->whereOr($wheror);
+//            })
+            ->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
         $list = Db::name('good_basic')
@@ -155,9 +162,10 @@ class Goodup extends Base
             ->field('gb.*,u.itemid')
             ->leftJoin("depart_user u", "u.uid=gb.chargerid AND u.is_del=0")
             ->where($where)
-            ->where(function ($Query) use ($wheror) {
-                return $Query->whereOr($wheror);
-            })->page($page, $size)
+//            ->where(function ($Query) use ($wheror) {
+//                return $Query->whereOr($wheror);
+//            })
+            ->page($page, $size)
             ->order("addtime desc")
             ->select()
             ->toArray();

+ 15 - 5
app/admin/controller/Orderback.php

@@ -65,21 +65,31 @@ class Orderback extends Base
         if($end!==""){
             $where[]=['addtime',"<=", $end];
         }
-        $condition='';
+        $condition=[];
 //        $role=$this->checkRole();
 //        if(!empty($role['write']) && $this->uid!=""){
 //            // $where[]=["a.apply_id","in",$role['write']];
 //            $condition .="cgderid = {$this->uid} or apply_id in (".implode(',',$role['write']).")";
 //        }
-        $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $condition .= "cgderid = {$this->uid} or apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
+//		$hand = resign_hand_user($this->uid);
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $condition .= "cgderid in {$hand} or apply_id in (" . implode(',',
+//        $role[DataGroupModel::$type_全部]) . ")";
+       $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$condition[] = ['apply_id', 'in',$arr];
+			$condition[] = ['cgderid', 'in',$hand];
+        }
 //        if(!empty($role['platform']) ){
 //            $where[]=["platform_id","in",$role['platform']];
 //        }
-        $count=Db::name("order_back")->where($where)->where($condition)->count();
+        $count=Db::name("order_back")->where($where)->whereOr($condition)->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name("order_back")->where($where)->where($condition)->page($page,$size)->order("addtime desc")->select()->toArray();
+        $list = Db::name("order_back")->where($where)->whereOr($condition)->page($page,$size)->order("addtime desc")
+        ->select()->toArray();
         $data=[];
         foreach ($list as $value){
             $value['wsm_name']="";

+ 7 - 2
app/admin/controller/Project.php

@@ -366,9 +366,14 @@ class Project extends Base
 //        if(!empty($role['write'])){
 //            $where[]=["p.createrid","in",$role['write']];
 //        }
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['p.createrid', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['p.createrid', 'in', $role[DataGroupModel::$type_全部]];
-
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['p.createrid', 'in',$arr];
+        }
 //        if(!empty($role['platform'])){
 //            $where[]=["p.platform_id","in",$role['platform']];
 //        }

+ 17 - 4
app/admin/controller/Purch.php

@@ -116,8 +116,15 @@ class Purch extends Base
 //            $whereor[]=["sip.personid","in",$role['write']];//最后的筛选条件
 ////            $whereor[]=["po.cgder_id","=",$this->uid];
 //        }
-		$role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["sip.personid", "in", $role[DataGroupModel::$type_全部]];
+//		$role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["sip.personid", "in", $role[DataGroupModel::$type_全部]];
+
+         $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['sip.personid', 'in',$arr];
+        }
 
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
@@ -902,8 +909,14 @@ class Purch extends Base
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];
 
-        $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+         $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['a.apply_id', 'in',$arr];
+        }
 
         $count = Db::name('purchease_diff')
             ->alias('a')

+ 20 - 7
app/admin/controller/Purchin.php

@@ -84,10 +84,17 @@ class Purchin extends Base
                 "is_del"=>0,"supplierNo"=>$supplierNo])->column("wsm_code");
             $where[]=['a.wsm_code',"in",$wsmcode];
         }
-        $condition="";
+        $condition=[];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $condition.="sip.personid in (".implode(",",
-        $role[DataGroupModel::$type_全部]).") or a.apply_id={$this->uid} or c.contactor = {$this->uid}";
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+        	$condition[]= ["sip.personid","in",$arr];
+        	$condition[]= ["a.apply_id","in",$hand];
+        	$condition[]= ["c.contactor","in",$hand];
+//        	$condition.="sip.personid in (".implode(",",
+//        $role[DataGroupModel::$type_全部]).") or a.apply_id in {$hand} or c.contactor in {$hand}";
+        }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];
@@ -99,7 +106,7 @@ class Purchin extends Base
             ->leftJoin("warehouse_info c","a.wsm_code=c.wsm_code")
             ->leftJoin('supplier sip', 'sip.code=b.supplierNo')
             ->where($where)
-            ->where($condition)
+            ->whereOr($condition)
             ->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
@@ -110,7 +117,7 @@ class Purchin extends Base
             ->leftJoin("warehouse_info c","a.wsm_code=c.wsm_code")
             ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
             ->where($where)
-            ->where($condition)
+            ->whereOr($condition)
             ->page($page,$size)
             ->field("a.apply_name,a.sendtime,b.order_type,b.order_source,a.status,a.cgdNo,
             a.wsm_in_code,a.send_num,a.wsm_code,b.good_name,b.spuCode,a.post_company,a.post_code,
@@ -1356,8 +1363,14 @@ class Purchin extends Base
         if($status!=""){
             $where[]= ["a.status",'=',$status];
         }
-        $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["a.apply_id", "in", $role[DataGroupModel::$type_全部]];
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["a.apply_id", "in", $role[DataGroupModel::$type_全部]];
+        	    $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['a.apply_id', 'in',$arr];
+        }
 
         $count = Db::name('purchease_return')
             ->alias('a')

+ 16 - 4
app/admin/controller/Reorder.php

@@ -426,21 +426,33 @@ class Reorder extends Base
         if($end!==""){
             $where[]=['sr.addtime',"<=", $end.' 23:59:59'];
         }
-        $condition='';
+        $condition=[];
 //        $role=$this->checkRole();
 //        if(!empty($role['write']) && $this->uid!=""){
 //            // $where[]=["sr.apply_id","in",$role['write']];
 //            $condition .="sr.cgderid = {$this->uid} or sr.apply_id in (".implode(',',$role['write']).")";
 //        }
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $condition .= "sr.cgderid = {$this->uid} or sr.person_id = {$this->uid} or sr.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+//        	$uidim =implode(",",$hand);
+//			$condition .= "sr.cgderid in ($uidim) or sr.person_id in ($uidim) or sr.apply_id in (" . implode(',',$arr) .
+//			 ")";
+			$condition[]= ["sr.apply_id","in",$arr];
+        	$condition[]= ["sr.cgderid","in",$hand];
+        	$condition[]= ["sr.person_id","in",$hand];
+
+        }
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $condition .= "sr.cgderid = {$this->uid} or sr.person_id = {$this->uid} or sr.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
 		if(in_array($this->roleid,config('app.wsm_cgder_role'))){
 			$where[]=["order_type","=",1];
 		}
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["sr.apply_id", 'in', get_company_item_user_by_name($company_name)];
 
-        $count=Db::name("sale_return")->alias('sr')->where($where)->where($condition)->count();
+        $count=Db::name("sale_return")->alias('sr')->where($where)->whereOr($condition)->count();
         $total = ceil($count/$size);
         $page = $total>=$page ? $page :$total;
         $list = Db::name("sale_return")
@@ -448,7 +460,7 @@ class Reorder extends Base
             ->field('sr.*,u.itemid')
             ->leftJoin("depart_user u", "u.uid=sr.apply_id AND u.is_del=0")
             ->where($where)
-            ->where($condition)
+            ->whereOr($condition)
             ->order("addtime desc")
             ->page($page,$size)
             ->cursor();

+ 11 - 4
app/admin/controller/Resign.php

@@ -75,7 +75,7 @@ class Resign extends Base
             $where[]=['p.addtime',"<=",$end];
         }
 //        $role=$this->checkRole();
-        $condition='';
+        $condition=[];
 //        if(!empty($role['write']) && $this->uid!=""){
 //            // $where[]=["a.apply_id","in",$role['write']];
 //            $condition .="p.cgderid = {$this->uid} or p.apply_id in (".implode(',',$role['write']).")";
@@ -85,7 +85,14 @@ class Resign extends Base
         $super_roleid = array_merge([1, 33], config('app.wsm_cgder_role'));
         if (!in_array($this->roleid, $super_roleid)) {
         	$role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $condition .="p.cgderid = {$this->uid} or p.apply_id in (".implode(',',$role[DataGroupModel::$type_全部]).")";
+        	$hand =resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])){
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+        	$condition[]= ["p.apply_id","in",$arr];
+        	$condition[]= ["p.cgderid","in",$hand];
+        }
+//        	$condition .="p.cgderid in {$hand}  or p.apply_id in {$hand} or p.apply_id in ("
+//        .implode(',',$role[DataGroupModel::$type_全部]).")";
         }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
@@ -98,7 +105,7 @@ class Resign extends Base
             ->alias('p')
             ->leftJoin("depart_user u", "u.uid=p.apply_id AND u.is_del=0")
             ->where($where)
-            ->where($condition)
+            ->whereOr($condition)
             ->count();
         $total = ceil($count/$size);
         $page = $page >= $total ? $total : $page;
@@ -107,7 +114,7 @@ class Resign extends Base
             ->field('p.*,u.itemid')
             ->leftJoin("depart_user u", "u.uid=p.apply_id AND u.is_del=0")
             ->where($where)
-            ->where($condition)
+            ->whereOr($condition)
             ->page($page,$size)
             ->order("p.addtime desc")
             ->cursor();

+ 8 - 2
app/admin/controller/Resigninfo.php

@@ -56,8 +56,14 @@ class Resigninfo extends Base
             $where[]= ["addtime",'<=',$end];
         }
 
-        $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["hand_uid", "in", $role[DataGroupModel::$type_全部]];
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["hand_uid", "in", $role[DataGroupModel::$type_全部]];
+          $role = $this->checkDataShare();
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['hand_uid', 'in',$arr];
+        }
 
         $count = Db::name('resign_info')->where($where)->count();
         $total = ceil($count/$size);

+ 24 - 8
app/admin/controller/Sale.php

@@ -2173,8 +2173,14 @@ class Sale extends Base
 //            $where[] = ["s.apply_id", "in", $role['write']];
 //        }
 
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['s.apply_id', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['s.apply_id', 'in', $role[DataGroupModel::$type_全部]];
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['s.apply_id', 'in',$arr];
+        }
 
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["s.apply_id", 'in', get_company_item_user_by_name($company_name)];
@@ -3182,9 +3188,14 @@ class Sale extends Base
 //        if(!empty($role['write'])){
 //            $where[]=["apply_id","in",$role['write']];
 //        }
+//        $role = $this->checkDataShare();
+//        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['c.apply_id', 'in', $role[DataGroupModel::$type_全部]];
         $role = $this->checkDataShare();
-        if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['c.apply_id', 'in', $role[DataGroupModel::$type_全部]];
-
+        $hand = resign_hand_user($this->uid,0);
+        if (!empty($role[DataGroupModel::$type_全部])) {
+        	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+			$where[] = ['c.apply_id', 'in',$arr];
+        }
 //        if(!empty($role['platform']) ){
 //            $where[]=["c.platform_id","in",$role['platform']];
 //        }
@@ -3486,7 +3497,7 @@ class Sale extends Base
             $where[] = ["os.cgdNo", 'like', '%' . $cgdNo . '%'];
         }
 //        $role = $this->checkRole();
-        $condition = '';
+        $condition = [];
 //        if (!empty($role['write']) && $this->uid != "") {
 //            // $where[]=["a.apply_id","in",$role['write']];
 //            $condition .= " (b.is_stock=1 and n.contactor = {$this->uid}) or (b.is_stock=0 and wpo.cgder_id = {$this->uid}) or a.apply_id in (" . implode(',',
@@ -3494,16 +3505,21 @@ class Sale extends Base
 //        }
 
 
+        $hand = resign_hand_user($this->uid,0);
         //库管只能看到库存品订单,供应商负责人只能看到非库存品订单
         if(!in_array($this->roleid,[1,33])){
             //库管看到所有的库存品发货申请单
-            if(in_array($this->roleid,config('app.wsm_cgder_role'))) $condition .="b.is_stock=1";
+            if(in_array($this->roleid,config('app.wsm_cgder_role'))) $where[]=["b.is_stock","=",1];
             else{
             	$role = $this->checkDataShare();
-                if (!empty($role[DataGroupModel::$type_全部])) $condition .= " a.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
+            	$uidarr =implode(",",$hand);
+                if (!empty($role[DataGroupModel::$type_全部])) {
+                	$arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
+                	$condition .= " a.apply_id in (" . implode(',',$arr) . ")";
+                }
 
-                $personid=Db::name('supplier')->field('id')->where(['is_del'=>0,'personid'=>$this->uid])->findOrEmpty();
-                if($personid)$condition.=" or (b.is_stock=0 and sip.personid = {$this->uid})";//供应商负责人能看到非库存品的单子
+                $personid=Db::name('supplier')->field('id')->where(['is_del'=>0,'personid'=> $hand])->findOrEmpty();
+                if($personid)$condition.=" or (b.is_stock=0 and sip.personid in ($uidarr))";//供应商负责人能看到非库存品的单子
 //                else $condition.="a.apply_id = {$this->uid}";//其他只能看到自己创建的单子
             }
         }

+ 16 - 0
app/common.php

@@ -1403,4 +1403,20 @@ if(!function_exists("cgd_sale_return")){
 		->findOrEmpty();
 		return !empty($order);
 	}
+}
+
+//采购单未操作确认或入库时判断销售单是否存在正进行中的退货
+if(!function_exists("resign_hand_user")){
+	/**
+	* @param $uid
+	* @param int $ty 1 返回字符串 0 返回数组
+	 * @return array|string
+	 */
+	function resign_hand_user($uid,$ty=1){
+		$uid_arr=[$uid];
+		$resign_uids =Db::name("resign_info")->where([["hand_uid","=",$uid],["is_del","=",0],["status","=",4]])
+		->column("resign_uid");
+		$uid_arr =array_filter(array_merge($uid_arr,$resign_uids));
+		return $ty==1? "(".implode(",",$uid_arr).")":$uid_arr;
+	}
 }