Browse Source

小程序信息提醒优化

wanghaijun 4 years ago
parent
commit
b59767b9e6
2 changed files with 18 additions and 7 deletions
  1. 3 1
      app/Http/Controllers/Api/mini/OrderController.php
  2. 15 6
      app/Models/Notification.php

+ 3 - 1
app/Http/Controllers/Api/mini/OrderController.php

xqd xqd xqd
@@ -53,8 +53,8 @@ class OrderController extends BaseController
             'type' => 1
         ]);
         if(!$order) return $this->error(['msg' => '订单创建失败']);
-        Notification::send($order->id);
         $order->updateOrderDevices($request->input('devices'));
+        Notification::send($order->id);
 
         return $this->success();
     }
@@ -314,6 +314,7 @@ class OrderController extends BaseController
         $user = Auth::guard('mini')->user();
         $project_role = ProjectRole::getCreateRole('rent', $request->input('is_draft'));
         $option = Option::get('orders', 'status', 'checking');
+
         $res = $order->update([
             'work_point_id' => $request->input('work_point_id'),
             'remark' => $request->input('remark'),
@@ -326,6 +327,7 @@ class OrderController extends BaseController
         ]);
         if(!$res) return $this->error(['msg' => '订单修改失败']);
         $order->updateOrderDevices($request->input('devices'));
+        Notification::send($order->id);
         return $this->success();
     }
 

+ 15 - 6
app/Models/Notification.php

xqd xqd xqd
@@ -28,8 +28,12 @@ class Notification extends BaseModel
         } else if($order['status'] == $pass_id) {
             // 租赁完成,调用完成
             if($order['type'] == 1) {
-                // 租赁完成
-                $project_role_ids = ProjectRole::whereIn('key', ['manager'])->pluck('id');
+                // 租赁完成 经理通过后给工区负责人发消息
+                if($order->level== 4 && $order->status == 2 ){
+                      $project_role_ids = ProjectRole::whereIn('key', ['work'])->pluck('id');
+                }
+                //老逻辑 审核状态都通知项目经理
+                //$project_role_ids = ProjectRole::whereIn('key', ['manager'])->pluck('id');
             } else if($order['is_change' == 2]) {
                 // 调用完成且未修改
                 $project_role_ids = ProjectRole::whereIn('key', ['admin'])->pluck('id');
@@ -45,9 +49,15 @@ class Notification extends BaseModel
             $project_role_ids = ProjectRole::whereIn('key', ['machine', 'admin'])->pluck('id');
         }
         if(count($project_role_ids) > 0) {
-            $user_ids = ProjectUser::where([
-                ['project_id', $order['project_id']]
-            ])->whereIn('project_role_id', $project_role_ids)->pluck('user_id');
+            //如果拒绝只给创建人提醒
+            if($order->status == 4){
+                $user_ids = [$order['user_id']];
+            } else {
+                $user_ids = ProjectUser::where([
+                    ['project_id', $order['project_id']]
+                ])->whereIn('project_role_id', $project_role_ids)->pluck('user_id');
+            }
+
         }
         // 外部租赁
         if($order['type'] == 1) {
@@ -65,7 +75,6 @@ class Notification extends BaseModel
                 $status = 5;
             }
         } else {
-            // 调用
             // 调用成功
             if($order['status'] == $checked_id && $role && $last_role && in_array($last_role['key'], ['admin', 'sub'])) {
                 $status = $order['is_change'] == 1 ? 7 : 1;