|
@@ -65,6 +65,12 @@ class CustomService
|
|
|
$query->orWhere('name', 'like', "%{$keywords}%")->orWhere('mobile', 'like', "%{$keywords}%");
|
|
|
}];
|
|
|
}
|
|
|
+ if (!empty($params['mobile'])) {
|
|
|
+ $mobile = $params['mobile'];
|
|
|
+ $where[] = [function($query) use ($mobile) {
|
|
|
+ $query->where('mobile', 'like', "%{$mobile}%");
|
|
|
+ }];
|
|
|
+ }
|
|
|
if (!empty($params['report_status'])) {
|
|
|
if ($params['report_status'] == -1) {
|
|
|
//待审核
|
|
@@ -162,6 +168,42 @@ class CustomService
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
+ if (isset($params['require_area'])) {
|
|
|
+ if (is_numeric($params['require_area'])) {
|
|
|
+ $where[] = ['require_area', '=', ($params['require_area'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['requirement'])) {
|
|
|
+ if (is_numeric($params['requirement'])) {
|
|
|
+ $where[] = ['requirement', '=', ($params['requirement'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['age_range'])) {
|
|
|
+ if (is_numeric($params['age_range'])) {
|
|
|
+ $where[] = ['age_range', '=', ($params['age_range'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['visit_type'])) {
|
|
|
+ if (is_numeric($params['visit_type'])) {
|
|
|
+ $where[] = ['visit_type', '=', $params['visit_type']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['region'])) {
|
|
|
+ if (is_numeric($params['region'])) {
|
|
|
+ $where[] = ['region', '=', ($params['region'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['purpose'])) {
|
|
|
+ if (is_numeric($params['purpose'])) {
|
|
|
+ $where[] = ['purpose', '=', ($params['purpose'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($params['level'])) {
|
|
|
+ if (is_numeric($params['level'])) {
|
|
|
+ $where[] = ['level', '=', ($params['level'] + 1)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return $where;
|
|
|
}
|
|
|
|
|
@@ -790,6 +832,64 @@ class CustomService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Notes: 前12个月统计数据
|
|
|
+ * User: yb
|
|
|
+ * Date: 2024/8/21
|
|
|
+ * Time: 15:56
|
|
|
+ */
|
|
|
+ public static function statisticsMonth()
|
|
|
+ {
|
|
|
+ $months = month_12();
|
|
|
+ sort($months);
|
|
|
+ $startDate = $months[0];
|
|
|
+ $startDateTime = strtotime($startDate.'/01 00:00:00');
|
|
|
+ $endDateTime = time();
|
|
|
+ $where = [
|
|
|
+ ['created_at', '>=', $startDateTime],
|
|
|
+ ['created_at', '<=', $endDateTime]
|
|
|
+ ];
|
|
|
+ $currentTime = time();
|
|
|
+ $diffNums = self::DIFF_TIME;
|
|
|
+ $deptIds = TeamService::getIdsByUser();
|
|
|
+ if (false === $deptIds) {
|
|
|
+ //无权限
|
|
|
+ $where[] = ['dept_id', '=', 0];
|
|
|
+ } else if (is_array($deptIds)) {
|
|
|
+ //指定团队下的权限
|
|
|
+ if (!empty($params['dept_id'])) {
|
|
|
+ $deptId = end($params['dept_id']);
|
|
|
+ $deptIds = SysDept::where('dept_super_path','like', "%/{$deptId}/%")->where('dept_category', '=', TeamService::DEPT_CATEGORY)->pluck('dept_id')->toArray();
|
|
|
+ }
|
|
|
+ $where[] = [function($query) use ($deptIds) {
|
|
|
+ $query->whereIn('dept_id', $deptIds);
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ if (!empty($params['dept_id'])) {
|
|
|
+ $deptId = end($params['dept_id']);
|
|
|
+ $deptIds = SysDept::where('dept_super_path','like', "%/{$deptId}/%")->where('dept_category', '=', TeamService::DEPT_CATEGORY)->pluck('dept_id')->toArray();
|
|
|
+ $where[] = [function($query) use ($deptIds) {
|
|
|
+ $query->whereIn('dept_id', $deptIds);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $selectRaw = Db::raw("DATE_FORMAT(FROM_UNIXTIME(created_at), '%Y/%m') as date,count(*) as nums");
|
|
|
+ $groupRaw = Db::raw("DATE_FORMAT(FROM_UNIXTIME(created_at), '%Y/%m')");
|
|
|
+ $totalData = MarketCustomer::where($where)->selectRaw($selectRaw)->groupByRaw($groupRaw)->get();
|
|
|
+ $payData = MarketCustomer::where($where)->where([['current_status', '=', 3], ['check_status', '=', 2]])->selectRaw($selectRaw)->groupByRaw($groupRaw)->get();
|
|
|
+ $visitData = MarketCustomer::where($where)->where([['current_status', '=', 2], ['check_status', '=', 2]])->selectRaw($selectRaw)->groupByRaw($groupRaw)->get();
|
|
|
+ $dealData = MarketCustomer::where($where)->where([['current_status', '=', 4], ['check_status', '=', 2]])->selectRaw($selectRaw)->groupByRaw($groupRaw)->get();
|
|
|
+ $returnData = [
|
|
|
+ 'total' => $totalData->pluck('nums','date'),
|
|
|
+ 'pay' => $payData->pluck('nums','date'),
|
|
|
+ 'visit' => $visitData->pluck('nums','date'),
|
|
|
+ 'deal' => $dealData->pluck('nums','date'),
|
|
|
+ 'date' => $months
|
|
|
+ ];
|
|
|
+ return json_success('请求成功', $returnData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Notes: 导出数据
|
|
|
* User: yb
|