Browse Source

新增营销客户统计搜索条件

yb 6 months ago
parent
commit
bb4d208888

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

@@ -125,6 +125,7 @@ class ConsultantService
             'mobile' => $params['mobile'],
             'dept_id' => $params['dept_id'],
             'top_dept_id' => $topDeptId,
+            'job' => $params['job'] ?? '顾问',
             'gender' => $params['gender'] ?? 1,
             'password' => $password,
             'status' => $params['status'] ?? 1,
@@ -184,6 +185,7 @@ class ConsultantService
         $updateData = [
             'name' => $params['name'],
             'mobile' => $params['mobile'],
+            'job' => $params['job'] ?? '顾问',
             'gender' => $params['gender'] ?? 1,
             'status' => $params['status'] ?? 1,
             'relation_user_id' => $params['relation_user_id'] ?? null,

+ 42 - 0
app/admin/service/consultant/CustomService.php

@@ -65,6 +65,12 @@ class CustomService
                 $query->orWhere('name', 'like', "%{$keywords}%")->orWhere('mobile', 'like', "%{$keywords}%");
             }];
         }
+        if (!empty($params['mobile'])) {
+            $mobile = $params['mobile'];
+            $where[] = [function($query) use ($mobile) {
+                $query->where('mobile', 'like', "%{$mobile}%");
+            }];
+        }
         if (!empty($params['report_status'])) {
             if ($params['report_status'] == -1) {
                 //待审核
@@ -162,6 +168,42 @@ class CustomService
                 }];
             }
         }
+        if (isset($params['require_area'])) {
+            if (is_numeric($params['require_area'])) {
+                $where[] = ['require_area', '=', ($params['require_area'] + 1)];
+            }
+        }
+        if (isset($params['requirement'])) {
+            if (is_numeric($params['requirement'])) {
+                $where[] = ['requirement', '=', ($params['requirement'] + 1)];
+            }
+        }
+        if (isset($params['age_range'])) {
+            if (is_numeric($params['age_range'])) {
+                $where[] = ['age_range', '=', ($params['age_range'] + 1)];
+            }
+        }
+        if (isset($params['visit_type'])) {
+            if (is_numeric($params['visit_type'])) {
+                $where[] = ['visit_type', '=', $params['visit_type']];
+            }
+        }
+        if (isset($params['region'])) {
+            if (is_numeric($params['region'])) {
+                $where[] = ['region', '=', ($params['region'] + 1)];
+            }
+        }
+        if (isset($params['purpose'])) {
+            if (is_numeric($params['purpose'])) {
+                $where[] = ['purpose', '=', ($params['purpose'] + 1)];
+            }
+        }
+        if (isset($params['level'])) {
+            if (is_numeric($params['level'])) {
+                $where[] = ['level', '=', ($params['level'] + 1)];
+            }
+        }
+
         return $where;
     }
 

+ 13 - 0
app/wechat/controller/CustomController.php

@@ -165,4 +165,17 @@ class CustomController extends IndexController
         }
         return CustomService::checkCustom($params);
     }
+
+    /**
+     * Notes: 校验客户是否已经登记
+     * User: yb
+     * Date: 2024/8/21
+     * Time: 9:37
+     * @param Request $request
+     */
+    public function checkMobile(Request $request)
+    {
+        $params = $request->post();
+        return CustomService::checkPhone($params);
+    }
 }

+ 45 - 0
app/wechat/service/CustomService.php

@@ -609,6 +609,51 @@ class CustomService
 
     }
 
+    /**
+     * Notes: 检查客户是否已经登记
+     * User: yb
+     * Date: 2024/8/21
+     * Time: 9:40
+     * @param $params
+     * @return \support\Response
+     */
+    public static function checkPhone($params)
+    {
+        if (empty($params['mobile'])) {
+            return json_fail('请输入联系电话');
+        }
+        $mobile = $params['mobile'];
+        //添加和编辑
+        if (!empty($params['id'])) {
+            //编辑的情况
+            if (false === strpos($mobile,'****')) {
+                //校验手机号格式
+                $validate = new CustomValidate();
+                if (!$validate->scene('phone')->check(['mobile' => $mobile])) {
+                    return  json_fail($validate->getError());
+                }
+                //修改手机号操作
+                if (MarketCustomer::checkCustomExists($mobile, $params['id'])) {
+                    return json_fail('客户已经登记过了');
+                }
+            }
+            return json_success('请求成功',['is_ex' => 2]);
+        } else {
+            $validate = new CustomValidate();
+            if (!$validate->scene('phone')->check(['mobile' => $mobile])) {
+                return  json_fail($validate->getError());
+            }
+            //添加
+            $result = MarketCustomer::checkCustomExists($mobile);
+            if ($result) {
+                $isEx = 1;
+            } else {
+                $isEx = 2;
+            }
+            return json_success('请求成功',['is_ex' => $isEx]);
+        }
+    }
+
     /**
      * Notes: 对手机号加密处理
      * User: yb

+ 9 - 2
app/wechat/service/FollowService.php

@@ -62,6 +62,8 @@ class FollowService
                     $customInfo->current_status = 2;
                 }
             }
+            $customInfo->follow_num = $customInfo->follow_num + 1;
+            $customInfo->level = $insertData['intention_type'];
             $customInfo->visit_time = $insertData['follow_time'];
             $customInfo->save();
             $result = MarketCustomerFollow::insert($insertData);
@@ -89,9 +91,14 @@ class FollowService
         $page = $params['page'] ?? 1;
         $size = $params['size'] ?? 10;
         $ids = UserService::getIds();
+        //查询顾问下的客户信息
+        $customIds = [];
+        if (!empty($ids)) {
+            $customIds = MarketCustomer::whereIn('consultant_id', $ids)->pluck('id')->toArray();
+        }
         $where = [
-            [function($query) use ($ids) {
-            $query->whereIn('consultant_id',$ids);
+            [function($query) use ($customIds) {
+            $query->whereIn('market_customer_id',$customIds);
             }]
         ];
         $whereCustom = [];

+ 1 - 0
route/wechat.php

@@ -28,6 +28,7 @@ Route::group('/wechat',function (){
         Route::post('/move', [\app\wechat\controller\CustomController::class, 'moveCustom']);
         Route::post('/logs', [\app\wechat\controller\CustomController::class, 'moveLogs']);
         Route::post('/check', [\app\wechat\controller\CustomController::class, 'checkCustom']);
+        Route::post('/mobile', [\app\wechat\controller\CustomController::class, 'checkMobile']);
     });
     Route::group('/follow', function () {
         Route::post('/add', [\app\wechat\controller\FollowController::class, 'addFollow']);