|
|
|
@ -69,12 +69,12 @@ class ReportCommunity extends EloquentRepository |
|
|
|
if(empty($startTime)){ |
|
|
|
$startTime = '2020-07-01 00:00:00'; |
|
|
|
}else{ |
|
|
|
$startTime = $startTime . '00:00:00'; |
|
|
|
$startTime = $startTime . ' 00:00:00'; |
|
|
|
} |
|
|
|
if(empty($endTime)){ |
|
|
|
$endTime = $nowDay . '23:59:59'; |
|
|
|
$endTime = $nowDay . ' 23:59:59'; |
|
|
|
}else{ |
|
|
|
$endTime = $endTime . '23:59:59'; |
|
|
|
$endTime = $endTime . ' 23:59:59'; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取懒族员工
|
|
|
|
@ -90,7 +90,7 @@ class ReportCommunity extends EloquentRepository |
|
|
|
'data' => $list |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!isset($employeeList['data']) || count($employeeList['data']) <= 0 ) { |
|
|
|
return $employeeList; |
|
|
|
} |
|
|
|
@ -102,8 +102,8 @@ class ReportCommunity extends EloquentRepository |
|
|
|
$query->where('person_id', '=', $employee['user_id']) |
|
|
|
->orWhere('user_id', '=', $employee['user_id']); |
|
|
|
}) |
|
|
|
->where('created_at', '>=', strtotime($startTime ?? 0)) |
|
|
|
->where('created_at', '<=', strtotime($endTime ?? 0)) |
|
|
|
->where('created_at', '>=', strtotime($startTime)) |
|
|
|
->where('created_at', '<=', strtotime($endTime)) |
|
|
|
->count(); |
|
|
|
|
|
|
|
// 查询名下所有的服务点
|
|
|
|
@ -112,49 +112,46 @@ class ReportCommunity extends EloquentRepository |
|
|
|
->orWhere('user_id', '=', $employee['user_id']); |
|
|
|
}) |
|
|
|
->get() |
|
|
|
->map(function ($value) {return (array)$value;}) |
|
|
|
->toArray(); |
|
|
|
|
|
|
|
// 新增绑定用户数 Statistics
|
|
|
|
$newBindUserCount = UserRelationBindModel::where('bind_type', '=', 1) |
|
|
|
->whereIn('source_id', array_values(array_column($allCsInfos, 'admin_user_id'))) |
|
|
|
->where('created_at', '>=', strtotime($startTime ?? 0)) |
|
|
|
->where('created_at', '<=', strtotime($endTime ?? 0)) |
|
|
|
->where('created_at', '>=', strtotime($startTime)) |
|
|
|
->where('created_at', '<=', strtotime($endTime)) |
|
|
|
->count(); |
|
|
|
|
|
|
|
// 查询名下所有服务点的所有用户
|
|
|
|
$allCsBindUsers = UserRelationBindModel::where('bind_type', '=', 1) |
|
|
|
->whereIn('source_id', array_values(array_column($allCsInfos, 'admin_user_id'))) |
|
|
|
->get() |
|
|
|
->map(function ($value) {return (array)$value;}) |
|
|
|
->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
// 平台新增用户数 Statistics
|
|
|
|
$platNewUsers = OrderMainModel::select('user_id') |
|
|
|
->where('type', '=', 1) |
|
|
|
->whereIn('state', [4,5,10,11]) |
|
|
|
->where('type', '=', OrderMainModel::ORDER_TYPE_ONLINE) |
|
|
|
->whereIn('state', OrderMainModel::ORDER_STATE_FINISH) |
|
|
|
->whereIn('user_id', array_values(array_column($allCsBindUsers, 'user_id'))) |
|
|
|
->groupBy('user_id') |
|
|
|
->havingRaw('MIN(created_at)>='.strtotime($startTime ?? 0).' AND MIN(created_at)<='.strtotime($endTime ?? 0).'') |
|
|
|
->havingRaw('MIN(created_at)>='.strtotime($startTime).' AND MIN(created_at)<='.strtotime($endTime).'') |
|
|
|
->get() |
|
|
|
->map(function ($value) {return (array)$value;}) |
|
|
|
->toArray(); |
|
|
|
$platNewUserCount = count($platNewUsers); |
|
|
|
|
|
|
|
// 所有用户产生的线上订单数 Statistics
|
|
|
|
$totalOrdersCount = OrderMainModel::where('type', '=', 1) |
|
|
|
->whereIn('state', [4,5,10,11]) |
|
|
|
$totalOrdersCount = OrderMainModel::where('type', '=', OrderMainModel::ORDER_TYPE_ONLINE) |
|
|
|
->whereIn('state', OrderMainModel::ORDER_STATE_FINISH) |
|
|
|
->whereIn('user_id', array_values(array_column($allCsBindUsers, 'user_id'))) |
|
|
|
->where('created_at', '>=', strtotime($startTime ?? 0)) |
|
|
|
->where('created_at', '<=', strtotime($endTime ?? 0)) |
|
|
|
->where('created_at', '>=', strtotime($startTime)) |
|
|
|
->where('created_at', '<=', strtotime($endTime)) |
|
|
|
->count(); |
|
|
|
|
|
|
|
// 平台新增用户产生的线上订单数 Statistics
|
|
|
|
$platNewUserOrdersCount =OrderMainModel::where('type', '=', 1) |
|
|
|
->whereIn('state', [4,5,10,11]) |
|
|
|
$platNewUserOrdersCount =OrderMainModel::where('type', '=', OrderMainModel::ORDER_TYPE_ONLINE) |
|
|
|
->whereIn('state', OrderMainModel::ORDER_STATE_FINISH) |
|
|
|
->whereIn('user_id', array_values(array_column($platNewUsers, 'user_id'))) |
|
|
|
->where('created_at', '>=', strtotime($startTime ?? 0)) |
|
|
|
->where('created_at', '<=', strtotime($endTime ?? 0)) |
|
|
|
->where('created_at', '>=', strtotime($startTime)) |
|
|
|
->where('created_at', '<=', strtotime($endTime)) |
|
|
|
->count(); |
|
|
|
|
|
|
|
$employee['new_cs_count'] = $newCsCount; |
|
|
|
|