<?php class wdxscClassModel extends sModel { public $search_date_model = ''; /** * 新增线索统计接口 * @desc 按照大区统计线索总数、从大到小进行排序展示 */ public function count_new_by_daqu($daqu){ $where = '1=1'; $this->get_count_new_by_daqu_where($daqu,$where); $date_field = 'applydt'; $this->get_search_date_where($where,$date_field); $fileds = 'count(id) as total,dizhi'; $order = 'total desc'; $limit = '1000'; $group = 'dizhi'; $this->get_count_new_by_daqu_field_and_group($daqu,$fileds,$group); $rows = $this->getrows($where,$fileds,$order,$limit,$group); return $rows; } private function get_count_new_by_daqu_where($daqu,&$where){ if(!empty($daqu)){ if($daqu=='全部'){ return true; } $where .= ' and daqu = "'.$daqu.'"'; } } private function get_count_new_by_daqu_field_and_group($daqu,&$fileds,&$group){ if(!empty($daqu)){ if($daqu=='全部'){ $fileds = 'count(id) as total,daqu'; $group = 'daqu'; } } } /** * 当前线索统计接口 * @desc 按照大区统计线索总数、从大到小进行排序展示 */ public function count_total_by_daqu($daqu,$end_time){ $where = '1=1'; $this->get_count_total_by_daqu_where($daqu,$where,$end_time); $fileds = 'count(id) as total,dizhi'; $order = 'total desc'; $limit = '1000'; $group = 'dizhi'; $this->get_count_total_by_daqu_field_and_group($daqu,$fileds,$group); $rows = $this->getrows($where,$fileds,$order,$limit,$group); return $rows; } private function get_count_total_by_daqu_where($daqu,&$where,$end_time){ if(!empty($daqu)){ if($daqu!='全部'){ $where .= ' and daqu = "'.$daqu.'"'; } } if(!empty($end_time)){ $where .= ' and applydt <= "'.$end_time.'"'; } } private function get_count_total_by_daqu_field_and_group($daqu,&$fileds,&$group){ if(!empty($daqu)){ if($daqu=='全部'){ $fileds = 'count(id) as total,daqu'; $group = 'daqu'; } } } /** * 当前线索统计接口 * @desc 按照大区统计线索总数、从大到小进行排序展示 */ public function count_total_by_sales($daqu,$end_time){ $where = '1=1'; $this->get_count_total_by_sales_where($daqu,$where,$end_time); $fileds = 'count(a.id) as total,b.name'; $order = 'total desc'; $limit = '1000'; $group = 'b.name'; $rows = $this->db->getall('SELECT '.$fileds.' FROM `[Q]wdxsc` a left join `[Q]admin` b on a.`uid`=b.`id` where '.$where.' group by '.$group.' order by '.$order.' limit '.$limit); return $rows; } private function get_count_total_by_sales_where($daqu,&$where,$end_time){ if(!empty($daqu)){ if($daqu!='全部'){ $where .= ' and a.daqu = "'.$daqu.'"'; } } if(!empty($end_time)){ $where .= ' and a.applydt <= "'.$end_time.'"'; } } /** * 客户经理新增线索统计接口 * @desc 按照大区统计线索总数、从大到小进行排序展示 */ public function count_new_by_sales($daqu){ $where = '1=1'; $this->get_count_new_by_sales_where($daqu,$where); $date_field = 'a.applydt'; $this->get_search_date_where($where,$date_field); $fileds = 'count(a.id) as total,b.name'; $order = 'total desc'; $limit = '1000'; $group = 'b.name'; $rows = $this->db->getall('SELECT '.$fileds.' FROM `[Q]wdxsc` a left join `[Q]admin` b on a.`uid`=b.`id` where '.$where.' group by '.$group.' order by '.$order.' limit '.$limit); return $rows; } private function get_count_new_by_sales_where($daqu,&$where){ if(!empty($daqu)){ if($daqu=='全部'){ return true; } $where .= ' and a.daqu = "'.$daqu.'"'; } } private function get_search_date_where(&$where,$date_field){ $this->search_date_model->set_where($where); $this->search_date_model->set_date_field($date_field); $this->search_date_model->get_date_where(); $where = $this->search_date_model->get_where(); } }
抽取共用的时间筛选,专门由时间搜索类去处理,业务代码处理特有业务的筛选
最新推荐文章于 2024-09-07 15:57:32 发布