|
@@ -17,6 +17,7 @@ use App\Models\Inquiry\InquiryRelayDetail; |
|
@@ -17,6 +17,7 @@ use App\Models\Inquiry\InquiryRelayDetail; |
|
17
|
use App\Models\Inquiry\InquiryRelayDetailLog;
|
17
|
use App\Models\Inquiry\InquiryRelayDetailLog;
|
|
18
|
use App\Models\Manage\Manage;
|
18
|
use App\Models\Manage\Manage;
|
|
19
|
use Illuminate\Support\Arr;
|
19
|
use Illuminate\Support\Arr;
|
|
|
|
20
|
+use Illuminate\Support\Facades\Cache;
|
|
20
|
use Illuminate\Support\Facades\DB;
|
21
|
use Illuminate\Support\Facades\DB;
|
|
21
|
use Illuminate\Support\Str;
|
22
|
use Illuminate\Support\Str;
|
|
22
|
|
23
|
|
|
@@ -525,53 +526,60 @@ class InquiryForwardLogic extends BaseLogic |
|
@@ -525,53 +526,60 @@ class InquiryForwardLogic extends BaseLogic |
|
525
|
*/
|
526
|
*/
|
|
526
|
public function inquiryManageCount()
|
527
|
public function inquiryManageCount()
|
|
527
|
{
|
528
|
{
|
|
528
|
- $manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray();
|
|
|
|
529
|
- $manageModel = new Manage();
|
|
|
|
530
|
-
|
|
|
|
531
|
- //月统计
|
|
|
|
532
|
- $data_month = [];
|
|
|
|
533
|
- $data_month_total = [];
|
|
|
|
534
|
- $now_month = date('Y-m');
|
|
|
|
535
|
- $last_year_month = date('Y-m', strtotime('-11 months'));
|
|
|
|
536
|
- while ($last_year_month <= $now_month) {
|
|
|
|
537
|
- $month_arr = explode('-', $last_year_month);
|
|
|
|
538
|
- $year = $month_arr[0];
|
|
|
|
539
|
- $month = $month_arr[1];
|
|
|
|
540
|
-
|
|
|
|
541
|
- foreach ($manage_ids as $mid) {
|
|
|
|
542
|
- $name = $manageModel->getName($mid);
|
|
|
|
543
|
- $month_count = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0);
|
|
|
|
544
|
- $data_month_total[$name] = ($data_month_total[$name] ?? 0) + $month_count;
|
|
|
|
545
|
- $data_month[$last_year_month][$name] = $month_count;
|
529
|
+ $data = Cache::get('inquiry_manage_count');
|
|
|
|
530
|
+ if (!$data) {
|
|
|
|
531
|
+ $manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray();
|
|
|
|
532
|
+ $manageModel = new Manage();
|
|
|
|
533
|
+
|
|
|
|
534
|
+ //月统计
|
|
|
|
535
|
+ $data_month = [];
|
|
|
|
536
|
+ $data_month_total = [];
|
|
|
|
537
|
+ $now_month = date('Y-m');
|
|
|
|
538
|
+ $last_year_month = date('Y-m', strtotime('-11 months'));
|
|
|
|
539
|
+ while ($last_year_month <= $now_month) {
|
|
|
|
540
|
+ $month_arr = explode('-', $last_year_month);
|
|
|
|
541
|
+ $year = $month_arr[0];
|
|
|
|
542
|
+ $month = $month_arr[1];
|
|
|
|
543
|
+
|
|
|
|
544
|
+ foreach ($manage_ids as $mid) {
|
|
|
|
545
|
+ $name = $manageModel->getName($mid);
|
|
|
|
546
|
+ $month_count = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0);
|
|
|
|
547
|
+ $data_month_total[$name] = ($data_month_total[$name] ?? 0) + $month_count;
|
|
|
|
548
|
+ $data_month[$last_year_month][$name] = $month_count;
|
|
|
|
549
|
+ }
|
|
|
|
550
|
+
|
|
|
|
551
|
+ $last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month'));
|
|
546
|
}
|
552
|
}
|
|
|
|
553
|
+ $data_month['total'] = $data_month_total;
|
|
|
|
554
|
+
|
|
|
|
555
|
+
|
|
|
|
556
|
+ //周统计
|
|
|
|
557
|
+ $data_week = [];
|
|
|
|
558
|
+ $data_week_total = [];
|
|
|
|
559
|
+ $now_day = date('Y-m-d');
|
|
|
|
560
|
+ $last_week_day = date('Y-m-d', strtotime('-1 week'));
|
|
|
|
561
|
+ while ($last_week_day < $now_day) {
|
|
|
|
562
|
+ $day_arr = explode('-', $last_week_day);
|
|
|
|
563
|
+ $year = $day_arr[0];
|
|
|
|
564
|
+ $month = $day_arr[1];
|
|
|
|
565
|
+ $day = $day_arr[2];
|
|
|
|
566
|
+
|
|
|
|
567
|
+ foreach ($manage_ids as $mid) {
|
|
|
|
568
|
+ $name = $manageModel->getName($mid);
|
|
|
|
569
|
+ $day_count = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0;
|
|
|
|
570
|
+ $data_week_total[$name] = ($data_week_total[$name] ?? 0) + $day_count;
|
|
|
|
571
|
+ $data_week[substr($last_week_day, 5)][$name] = $day_count;
|
|
|
|
572
|
+ }
|
|
547
|
|
573
|
|
|
548
|
- $last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month'));
|
|
|
|
549
|
- }
|
|
|
|
550
|
- $data_month['total'] = $data_month_total;
|
|
|
|
551
|
-
|
|
|
|
552
|
-
|
|
|
|
553
|
- //周统计
|
|
|
|
554
|
- $data_week = [];
|
|
|
|
555
|
- $data_week_total = [];
|
|
|
|
556
|
- $now_day = date('Y-m-d');
|
|
|
|
557
|
- $last_week_day = date('Y-m-d', strtotime('-1 week'));
|
|
|
|
558
|
- while ($last_week_day < $now_day) {
|
|
|
|
559
|
- $day_arr = explode('-', $last_week_day);
|
|
|
|
560
|
- $year = $day_arr[0];
|
|
|
|
561
|
- $month = $day_arr[1];
|
|
|
|
562
|
- $day = $day_arr[2];
|
|
|
|
563
|
-
|
|
|
|
564
|
- foreach ($manage_ids as $mid) {
|
|
|
|
565
|
- $name = $manageModel->getName($mid);
|
|
|
|
566
|
- $day_count = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0;
|
|
|
|
567
|
- $data_week_total[$name] = ($data_week_total[$name] ?? 0) + $day_count;
|
|
|
|
568
|
- $data_week[substr($last_week_day, 5)][$name] = $day_count;
|
574
|
+ $last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day'));
|
|
569
|
}
|
575
|
}
|
|
|
|
576
|
+ $data_week['total'] = $data_week_total;
|
|
|
|
577
|
+
|
|
|
|
578
|
+ $data = ['data_month' => $data_month, 'data_week' => $data_week];
|
|
570
|
|
579
|
|
|
571
|
- $last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day'));
|
580
|
+ Cache::add('inquiry_manage_count', $data);
|
|
572
|
}
|
581
|
}
|
|
573
|
- $data_week['total'] = $data_week_total;
|
|
|
|
574
|
|
582
|
|
|
575
|
- return $this->success(['data_month' => $data_month, 'data_week' => $data_week]);
|
583
|
+ return $this->success($data);
|
|
576
|
}
|
584
|
}
|
|
577
|
} |
585
|
} |