chengkun
2025-05-23 0d8e263c22903234efea68fd13a27d8b7b59aac1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
 
class crm_order_controller extends adminCommon{
    //设置高级搜索功能
    function set_search(){
        $pro=$this->obj->DB_select_all("crm_product","1","`id`,`name`");
        if(!empty($pro)){
            foreach($pro as $k=>$v){
                $carr[$v['id']]=$v['name'];
            }
        }
        $search_list[]=array("param"=>"status","name"=>'审核状态',"value"=>array("1"=>"待审核","2"=>"已付款","3"=>"已完成","4"=>"已退款"));
        $search_list[]=array("param"=>"product","name"=>'产品名称',"value"=>$carr);
        $lo_time=array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月');
        $search_list[]=array("param"=>"o_time","name"=>'发布时间',"value"=>$lo_time);
        $this->yunset("pro", $pro);
        $this->yunset("search_list",$search_list);
    }
    function index_action()
    {
        $this->set_search();
        $where.="`nid` in (".$this->config['crmpronid'].")";
        if ($_GET['product']!=""){
            $where.=" and `pid`='".$_GET['product']."'";
            $urlarr['product']=$_GET['product'];
        }
        if($_GET['status'])
        {
            $where.=" and `status`='".$_GET['status']."'";
            $urlarr['status']=$_GET['status'];
        }
        if($_GET['o_time']){
            if($_GET['o_time']=='1'){
                $where.=" and `ctime` >= '".strtotime(date("Y-m-d 00:00:00"))."'";
            }else{
                $where.=" and `ctime` >= '".strtotime('-'.$_GET['o_time'].'day')."'";
            }
            $urlarr['o_time']=$_GET['o_time'];
        }
        if($_GET['news_search']){
 
            if (trim($_GET['keyword'])!=""){
                    if ($_GET['type']=='2'){
                $where.=" and `orderid` like '%".trim($_GET['keyword'])."%'";
            }elseif ($_GET['type']=='1'){
                $orderinfo=$this->obj->DB_select_all("crm_client","`name` like '%".trim($_GET['keyword'])."%'","`id`");
                if (is_array($orderinfo)){
                    foreach ($orderinfo as $val){
                        $orderuids[]=$val['id'];
                    }
                    $oruids=@implode(",",$orderuids);
                }
                $where.=" and `client_id` in (".$oruids.")";
 
            }
            $urlarr['type']=$_GET['type'];
            $urlarr['keyword']=$_GET['keyword'];
            }
            $urlarr['news_search']=$_GET['news_search'];
        }
        if($_GET['order'])
        {
            if($_GET['order']=="desc")
            {
                $order=" order by `".$_GET['t']."` desc";
            }else{
                $order=" order by `".$_GET['t']."` asc";
            }
            $urlarr['order']=$_GET['order'];
            $urlarr['t']=$_GET['t'];
        }else{
            $order=" order by `id` desc";
        }
        $urlarr['page']="{{page}}";
        $pageurl=Url($_GET['m'],$urlarr,'admin');
        $rows=$this->get_page("crm_order",$where.$order,$pageurl,$this->config['sy_listnum']);
        if(is_array($rows))
        {
            foreach($rows as $v)
            {
                $pid[]=$v['pid'];
                $cuid[]=$v['client_id'];
            }
            $plist=$this->obj->DB_select_all("crm_product","`id` in (".@implode(",",$pid).")");
            $clist=$this->obj->DB_select_all("crm_client","`id` in (".@implode(",",$cuid).")");
            foreach($rows as $k=>$v)
            {
                foreach($plist as $val)
                {
                    if($v['pid']==$val['id'])
                    {
                        $rows[$k]['pname']=$val['name'];
                    }
                }
                foreach($clist as $val)
                {
                    if($v['client_id']==$val['id'])
                    {
                        $rows[$k]['username']=$val['name'];
                    }
                }
            }
        }
        $this->yunset("get_type", $_GET);
        $this->yunset("rows",$rows);
        $this->yuntpl(array('admin/crm_order'));
    }
    function show_action()
    {
        $info=$this->obj->DB_select_once("crm_order","`id`='".$_GET['id']."'");
        $this->yunset("info",$info);
        $product=$this->obj->DB_select_once("crm_product","`id`='".$info['pid']."'");
        $this->yunset("product",$product);
        $this->yuntpl(array('admin/crm_order_show'));
    }
    function status_action()//订单确认完成
    {
        if(is_array($_POST['del']))
        {
            $del=@implode(",",$_POST['del']);
            $layer_type=1;
        }else{
            $del=$_GET['del'];
            $layer_type=0;
        }
        $nid=$this->obj->DB_update_all("crm_order","`status`='3'","`id` in (".$del.")");
        isset($nid)?$this->layer_msg('crm订单(ID:".$del.")确认完成成功!',9,$layer_type,$_SERVER['HTTP_REFERER']):$this->layer_msg('确认完成失败!',8,$layer_type,$_SERVER['HTTP_REFERER']);
    }
}
?>