zhanglinxin 1 年之前
父節點
當前提交
a3042b2cb7

+ 22 - 16
application/api/controller/Approveinfo.php

@@ -406,14 +406,7 @@ class Approveinfo extends Base
     {
         $id = input('id') ?: 0;
         $user = $this->user;
-        Db::startTrans();
-        try {
-            ApproveInfoService::make($id, $user, 'urging');
-            Db::commit();
-        } catch (Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
+        ApproveInfoService::make($id, [],$user, 'urging');
         $this->success('催办成功');
     }
 
@@ -427,15 +420,28 @@ class Approveinfo extends Base
     {
         $id = input('id') ?: 0;
         $user = $this->user;
-        Db::startTrans();
-        try {
-            ApproveInfoService::make($id, $user, 'cancel');
-            Db::commit();
-        } catch (Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
+        ApproveInfoService::make($id, [],$user, 'cancel');
         $this->success('撤销成功');
     }
 
+    /**
+     * 评分
+     *
+     * @Apidoc\Desc("维修模块")
+     * @Apidoc\Method("POST")
+     * @Apidoc\Param("id", type="integer",require=true, desc="申请ID")
+     * @Apidoc\Param("comment_score", type="sting",require=true, desc="评分")
+     * @Apidoc\Param("comment", type="sting",require=false, desc="评价内容")
+     **/
+    public function comment()
+    {
+        $id = input('id') ?: 0;
+        $comment_score = input('comment_score') ?: '';
+        $comment = input('comment') ?: '';
+        $params = compact("id", "comment_score", "comment");
+        $user = $this->user;
+        ApproveInfoService::make($id, $params, $user, 'comment');
+        $this->success('评价成功');
+    }
+
 }

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

@@ -953,10 +953,11 @@ class ApproveInfoService
      * 操作方法
      *
      * @param integer $id 申请ID
+     * @param array $params 数组
      * @param mixed $user 用户信息
-     * @param string $type 类型:urging=催办,cancel=撤销
+     * @param string $type 类型:urging=催办,cancel=撤销,comment=评分
      */
-    public static function make($id, $user, $type)
+    public static function make($id, $params,$user, $type)
     {
         $userid = $user['userid'];
         $info = ApproveInfo::field('id,user_id,module,status')
@@ -966,16 +967,16 @@ class ApproveInfoService
             ->where('is_deleted', CommonConstant::IS_DELETED_0)
             ->find($id);
         if (!$info) {
-            throw new Exception('申请记录不存在或已删除');
+            except('申请记录不存在或已删除');
         }
         if ($info->user_id != $userid) {
-            throw new Exception('您没有权限操作');
+            except('您没有权限操作');
         }
 
         switch ($type) {
             case 'urging':
                 if ($info->status != CommonConstant::STATUS_2) {
-                    throw new Exception('其他人已操作');
+                    except('其他人已操作');
                 }
 
                 // TODO 待对接钉钉接口
@@ -983,7 +984,7 @@ class ApproveInfoService
                 break;
             case 'cancel':
                 if ($info->status != CommonConstant::STATUS_4) {
-                    throw new Exception('非审批驳回状态无法操作');
+                    except('非审批驳回状态无法操作');
                 }
 
                 $info->status = CommonConstant::STATUS_5;

+ 2 - 1
application/common/service/ApproveService.php

@@ -313,7 +313,7 @@ class ApproveService
                         $is_maintain = CommonService::isMaintain($user);
                     }
                     if ($data['approve_status'] == CommonConstant::STATUS_3) {
-                        if (CommonService::isMaintain($user) && $data['maintain_user_id'] > 0 && $data['module']['maintain_user_id'] == 0) {
+                        if (CommonService::isMaintain($user) && $data['maintain_user_id'] > 0 && $data['module']['feedback_status'] == CommonConstant::IS_WHO_0) {
                             $is_feedback = true;
                         }
                     }
@@ -557,6 +557,7 @@ class ApproveService
         try {
             $data = [
                 'maintain_user_id' => $info->maintain_user_id,
+                'feedback_status' => CommonConstant::IS_WHO_1,
                 'feedback' => $params['feedback'],
                 'feedback_images' => $params['feedback_images'],
             ];