aexiaoliou 1 gadu atpakaļ
vecāks
revīzija
532c2e32f9

+ 4 - 0
api/app/admin/middleware/CheckPermissionAttr.php

@@ -17,6 +17,10 @@ class CheckPermissionAttr
         $role = $admin->role;
         $codes = $role->codes;
 
+        if (!$role->valid) {
+            throw new CatchException("角色‘{$role->name}’已被禁用,如有疑问,请联系管理员", 403);
+        }
+
         // 超级管理员可以做任何事
         if (in_array(Role::CODE_SUPER_ADMIN, $codes)) {
             return $next($request);

+ 8 - 0
api/app/common/model/Project.php

@@ -2,10 +2,14 @@
 
 namespace app\common\model;
 
+use think\facade\Db;
 use app\common\model\Contract;
 use app\common\model\ProjectSchedule;
 
 /**
+ * 
+ * @property array<number> $participants_id
+ * @property number $responsibility_person_id
  * @property array<ProjectSchedule> $schedules
  * @property array<Contract> $contracts
  */
@@ -56,4 +60,8 @@ class Project extends Base
             ->order('s.start_date asc')
             ->join('admin a', 'a.id = s.updater_id', 'LEFT');
     }
+
+    public function getParticipantsAttr($value, $data) {
+        return (new Admin)->where('id', 'in', $this->participants_id)->select()->map(fn($admin) => $admin->real_name);
+    }
 }

+ 12 - 0
api/app/common/model/ProjectSchedule.php

@@ -2,6 +2,13 @@
 
 namespace app\common\model;
 
+/**
+ * 项目流程
+ * 
+ * @property bool|int $is_update_project_status 是否更新项目状态
+ * @property string $status 状态值
+ * @property mixed $name
+ */
 class ProjectSchedule extends Base
 {
     // 状态值
@@ -41,4 +48,9 @@ class ProjectSchedule extends Base
         'status'         => 'varchar',   // "NOT_START"未开始 "GOING"进行中 "FINISH"完成 "SKIP"跳过
         'updater_id'     => 'int'   // 更新人id
     ];
+
+    public function project()
+    {
+        return $this->belongsTo(Project::class);
+    }
 }

+ 24 - 0
api/app/common/service/ProjectScheduleService.php

@@ -17,6 +17,30 @@ class ProjectScheduleService extends Service
     {
         $param = $this->autoParams($param);
 
+        $newStatus = $this->pg('status');
+        $goingStatus = $this->pg('going_project_status');
+        $finishStatus = $this->pg('finish_project_status');
+        $projectNewStatus = '';
+
+        $schedule = $this->one(ProjectSchedule::class);
+        // 是否更新项目状态值
+        if ($schedule->is_update_project_status) {
+            if ($schedule->status == ProjectSchedule::STATUS_NOT_START) {   
+                if ($newStatus == ProjectSchedule::STATUS_GOING) {
+                    $projectNewStatus = $goingStatus;
+                } elseif ($newStatus == ProjectSchedule::STATUS_FINISH) {
+                    $projectNewStatus = $finishStatus;
+                }
+            } elseif($schedule->status == ProjectSchedule::STATUS_GOING && $newStatus == ProjectSchedule::STATUS_FINISH) {
+                $projectNewStatus = $finishStatus;
+            }
+        }
+
+        // 跳过、没有对应值、不更新项目状态值的projectNewStatus都是空,跳过
+        if (!$projectNewStatus) {
+            $schedule->project = $projectNewStatus;
+        }
+
         return ProjectSchedule::update($param);
     }
 

+ 3 - 2
api/app/common/service/ProjectService.php

@@ -25,8 +25,8 @@ class ProjectService extends Service
         $update_time_end_time = $this->pg('update_time_begin_time');
         $corret_update_end_time = $update_time_end_time ? Carbon::createFromTimeString($update_time_end_time)->endOfDay()->toDateTimeString() : null;
 
-        $min_amount = $this->pg('min_price');
-        $max_amount = $this->pg('max_price');
+        $min_amount = $this->pg('min_amount');
+        $max_amount = $this->pg('max_amount');
         
         $min_dev_time_days = $this->pg('min_dev_time_days');
         $max_dev_time_days = $this->pg('max_dev_time_days');
@@ -47,6 +47,7 @@ class ProjectService extends Service
 
         return (new Project)->alias('p')
             ->with(['schedules'])
+            ->append(['participants'])
             ->field('p.*')
             ->field('a.real_name as responsibility_person')
             ->join('admin a', 'a.id = p.responsibility_person_id', 'LEFT')

+ 5 - 5
api/app/common/util/WhereBuilder.php

@@ -133,14 +133,14 @@ class WhereBuilder implements \ArrayAccess
 
     public function between($column, $left, $right, $when = false)
     {
-        if ($when || (self::empty($left) && self::empty($right))) {
+        if ($when || (self::exist($left) && self::exist($right))) {
             $this->where($column, 'between', [$left, $right]);
             return $this;
-        } elseif (self::empty($left) && !self::empty($right)) {
+        } elseif (self::exist($left) && !self::exist($right)) {
             $this->where($column, '>=', $left);
             return $this;
-        } elseif (!self::empty($left) && self::empty($right)) {
-            $this->where($column, '<=', $left);
+        } elseif (!self::exist($left) && self::exist($right)) {
+            $this->where($column, '<=', $right);
             return $this;
         } else {
             return $this;
@@ -197,7 +197,7 @@ class WhereBuilder implements \ArrayAccess
         return isset($this->where[$offset]) ? $this->where[$offset] : null;
     }
 
-    private static function empty($condition)
+    private static function exist($condition)
     {
         $valid = false;
         if (is_int($condition)) {