Bläddra i källkod

外渠人员功能调整

yb 1 vecka sedan
förälder
incheckning
25ec5f2aca

+ 2 - 2
app/admin/service/consultant/ConsultantService.php

@@ -112,7 +112,7 @@ class ConsultantService
         }
         $type = 2;
         if (!empty($params['type'])) {
-            if (in_array($params['type'], [1,2,3])) {
+            if (in_array($params['type'], [1,2,3,4])) {
                 $type = $params['type'];
                 if ($type != 1) {
                     $params['relation_user_id'] = null;
@@ -179,7 +179,7 @@ class ConsultantService
         }
         $type = 2;
         if (!empty($params['type'])) {
-            if (in_array($params['type'], [1,2,3])) {
+            if (in_array($params['type'], [1,2,3,4])) {
                 $type = $params['type'];
                 if ($type != 1) {
                     $params['relation_user_id'] = null;

+ 7 - 7
app/admin/service/consultant/CustomService.php

@@ -81,16 +81,16 @@ class CustomService
             }];
         }
         if (!empty($params['consultant_name'])) {
-            $consultantIds = Consultant::where('name', 'like', "%{$params['consultant_name']}%")
-                ->where('mobile', 'like', "%{$params['consultant_name']}%")
+            $consultantIds = Consultant::orWhere('name', 'like', "%{$params['consultant_name']}%")
+                ->orWhere('mobile', 'like', "%{$params['consultant_name']}%")
                 ->pluck('id')->toArray();
             $where[] = [function($query) use ($consultantIds) {
                 $query->whereIn('consultant_id', $consultantIds);
             }];
         }
         if (!empty($params['report_name'])) {
-            $consultantIds = Consultant::where('name', 'like', "%{$params['report_name']}%")
-                ->where('mobile', 'like', "%{$params['report_name']}%")
+            $consultantIds = Consultant::orWhere('name', 'like', "%{$params['report_name']}%")
+                ->orWhere('mobile', 'like', "%{$params['report_name']}%")
                 ->pluck('id')->toArray();
             $where[] = [function($query) use ($consultantIds) {
                 $query->whereIn('report_consultant_id', $consultantIds);
@@ -1294,9 +1294,9 @@ class CustomService
                                 'create_consultant_id' => $reportConsultantId,
                                 'dept_id' => $deptId ?? 0,
                                 'belong_status' => 1,
-                                'current_status' => 2,
-                                'check_status' => 2,
-                                'check_note' => '导入的客户信息,无审核人员',
+                                'current_status' => 1,
+                                'check_status' => 1,
+                                'check_note' => '',
                                 'type' => 1,
                                 'visit_time' => strtotime($val[0]),
                                 'created_at' => strtotime($val[0])

+ 21 - 6
app/wechat/service/CustomService.php

@@ -66,11 +66,21 @@ class CustomService
                 $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
             }];
         } else {
-            $where[] = [function($query) use ($diffNums, $currentTime){
-                $query->orWhereRaw("check_status IN (-1, 1)")
-                    ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
-                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
-            }];
+            if ($type == 4) {
+                $where[] = [function($query) use ($diffNums, $currentTime){
+                    $query->orWhereRaw("check_status IN (-1, 1)")
+                        ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
+                        ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)")
+                        ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2)");
+                }];
+            } else {
+                $where[] = [function($query) use ($diffNums, $currentTime){
+                    $query->orWhereRaw("check_status IN (-1, 1)")
+                        ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
+                        ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
+                }];
+            }
+
         }
         if ($type == 1) {
             //团队下所有的
@@ -97,9 +107,14 @@ class CustomService
                 $query->orWhere('consultant_id', $consultantId)->orWhere('report_consultant_id', $consultantId);
             }];
             $whereFollow[] = ['consultant_id', '=', $consultantId];
-        } else {
+        } else if ($type == 3){
             //所有团队的
 
+        } else if ($type == 4) {
+            //查询渠道人员
+            $where[] = [function($query) use ($consultantId) {
+                $query->orWhere('consultant_id', $consultantId)->orWhere('report_consultant_id', $consultantId);
+            }];
         }
         if (!empty($params['search_type'])) {
             $searchType = $params['search_type'];

+ 32 - 10
app/wechat/service/UserService.php

@@ -345,10 +345,26 @@ class UserService
         } else if ($userInfo->type == 3) {
             //判客账户
             $ids = Consultant::pluck('id')->toArray();
+        } else if ($userInfo->type == 4) {
+            //外渠账号
+            $ids[] = $userId;
         }
         return $ids;
     }
 
+    /**
+     * Notes: 获取用户类型
+     * User: yb
+     * Date: 2024/9/13
+     * Time: 13:57
+     * @return mixed
+     */
+    public static function getUserType()
+    {
+        $userId = JwtToken::getCurrentId();
+        return Consultant::where('id', $userId)->value('type');
+    }
+
     /**
      * Notes: 首页统计分析
      * User: yb
@@ -361,6 +377,7 @@ class UserService
         $userIds = self::getIds();
         $currentTime = time();
         $diffNums = CustomService::DIFF_TIME;
+        $userType = self::getUserType();
 
         $whereFollow = [
             [function($query) use ($userIds) {
@@ -371,12 +388,14 @@ class UserService
         $where[] = [function($query) use ($userIds) {
             $query->orWhereIn('consultant_id', $userIds)->orWhereIn('report_consultant_id', $userIds);
         }];
-        $where[] = [function($query) use ($diffNums, $currentTime){
-            $query->orWhereRaw("check_status IN (-1, 1)")
-                ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
-                ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)")
-                ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
-        }];
+        if ($userType != 4) {
+            $where[] = [function($query) use ($diffNums, $currentTime){
+                $query->orWhereRaw("check_status IN (-1, 1)")
+                    ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
+                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)")
+                    ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
+            }];
+        }
         //客户总量
         $customNums = MarketCustomer::where($where)->count();
         if (!empty($params['time'])) {
@@ -470,16 +489,19 @@ class UserService
         $diffNums = CustomService::DIFF_TIME;
         //统计客户总数
         $userIds = self::getIds();
+        $userType = self::getUserType();
         $where = [
             [function($query) use ($userIds) {
                 $query->whereIn('consultant_id', $userIds);
-            }],
-            [function($query) use ($diffNums, $currentTime){
+            }]
+        ];
+        if ($userType != 4) {
+            $where[] = [function($query) use ($diffNums, $currentTime){
                 $query->orWhereRaw("check_status IN (-1, 1)")
                     ->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
                     ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
-            }]
-        ];
+            }];
+        }
         $whereTrend = [];
         if (!empty($params['type'])) {
             $whereTrend[] = ['current_status', '=', $params['type']];