|
@@ -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']];
|