抽取共用的时间筛选,专门由时间搜索类去处理,业务代码处理特有业务的筛选

<?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();
    }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值