chengkun
2025-04-27 a0402d122fee696e2b7684ef7edfc504ade12640
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
 
class coupon_list_controller extends adminCommon{
        //设置高级搜索功能
    function set_search(){
        $search_list[]=array("param"=>"status","name"=>'消费状态',"value"=>array("1"=>"未消费","2"=>"已消费","3"=>"已到期"));
        $search_list[]=array("param"=>"end","name"=>'到期时间',"value"=>array("1"=>"今天","3"=>"最近三天","7"=>"最近七天","15"=>"最近半月","30"=>"最近一个月"));
        $search_list[]=array("param"=>"change","name"=>'消费时间',"value"=>array("1"=>"今天","3"=>"最近三天","7"=>"最近七天","15"=>"最近半月","30"=>"最近一个月"));
        $search_list[]=array("param"=>"receive","name"=>'获赠时间',"value"=>array('1'=>'一天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月'));
        $this->yunset("search_list",$search_list);
    }
    function index_action()
    {
        $this->set_search();
        
        $couponM    =    $this->MODEL('coupon');
        
        $upwhere['validity']    =    array('<',time());
        
        $upwhere['status']        =    '1';
        
        $couponM -> upCouponList($upwhere,array('status'=>'3'));
        
        if($_GET['status']){
            
            $where['status']    =    $_GET['status'];
            
            $urlarr['status']    =    $_GET['status'];
        }
        if($_GET['change']){
            if($_GET['change']=='1'){
                
                $where['xf_time']    =    array('>=',strtotime(date("Y-m-d 00:00:00")));
                
            }else{
                
                $where['xf_time']    =    array('>=',strtotime('-'.$_GET['change'].'day'));
                
            }
            $urlarr['change']        =    $_GET['change'];
        }
        if($_GET['end']){
            if($_GET['end']=='1'){
                
                $where['validity'][]    =    array('<=',strtotime(date("Y-m-d 11:59:59")));
                
                $where['validity'][]    =    array('>=',strtotime(date("Y-m-d 00:00:00")));
                
            }else{
                
                $where['validity'][]    =    array('<=',strtotime('+'.$_GET['end'].'day'));
                
                $where['validity'][]    =    array('>=',time());
                
            }
            $urlarr['end']=$_GET['end'];
        }
        if($_GET['receive']){
            if($_GET['receive']=='1'){
                
                $where['ctime']            =    array('>=',strtotime(date("Y-m-d 00:00:00")));
                
            }else{
                
                $where['ctime']            =    array('>=',strtotime('-'.$_GET['receive'].'day'));
                
            }
            $urlarr['receive']            =    $_GET['receive'];
        }
        if(trim($_GET['keyword']))
        {
            if($_GET['type']=='1'){
                
                $userinfoM    =    $this->MODEL('userinfo');
                
                $m_uid        =    $userinfoM->getList(array('username'=>array('like',trim($_GET['keyword']))),array('field'=>'`uid`'));
                
                if(is_array($m_uid) && !empty($m_uid)){
                    
                    foreach($m_uid as $k){
                        
                        $m_id[]=$k['uid'];
                        
                    }
                }
                
                $where['uid']            =    array('in',pylode(',',$m_id));
                
            }elseif($_GET['type']=='2'){
                
                $where['number']        =    array('like',trim($_GET['keyword']));
                
            }elseif($_GET['type']=='3'){
                
                $where['coupon_name']    =    array('like',trim($_GET['keyword']));
                
            }
            $urlarr['type']                =    $_GET['type'];
            
            $urlarr['keyword']            =    $_GET['keyword'];
        }
        if($_GET['order'])
        {
            $where['orderby']        =    $_GET['t'].','.$_GET['order'];
            
            $urlarr['order']        =    $_GET['order'];
            
            $urlarr['t']            =    $_GET['t'];
        }else{
            
            $where['orderby']        =    'id';
        }
        $urlarr                =   $_GET;
        $urlarr['page']        =    "{{page}}";
        
        $pageurl            =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM                =    $this  -> MODEL('page');
        
        $pages                =    $pageM -> pageList('coupon_list',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            $where['limit']    =    $pages['limit'];
            
            $rows            =    $couponM -> getCouponList($where,array('utype'=>'admin'));
            
            $this->yunset('rows',$rows);
        }
        
        $this->yunset("get_type",$_GET);
        
        $this->yuntpl(array('admin/coupon_list'));
    }
    function del_action()
    {
        if($_GET['del'])
        {
            $this->check_token();
            
            $couponM        =    $this->MODEL('coupon');
            
            $del=$_GET['del'];
            
            if(is_array($del)){
                
                $del=@implode(',',$del);
                
                $layer_type=1;
            }else{
                $layer_type=0;
            }
            $where['id']    =    array('in',$del);
            
            $return            =    $couponM->delCouponList($where);
            
            $this->layer_msg('优惠券记录(ID:'.$del.')'.$return['msg'],$return['cod'],$layer_type,$_SERVER['HTTP_REFERER']);
        }else{
            $this->layer_msg('请选择要删除的内容!',8,0,$_SERVER['HTTP_REFERER']);
        }
    }
}
 
?>