From c202e34091f4c8f8ceb55c7f9f25acaebe9fc6d1 Mon Sep 17 00:00:00 2001 From: lcc <805383944@qq.com> Date: Wed, 8 Jan 2025 08:03:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=A2=9E=E5=8A=A0=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E6=97=A5=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/controllers/receiver/Report.php | 347 +++++++++++++-------- admin/views/receiver/report/lists.php | 104 +++++- api/controllers/plan/Plan.php | 2 + api/controllers/plan/Report.php | 176 +++++++++++ common/models/biz/Biz_report_day_model.php | 13 + 5 files changed, 505 insertions(+), 137 deletions(-) create mode 100644 api/controllers/plan/Report.php create mode 100644 common/models/biz/Biz_report_day_model.php diff --git a/admin/controllers/receiver/Report.php b/admin/controllers/receiver/Report.php index c93f23f2..71a5da3f 100644 --- a/admin/controllers/receiver/Report.php +++ b/admin/controllers/receiver/Report.php @@ -1,6 +1,6 @@ load->model("biz/biz_model"); - $this->load->model('receiver/receiver_score_log_model'); - $this->load->model('receiver/receiver_score_day_model'); - $this->load->model('receiver/receiver_score_avg_day_model'); - $this->load->model('app/licheb/app_licheb_users_model'); - $this->load->model('receiver/receiver_customers_model'); - $this->load->model('receiver/order/receiver_orders_model'); - $this->load->model('receiver/order/receiver_order_datas_model'); + $this->load->model("biz/biz_report_day_model"); +// $this->load->model('receiver/receiver_score_log_model'); +// $this->load->model('receiver/receiver_score_day_model'); +// $this->load->model('receiver/receiver_score_avg_day_model'); +// $this->load->model('app/licheb/app_licheb_users_model'); +// $this->load->model('receiver/receiver_customers_model'); +// $this->load->model('receiver/order/receiver_orders_model'); +// $this->load->model('receiver/order/receiver_order_datas_model'); } //首页信息 public function index() { - //return $this->lists(); + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + $lists = array(); + $where = ["status<>-1" => null]; + if ($params['day']) { + $where['day'] = $params['day']; + } + if ($params['biz_id']) { + $where['biz_id'] = $params['biz_id']; + } + $count = $this->biz_report_day_model->count($where); + $biz_where = ['status' => 1, 'type' => 0, 'province_id' => 350000]; + $biz_lists = $this->biz_model->select($biz_where, '', 0, 0, 'id,biz_name'); + $map_biz_lists = array_column($biz_lists, null, 'id'); + if ($count) { + $res = $this->biz_report_day_model->select($where, "id desc", $params['page'], $params['size']); + foreach ($res as $value) { + $setValue = $value; + $biz = $map_biz_lists[$value['biz_id']]; + $setValue['biz_name'] = $biz['biz_name']; + $lists[] = $setValue; + } + } + //获取所有 + $this->data['biz_lists'] = $biz_lists; + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['_title'] = '门店日报'; + $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); return $this->show_view('receiver/report/lists', true); } @@ -44,24 +74,26 @@ class Report extends HD_Controller } //编辑单条数据 - public function edit(){ + public function edit() + { } //删除单条数据 - public function del(){ + public function del() + { } //批量操作(默认修改状态) - public function batch(){ + public function batch() + { } - //导出数据列表 public function export() { - $day = $this->input->get('day'); + $params = $this->input->get(); + $day = $params['day']; !$day && $day = date('Y-m-d', strtotime('yesterday')); - $month = date('m', strtotime($day)); $indexs = [ 'biz_name' => '车卖场', @@ -88,124 +120,177 @@ class Report extends HD_Controller "order_finish" => "本月订单信息完整数", 'score_month' => '本月运营分', ]; - - $where = array( - 'status' => 1, - 'type' => 0, - 'province_id' => 350000 - ); - $bizs = $this->biz_model->select($where, '', 0, 0, 'id, biz_name'); - if($bizs){ - foreach ($bizs as $v){ - //开工率 - $sales = $this->app_licheb_users_model->count(array('group_id in (1,2)' => null, 'biz_id' => $v['id'], 'status' => 1)); - $works = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 0, 'sub_type' => 0, 'score >' => 0)); - - //今日新增线索数 - $cust_new = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'DATE(p_time)' => $day)); - - //本月线索总数 - $cust_month = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'MONTH(p_time)' => $month)); - - //今日新增跟进数 - $cust_visit = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0)); - - //本月跟进客户数 - $cust_visit_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); - - //今日订单新增数 - $order_new = $this->receiver_orders_model->count(array('DATE(order_time)' => $day, 'biz_id' => $v['id'], 'status >=' => 0)); - - //本月订单总数 - $order_month = $this->receiver_orders_model->select(array('MONTH(order_time)' => $month, 'biz_id' => $v['id'], 'status >=' => 0), '', 0, 0, 'id'); - - - //本月订单信息完整数 - if($order_month){ - $oids = implode(',', array_unique(array_column($order_month, 'id'))); - - $where = array( - "o_id in ({$oids})" => null, - "((cardida != '' AND cardidb != '') OR (business_licence != ''))" => null, - "pay_img <>" => '', - "contract_img <>" => '', - "bill_img <>" => '', - "car_img <>" => '', - "insurance_img <>" => '', - "business_img <>" => '', - ); - $order_finish = $this->receiver_order_datas_model->count($where); - }else{ - $order_finish = 0; - } - - //今日线索逾期数 - $cust_delay = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0)); - - //本月线索逾期数 - $cust_delay_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0)); - - //今日订单未达T+1 - $order_wrong = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); - - //本月订单未达T+1 - $order_wrong_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); - - //今日开票早与订单时间数 - $order_early = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 1, 'target_id >' => 0), 'target_id'); - - //今日未及时分配数 - $cust_push = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id'); - - //本月未及时分配数 - $cust_push_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id'); - - //今日战败申请未处理数 - $cust_defeat = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id'); - - //本月战败申请未处理数 - $cust_defeat_moth = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id'); - - //本月交付总数 - $order_over = $this->receiver_orders_model->count(array('MONTH(over_time)' => $month, 'biz_id' => $v['id'], 'status >' => 0)); - - //今日运营分 - $score = $this->receiver_score_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1)); - - //本月运营分 - $score_month = $this->receiver_score_avg_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'uid' => 0)); - - $data[] = array( - 'biz_name' => $v['biz_name'], - 'sales' => $sales, - 'work_per' => number_format($works/$sales, 2) * 100 .'%', - 'cust_new' => $cust_new, - 'cust_push' => $cust_push, - 'cust_visit' => $cust_visit, - 'cust_delay' => $cust_delay, - 'cust_defeat' => $cust_defeat, - 'order_new' => $order_new, - 'order_wrong' => $order_wrong, - 'order_early' => $order_early, - 'score' => round($score['score']), - - 'cust_month' => $cust_month, - 'cust_push_month' => $cust_push_month, - 'cust_visit_month' => $cust_visit_month, - 'cust_delay_month' => $cust_delay_month, - 'cust_defeat_month' => $cust_defeat_moth, - 'order_month' => count($order_month), - 'order_wrong_month' => $order_wrong_month, - 'order_over' => $order_over, - 'order_finish' => $order_finish, - 'score_month' => round($score_month['score']), - ); - } + $lists = []; + $where = ["status<>-1" => null]; + if ($params['day']) { + $where['day'] = $params['day']; + } + if ($params['biz_id']) { + $where['biz_id'] = $params['biz_id']; + } + $res = $this->biz_report_day_model->select($where, "id desc", $params['page'], $params['size']); + $map_biz_lists = $this->biz_model->get_map_by_ids(array_column($res, 'biz_id'), 'id,biz_name'); + foreach ($res as $value) { + $setValue = $value; + $biz = $map_biz_lists[$value['biz_id']][0]; + $setValue['biz_name'] = $biz['biz_name']; + $lists[] = $setValue; } - $fileName = '车卖场日报'; - array_unshift($data, $indexs); + array_unshift($lists, $indexs); $this->load->library('excel'); - $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); + $this->excel->out_csv($lists, $indexs, $fileName . "_" . date('YmdHis')); } + //导出数据列表 +// public function export() +// { +// $day = $this->input->get('day'); +// !$day && $day = date('Y-m-d', strtotime('yesterday')); +// $month = date('m', strtotime($day)); +// +// $indexs = [ +// 'biz_name' => '车卖场', +// 'sales' => '顾问数(含店长)', +// 'work_per' => '今日开工率', +// 'cust_new' => '今日新增线索数', +// "cust_push" => "今日未及时分配数", +// 'cust_visit' => '今日新增跟进数', +// "cust_delay" => "今日线索逾期数", +// "cust_defeat" => "今日战败申请未处理数", +// 'order_new' => '今日订单新增数', +// "order_wrong" => "今日订单未达T+1", +// "order_early" => "今日开票早与订单时间数", +// 'score' => '今日运营分', +// +// 'cust_month' => '本月线索总数', +// "cust_push_month" => "本月未及时分配总数", +// 'cust_visit_month' => '本月跟进客户数', +// "cust_delay_month" => "本月线索逾期数", +// "cust_defeat_month" => "本月战败申请未处理数", +// 'order_month' => '本月订单总数', +// "order_wrong_month" => "本月订单未达T+1", +// 'order_over' => "本月交付总数", +// "order_finish" => "本月订单信息完整数", +// 'score_month' => '本月运营分', +// ]; +// +// $where = array( +// 'status' => 1, +// 'type' => 0, +// 'province_id' => 350000 +// ); +// $bizs = $this->biz_model->select($where, '', 0, 0, 'id, biz_name'); +// if($bizs){ +// foreach ($bizs as $v){ +// //开工率 +// $sales = $this->app_licheb_users_model->count(array('group_id in (1,2)' => null, 'biz_id' => $v['id'], 'status' => 1)); +// $works = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 0, 'sub_type' => 0, 'score >' => 0)); +// +// //今日新增线索数 +// $cust_new = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'DATE(p_time)' => $day)); +// +// //本月线索总数 +// $cust_month = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'MONTH(p_time)' => $month)); +// +// //今日新增跟进数 +// $cust_visit = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0)); +// +// //本月跟进客户数 +// $cust_visit_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); +// +// //今日订单新增数 +// $order_new = $this->receiver_orders_model->count(array('DATE(order_time)' => $day, 'biz_id' => $v['id'], 'status >=' => 0)); +// +// //本月订单总数 +// $order_month = $this->receiver_orders_model->select(array('MONTH(order_time)' => $month, 'biz_id' => $v['id'], 'status >=' => 0), '', 0, 0, 'id'); +// +// +// //本月订单信息完整数 +// if($order_month){ +// $oids = implode(',', array_unique(array_column($order_month, 'id'))); +// +// $where = array( +// "o_id in ({$oids})" => null, +// "((cardida != '' AND cardidb != '') OR (business_licence != ''))" => null, +// "pay_img <>" => '', +// "contract_img <>" => '', +// "bill_img <>" => '', +// "car_img <>" => '', +// "insurance_img <>" => '', +// "business_img <>" => '', +// ); +// $order_finish = $this->receiver_order_datas_model->count($where); +// }else{ +// $order_finish = 0; +// } +// +// //今日线索逾期数 +// $cust_delay = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0)); +// +// //本月线索逾期数 +// $cust_delay_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0)); +// +// //今日订单未达T+1 +// $order_wrong = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); +// +// //本月订单未达T+1 +// $order_wrong_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id'); +// +// //今日开票早与订单时间数 +// $order_early = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 1, 'target_id >' => 0), 'target_id'); +// +// //今日未及时分配数 +// $cust_push = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id'); +// +// //本月未及时分配数 +// $cust_push_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id'); +// +// //今日战败申请未处理数 +// $cust_defeat = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id'); +// +// //本月战败申请未处理数 +// $cust_defeat_moth = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id'); +// +// //本月交付总数 +// $order_over = $this->receiver_orders_model->count(array('MONTH(over_time)' => $month, 'biz_id' => $v['id'], 'status >' => 0)); +// +// //今日运营分 +// $score = $this->receiver_score_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1)); +// +// //本月运营分 +// $score_month = $this->receiver_score_avg_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'uid' => 0)); +// +// $data[] = array( +// 'biz_name' => $v['biz_name'], +// 'sales' => $sales, +// 'work_per' => number_format($works/$sales, 2) * 100 .'%', +// 'cust_new' => $cust_new, +// 'cust_push' => $cust_push, +// 'cust_visit' => $cust_visit, +// 'cust_delay' => $cust_delay, +// 'cust_defeat' => $cust_defeat, +// 'order_new' => $order_new, +// 'order_wrong' => $order_wrong, +// 'order_early' => $order_early, +// 'score' => round($score['score']), +// +// 'cust_month' => $cust_month, +// 'cust_push_month' => $cust_push_month, +// 'cust_visit_month' => $cust_visit_month, +// 'cust_delay_month' => $cust_delay_month, +// 'cust_defeat_month' => $cust_defeat_moth, +// 'order_month' => count($order_month), +// 'order_wrong_month' => $order_wrong_month, +// 'order_over' => $order_over, +// 'order_finish' => $order_finish, +// 'score_month' => round($score_month['score']), +// ); +// } +// } +// +// $fileName = '车卖场日报'; +// array_unshift($data, $indexs); +// $this->load->library('excel'); +// $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); +// } } \ No newline at end of file diff --git a/admin/views/receiver/report/lists.php b/admin/views/receiver/report/lists.php index ccc51ef9..c9657f49 100644 --- a/admin/views/receiver/report/lists.php +++ b/admin/views/receiver/report/lists.php @@ -1,12 +1,25 @@