wupengfei il y a 2 ans
Parent
commit
eb0225dd4b

+ 2 - 22
application/api/controller/Offer.php

@@ -31,17 +31,7 @@ class Offer extends Base
      */
     public function getApproveFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',1)->where('module',4)->find();
-        $where = [];
-        $where[] = ['l.type','=',1];
-        $where[] = ['l.module','=',4];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getApproveUser(4,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 
@@ -58,17 +48,7 @@ class Offer extends Base
      */
     public function getCopyFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',2)->where('module',4)->find();
-        $where = [];
-        $where[] = ['l.type','=',2];
-        $where[] = ['l.module','=',4];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getCopyTo(4,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 

+ 3 - 23
application/api/controller/UserCar.php

@@ -33,17 +33,7 @@ class UserCar extends Base
      */
     public function getApproveFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',1)->where('module',2)->find();
-        $where = [];
-        $where[] = ['l.type','=',1];
-        $where[] = ['l.module','=',2];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getApproveUser(2,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 
@@ -60,17 +50,7 @@ class UserCar extends Base
      */
     public function getCopyFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',2)->where('module',2)->find();
-        $where = [];
-        $where[] = ['l.type','=',2];
-        $where[] = ['l.module','=',2];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getCopyTo(2,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 
@@ -109,7 +89,7 @@ class UserCar extends Base
         $approve_res = ApproveFlow::getApproveData($flow_user,$copy_user,$flow_info->id);
         $flow_data = $approve_res['flow_data'];// 审批流程
         $flow_num = $approve_res['flow_num'];
-        
+
         if(!empty($flow_data)) {
             CarInfo::where('id',$flow_info->id)->update(['approve_num'=>$flow_num]);
             (new CarApprove())->saveAll($flow_data);

+ 2 - 22
application/api/controller/UserLeave.php

@@ -34,17 +34,7 @@ class UserLeave extends Base
      */
     public function getApproveFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',1)->where('module',1)->find();
-        $where = [];
-        $where[] = ['l.type','=',1];
-        $where[] = ['l.module','=',1];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getApproveUser(1,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }
 
@@ -61,17 +51,7 @@ class UserLeave extends Base
      */
     public function getCopyFlow()
     {
-        $check_flow = ApproveFlow::where('user_id',$this->user_id)->where('type',2)->where('module',1)->find();
-        $where = [];
-        $where[] = ['l.type','=',2];
-        $where[] = ['l.module','=',1];
-        if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
-        $list = ApproveFlow::field('l.user_id,u.name user_name,u.headimg')
-            ->alias('l')
-            ->where($where)
-            ->order('l.sort asc')
-            ->leftJoin('StoreMember u','u.id = l.user_id')
-            ->select()->toArray();
+        $list = ApproveFlow::getCopyTo(1,$this->user_id);
         $this->success('ok',['list'=>$list]);
     }