|
@@ -345,10 +345,26 @@ class UserService
|
|
} else if ($userInfo->type == 3) {
|
|
} else if ($userInfo->type == 3) {
|
|
//判客账户
|
|
//判客账户
|
|
$ids = Consultant::pluck('id')->toArray();
|
|
$ids = Consultant::pluck('id')->toArray();
|
|
|
|
+ } else if ($userInfo->type == 4) {
|
|
|
|
+ //外渠账号
|
|
|
|
+ $ids[] = $userId;
|
|
}
|
|
}
|
|
return $ids;
|
|
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: 首页统计分析
|
|
* Notes: 首页统计分析
|
|
* User: yb
|
|
* User: yb
|
|
@@ -361,6 +377,7 @@ class UserService
|
|
$userIds = self::getIds();
|
|
$userIds = self::getIds();
|
|
$currentTime = time();
|
|
$currentTime = time();
|
|
$diffNums = CustomService::DIFF_TIME;
|
|
$diffNums = CustomService::DIFF_TIME;
|
|
|
|
+ $userType = self::getUserType();
|
|
|
|
|
|
$whereFollow = [
|
|
$whereFollow = [
|
|
[function($query) use ($userIds) {
|
|
[function($query) use ($userIds) {
|
|
@@ -371,12 +388,14 @@ class UserService
|
|
$where[] = [function($query) use ($userIds) {
|
|
$where[] = [function($query) use ($userIds) {
|
|
$query->orWhereIn('consultant_id', $userIds)->orWhereIn('report_consultant_id', $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();
|
|
$customNums = MarketCustomer::where($where)->count();
|
|
if (!empty($params['time'])) {
|
|
if (!empty($params['time'])) {
|
|
@@ -470,16 +489,19 @@ class UserService
|
|
$diffNums = CustomService::DIFF_TIME;
|
|
$diffNums = CustomService::DIFF_TIME;
|
|
//统计客户总数
|
|
//统计客户总数
|
|
$userIds = self::getIds();
|
|
$userIds = self::getIds();
|
|
|
|
+ $userType = self::getUserType();
|
|
$where = [
|
|
$where = [
|
|
[function($query) use ($userIds) {
|
|
[function($query) use ($userIds) {
|
|
$query->whereIn('consultant_id', $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)")
|
|
$query->orWhereRaw("check_status IN (-1, 1)")
|
|
->orWhereRaw("check_status = 2 AND current_status IN (-1,3,4)")
|
|
->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)");
|
|
- }]
|
|
|
|
- ];
|
|
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
$whereTrend = [];
|
|
$whereTrend = [];
|
|
if (!empty($params['type'])) {
|
|
if (!empty($params['type'])) {
|
|
$whereTrend[] = ['current_status', '=', $params['type']];
|
|
$whereTrend[] = ['current_status', '=', $params['type']];
|