From 41ff5249944186ca70a4425e498c1eb314cc07ae Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Fri, 27 Nov 2020 14:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E4=BB=A3=E7=90=86=E7=82=B9?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1--=E4=BF=AE=E6=94=B9=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Repositories/v3/ReportCommunity.php | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Admin/Repositories/v3/ReportCommunity.php b/app/Admin/Repositories/v3/ReportCommunity.php index 6f7f6ee..c1fe04f 100644 --- a/app/Admin/Repositories/v3/ReportCommunity.php +++ b/app/Admin/Repositories/v3/ReportCommunity.php @@ -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,49 @@ class ReportCommunity extends EloquentRepository ->orWhere('user_id', '=', $employee['user_id']); }) ->get() - ->map(function ($value) {return (array)$value;}) + // ->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;}) + // ->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;