|
@@ -172,13 +172,18 @@ class ApiService{
|
|
|
}
|
|
|
|
|
|
if ($date_type == 'month') {
|
|
|
- $query = $query->where(DB::raw('MONTH(lrsj)'), DB::raw('MONTH(CURDATE())'));
|
|
|
+ $start_date = date('Y-m-01') . ' 00:00:00';
|
|
|
+ $end_date = date('Y-m-t') . ' 23:59:59';
|
|
|
} else if ($date_type = 'quarter') {
|
|
|
- $query = $query->where(DB::raw('QUARTER(lrsj)'), DB::raw('QUARTER(CURDATE())'));
|
|
|
+ $start_date = self::GetInceDay() . ' 00:00:00';
|
|
|
+ $end_date = self::GetEndDay() . ' 23:59:59';
|
|
|
} else {
|
|
|
- $query = $query->where(DB::raw('WEEK(lrsj)'), DB::raw('WEEK(CURDATE())'));
|
|
|
+ $start_date = date('Y-m-d', strtotime('this week monday')) . ' 00:00:00';
|
|
|
+ $end_date = date('Y-m-d', strtotime('this week sunday')) . ' 23:59:59';
|
|
|
}
|
|
|
|
|
|
+ $query = $query->where('lrsj', '>=', $start_date)->where('lrsj', '<=', $end_date);
|
|
|
+
|
|
|
$query = $query->groupBy('lrdate', 'xjdw', 'lrr', 'dwmc')
|
|
|
->select(
|
|
|
[
|
|
@@ -437,4 +442,48 @@ class ApiService{
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
+
|
|
|
+ protected static function GetInceDay()
|
|
|
+ {
|
|
|
+ $month = date("m");
|
|
|
+ if ($month >=1 && $month < 4)
|
|
|
+ {
|
|
|
+ return date('Y') . '-01-01';
|
|
|
+ }
|
|
|
+ else if ($month >= 4 && $month < 7)
|
|
|
+ {
|
|
|
+ return date('Y') . '-04-01';
|
|
|
+ }
|
|
|
+ else if ($month >= 7 && $month < 10)
|
|
|
+ {
|
|
|
+ return date('Y') . '-07-01';
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return date('Y') . '-10-01';
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ protected static function GetEndDay()
|
|
|
+ {
|
|
|
+ $month = date("m");
|
|
|
+ if ($month >= 1 && $month < 4)
|
|
|
+ {
|
|
|
+ return date('Y') . '-03-31';
|
|
|
+ }
|
|
|
+ else if ($month >= 4 && $month < 7)
|
|
|
+ {
|
|
|
+ return date('Y') . '-06-30';
|
|
|
+ }
|
|
|
+ else if ($month >= 7 && $month < 10)
|
|
|
+ {
|
|
|
+ return date('Y') . '-09-30';
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return date('Y') . '-12-31';
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|