|
@@ -856,6 +856,8 @@ class CustomService
|
|
|
return json_fail('客户已经存在');
|
|
|
}
|
|
|
}
|
|
|
+ //查询顾问的团队信息
|
|
|
+ $deptId = Consultant::where('id', $params['consultant_id'])->value('dept_id');
|
|
|
$result = false;
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
@@ -869,6 +871,7 @@ class CustomService
|
|
|
//更新到访保护期时间
|
|
|
$info->visit_time = time();
|
|
|
}
|
|
|
+ $info->dept_id = $deptId ?? 0;
|
|
|
$info->consultant_id = $params['consultant_id'];
|
|
|
$info->check_time = time();
|
|
|
$info->check_admin_id = $adminId;
|
|
@@ -1053,47 +1056,49 @@ class CustomService
|
|
|
$returnData = [];
|
|
|
$genderData = ['', '男', '女'];
|
|
|
$typeData = ['', '来电', '来访'];
|
|
|
- $currentStatusData = [-1 => '无效客户', 1 => '已来电', 2 => '已到访', 3 => '已缴费', 4 => '已成交'];
|
|
|
+ $currentStatusData = [-1 => '报备失败', 1 => '已报备', 2 => '已到访', 3 => '已缴费', 4 => '已成交'];
|
|
|
+ $textConfig = self::config();
|
|
|
+ //合并数组并去重
|
|
|
+ $type1 = $textConfig['visit_type']['type1'] ?? [];
|
|
|
+ $type2 = $textConfig['visit_type']['type2'] ?? [];
|
|
|
+ $textTypeKeys = [];
|
|
|
+ foreach ($type1 as $k1 => $v1) {
|
|
|
+ $textTypeKeys[$k1] = $v1;
|
|
|
+ }
|
|
|
+ foreach ($type2 as $k2 => $v2) {
|
|
|
+ $textTypeKeys[$k2] = $v2;
|
|
|
+ }
|
|
|
foreach ($list as &$item) {
|
|
|
$visitTime = $item->visit_time;
|
|
|
$visitTimeStamp = strtotime($visitTime);
|
|
|
$diff = ($visitTimeStamp + $diffNums) - $currentTime;
|
|
|
$currentStatus = $item->current_status;//当前状态
|
|
|
$checkStatus = $item->check_status;//审核状态
|
|
|
- if ($checkStatus == 1) {
|
|
|
- $currentStatusText = '待审核';
|
|
|
- }
|
|
|
- if ($checkStatus == -1) {
|
|
|
- $currentStatusText = '已失效';
|
|
|
- }
|
|
|
- if ($checkStatus == 2) {
|
|
|
- //审核通过
|
|
|
- if ($currentStatus > 1) {
|
|
|
- $currentStatusText = $currentStatusData[$currentStatus] ?? '';
|
|
|
- }
|
|
|
- if ($currentStatus == 1) {
|
|
|
- if ($diff > 0) {
|
|
|
- $currentStatusText = $currentStatusData[$currentStatus] ?? '';
|
|
|
- } else {
|
|
|
- $currentStatusText = '已失效';
|
|
|
- }
|
|
|
- }
|
|
|
- if ($currentStatus == -1) {
|
|
|
- $currentStatusText = '无效客户';
|
|
|
- }
|
|
|
+ if ($diff <= 0 && $checkStatus == 2 && $currentStatus > 1) {
|
|
|
+ $currentStatusText = '公池';
|
|
|
+ } else {
|
|
|
+ $currentStatusText = $currentStatusData[$item->current_status] ?? '';
|
|
|
}
|
|
|
+ $ageRangeText = $item->age_range > 0 ? $textConfig['age_range'][$item->age_range - 1] ?? '' : '';
|
|
|
+ $levelText = $item->level > 0 ? $textConfig['level'][$item->level - 1] ?? '' : '';
|
|
|
+ $regionText = $item->region > 0 ? $textConfig['region'][$item->region - 1] ?? '' : '';
|
|
|
+ $visitTypeText = $textTypeKeys[$item->visit_type] ?? '';
|
|
|
+
|
|
|
$returnData[] = [
|
|
|
- 'name' => $item->name,
|
|
|
- 'mobile' => $item->mobile,
|
|
|
+ 'name' => $item->name, //客户姓名
|
|
|
+ 'mobile' => $item->mobile, //客户电话
|
|
|
'mask_mobile' => self::handlePhone($item->mobile),
|
|
|
- 'gender' => $genderData[$item->gender] ?? '',
|
|
|
- 'type' => $typeData[$item->type] ?? '',
|
|
|
- 'consultant_name' => $consultantKeys[$item->consultant_id]['name'] ?? '',
|
|
|
- 'consultant_mobile' => $consultantKeys[$item->consultant_id]['mobile'] ?? '',
|
|
|
- 'team_name' => TeamService::getTeamName($teamKeys, $item->dept_id),
|
|
|
+ 'gender' => $genderData[$item->gender] ?? '', //客户性别
|
|
|
+ "report_consultant_name" => $consultantKeys[$item->report_consultant_id]['name'] ?? '', //报备人
|
|
|
+ 'consultant_name' => $consultantKeys[$item->consultant_id]['name'] ?? '', //健康顾问
|
|
|
+ 'team_name' => TeamService::getTeamName($teamKeys, $item->dept_id), //所属团队
|
|
|
'current_status' => $currentStatusText, //当前状态
|
|
|
- 'visit_time' => $item->visit_time,
|
|
|
- 'created_at' => date('Y-m-d H:i:s',strtotime($item->created_at))
|
|
|
+ 'visit_time' => $item->visit_time, //到访时间
|
|
|
+ "age_range" => $ageRangeText, //年龄区间
|
|
|
+ "level" => $levelText, //客户等级
|
|
|
+ "region" => $regionText, //所在区域
|
|
|
+ "visit_type" => $visitTypeText, //来源
|
|
|
+ 'created_at' => date('Y-m-d H:i:s', strtotime($item->created_at)) //报备时间
|
|
|
];
|
|
|
}
|
|
|
return json_success('请求成功', $returnData);
|