瀏覽代碼

判断用户是否是物业主管或信息负责人

zhanglinxin 1 年之前
父節點
當前提交
4613ee8af4

+ 6 - 1
application/common/service/ApproveInfoService.php

@@ -663,7 +663,6 @@ class ApproveInfoService
             ]);
             $info = $info->find($id);
             if ($info) {
-                //
                 $module = $info['module'];
                 // 审批提交人申请人信息
                 if ($user) {
@@ -941,6 +940,12 @@ class ApproveInfoService
                         $info->peer_user;
                     }
                     break;
+                case CommonConstant::MODULE_8:
+                    if ($type == 'detail') {
+
+//                        $info['peer_user'] = ;
+                    }
+                    break;
             }
         }
         return $info;

+ 5 - 21
application/common/service/ApproveService.php

@@ -4,7 +4,6 @@ namespace app\common\service;
 
 use app\common\constant\ApplyConstant;
 use app\common\constant\CommonConstant;
-use app\common\constant\MaintainConstant;
 use app\common\model\Approve;
 use app\common\model\ApproveApplyGoods;
 use app\common\model\ApproveEvectionPeerUser;
@@ -92,8 +91,8 @@ class ApproveService
         $jobName = 'approveInfo.';
         $field = 'id as approve_id,info_id,status,create_at';
         $joinField = 'module,user_id,apply_user_id,order_no,apply_date,reason,type,desc,start_time,end_time';
-        $field = self::getAliasField($field, $aliasName);
-        $joinField = self::getAliasField($joinField, $jobName);
+        $field = CommonService::getAliasField($field, $aliasName);
+        $joinField = CommonService::getAliasField($joinField, $jobName);
         $field = implode(',', array_merge($field, $joinField));
         $list = Approve::alias('approve')
             ->field($field)
@@ -385,11 +384,9 @@ class ApproveService
             }
             if ($info->module == CommonConstant::MODULE_8) {
                 // 维修
-                // 匹配用户是否是 物业主管或信息负责人
-                if (in_array($user['title'], MaintainConstant::get_type_title_list())) {
-                    if (!$maintain_user_id) {
-                        except('请选择维修人员');
-                    }
+                $is_maintain = CommonService::isMaintain($user);
+                if ($is_maintain && !$maintain_user_id) {
+                    except('请选择维修人员');
                 }
             }
         }
@@ -492,17 +489,4 @@ class ApproveService
         return true;
     }
 
-
-    /**
-     * 拼接查询字段
-     */
-    public static function getAliasField($field, $aliasName)
-    {
-        $field = explode(',', $field);
-        foreach ($field as &$value) {
-            $value = $aliasName . $value;
-        }
-        return $field;
-    }
-
 }

+ 41 - 0
application/common/service/CommonService.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace app\common\service;
+
+use app\common\constant\MaintainConstant;
+use think\cache\driver\Redis;
+
+/**
+ * 公共服务类
+ */
+class CommonService
+{
+
+    /**
+     * 拼接查询字段
+     *
+     * @param string $field
+     * @param string $aliasName
+     */
+    public static function getAliasField($field, $aliasName)
+    {
+        $field = explode(',', $field);
+        foreach ($field as &$value) {
+            $value = $aliasName . $value;
+        }
+        return $field;
+    }
+
+    /**
+     * 判断用户是否是物业主管或信息负责人
+     *
+     * @param mixed $user 用户信息
+     **/
+    public static function isMaintain($user){
+        if (in_array($user['title'], MaintainConstant::get_type_title_list())) {
+            return true;
+        }
+        return false;
+    }
+
+}