合并分支 'akun' 到 'master'
Akun 查看合并请求 !3061
正在显示
1 个修改的文件
包含
24 行增加
和
22 行删除
| @@ -525,30 +525,11 @@ class InquiryForwardLogic extends BaseLogic | @@ -525,30 +525,11 @@ class InquiryForwardLogic extends BaseLogic | ||
| 525 | */ | 525 | */ |
| 526 | public function inquiryManageCount() | 526 | public function inquiryManageCount() |
| 527 | { | 527 | { |
| 528 | - $type = $this->param['type'] ?? 1;//统计类型:1周统计,2月统计 | ||
| 529 | - | ||
| 530 | $manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray(); | 528 | $manage_ids = ForwardCount::select('manage_id')->orderBy('manage_id', 'asc')->distinct()->pluck('manage_id')->toArray(); |
| 531 | $manageModel = new Manage(); | 529 | $manageModel = new Manage(); |
| 532 | - $data = []; | ||
| 533 | - if ($type == 1) { | ||
| 534 | - //周统计 | ||
| 535 | - $now_day = date('Y-m-d'); | ||
| 536 | - $last_week_day = date('Y-m-d', strtotime('-1 week')); | ||
| 537 | - while ($last_week_day < $now_day) { | ||
| 538 | - $day_arr = explode('-', $last_week_day); | ||
| 539 | - $year = $day_arr[0]; | ||
| 540 | - $month = $day_arr[1]; | ||
| 541 | - $day = $day_arr[2]; | ||
| 542 | - | ||
| 543 | - foreach ($manage_ids as $mid) { | ||
| 544 | - $name = $manageModel->getName($mid); | ||
| 545 | - $data[substr($last_week_day, 5)][$name] = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0; | ||
| 546 | - } | ||
| 547 | 530 | ||
| 548 | - $last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day')); | ||
| 549 | - } | ||
| 550 | - } else { | ||
| 551 | //月统计 | 531 | //月统计 |
| 532 | + $data_month = []; | ||
| 552 | $now_month = date('Y-m'); | 533 | $now_month = date('Y-m'); |
| 553 | $last_year_month = date('Y-m', strtotime('-11 months')); | 534 | $last_year_month = date('Y-m', strtotime('-11 months')); |
| 554 | while ($last_year_month <= $now_month) { | 535 | while ($last_year_month <= $now_month) { |
| @@ -558,13 +539,34 @@ class InquiryForwardLogic extends BaseLogic | @@ -558,13 +539,34 @@ class InquiryForwardLogic extends BaseLogic | ||
| 558 | 539 | ||
| 559 | foreach ($manage_ids as $mid) { | 540 | foreach ($manage_ids as $mid) { |
| 560 | $name = $manageModel->getName($mid); | 541 | $name = $manageModel->getName($mid); |
| 561 | - $data[$last_year_month][$name] = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0); | 542 | + $month_count = intval(ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->sum('count') ?? 0); |
| 543 | + $data_month[$last_year_month][$name] = $month_count; | ||
| 544 | + $data_month['total'][$name] += $month_count; | ||
| 562 | } | 545 | } |
| 563 | 546 | ||
| 564 | $last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month')); | 547 | $last_year_month = date('Y-m', strtotime($last_year_month . ' +1 month')); |
| 565 | } | 548 | } |
| 549 | + | ||
| 550 | + //周统计 | ||
| 551 | + $data_week = []; | ||
| 552 | + $now_day = date('Y-m-d'); | ||
| 553 | + $last_week_day = date('Y-m-d', strtotime('-1 week')); | ||
| 554 | + while ($last_week_day < $now_day) { | ||
| 555 | + $day_arr = explode('-', $last_week_day); | ||
| 556 | + $year = $day_arr[0]; | ||
| 557 | + $month = $day_arr[1]; | ||
| 558 | + $day = $day_arr[2]; | ||
| 559 | + | ||
| 560 | + foreach ($manage_ids as $mid) { | ||
| 561 | + $name = $manageModel->getName($mid); | ||
| 562 | + $day_count = ForwardCount::where('manage_id', $mid)->where('year', $year)->where('month', $month)->where('day', $day)->value('count') ?? 0; | ||
| 563 | + $data_week[substr($last_week_day, 5)][$name] = $day_count; | ||
| 564 | + $data_week['total'][$name] += $day_count; | ||
| 566 | } | 565 | } |
| 567 | 566 | ||
| 568 | - return $this->success($data); | 567 | + $last_week_day = date('Y-m-d', strtotime($last_week_day . ' +1 day')); |
| 568 | + } | ||
| 569 | + | ||
| 570 | + return $this->success(['data_month' => $data_month, 'data_week' => $data_week]); | ||
| 569 | } | 571 | } |
| 570 | } | 572 | } |
-
请 注册 或 登录 后发表评论