chengkun
2025-05-26 4462855c0033970c39ac8d0da704b7dc41eabbfe
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
 
class admin_prepaid_controller extends adminCommon{
    function set_search(){
        $search_list[]=array("param"=>"time","name"=>'有效期',"value"=>array("1"=>"未过期","2"=>"已过期"));
        $search_list[]=array("param"=>"status","name"=>'使用状态',"value"=>array("1"=>"已使用","2"=>"未使用"));
        $search_list[]=array("param"=>"type","name"=>'状态',"value"=>array("1"=>"可用","2"=>"不可用"));
        $this->yunset("search_list",$search_list);
    }
    function index_action(){
        $this->set_search();
        
        if(trim($_GET['keyword'])){
            
            if($_GET['ctype']=='2'){
                
                $where['username']    =    array('like',trim($_GET['keyword']));
                
            }else{
                
                $where['card']        =    array('like',trim($_GET['keyword']));
                
            }
            $urlarr['keyword']        =    $_GET['keyword'];
        }
        if($_GET['type']){
            
            if($_GET['type']=='1'){
                
                $where['type']        =    $_GET['type'];
                
            }else{
                
                $where['type']        =    $_GET['type'];
                
            }
            $urlarr['type']            =    $_GET['type'];
        }
        if($_GET['status']){
            
            if($_GET['status']==1){
                
                $where['uid']        =    array('>','0');
                
            }else{
                
                $where['uid']        =    array('isnull');
                
            }
            $urlarr['status']        =    $_GET['status'];
        }
        if($_GET['time']){
            
            if($_GET['time']==1){
                
                $where['etime']        =    array('>',time());
                
            }else{
                
                $where['etime']        =    array('<',time());
                
                $where['uid']        =    array('isnull');
                
            }
            $urlarr['time']            =    $_GET['time'];
        }
        $urlarr                =   $_GET;
        $urlarr['page']        =    "{{page}}";
        
        $pageurl            =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM                =    $this  -> MODEL('page');
        
        $pages                =    $pageM -> pageList('prepaid_card',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            if($_GET['order']){
                
                $where['orderby']        =    $_GET['t'].','.$_GET['order'];
                
                $urlarr['order']        =    $_GET['order'];
                
                $urlarr['t']            =    $_GET['t'];
                
            }else{
                
                $where['orderby']        =    'id';
                
            }
            
            $where['limit']                =    $pages['limit'];
            
            $prepaidM    =    $this->MODEL('prepaid');
            
            $rows       =    $prepaidM -> getList($where);
            
            unset($where['limit']);
            
            session_start();
            
            $_SESSION['preXls'] = $where;
        }
        
        $this->yunset('rows',$rows);
        
        $this->yuntpl(array('admin/admin_prepaid'));
    }
    function upcard_action(){
        
        $prepaidM    =    $this->MODEL('prepaid');
        
        if($_POST['submit']){
            
            $where['id']    =    intval($_POST['id']);
            
            $where['utime']    =    array('isnull');
            
            $return            =    $prepaidM -> upInfo($_POST,$where);
            
            $return['id']?$this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=admin_prepaid",2,1):$this->ACT_layer_msg($return['msg'],$return['errcode'],$_SERVER['HTTP_REFERER']);
        }
        if($_GET['id']){
            
            $info    =    $prepaidM -> getInfo(array('id'=>intval($_GET['id'])));
            
            if($info['id']){
                
                $this->yunset("info",$info);
                
                $this->yuntpl(array('admin/admin_prepaid_upcard'));
                
            }else{
                
                $this->ACT_msg("index.php?m=admin_prepaid","非法操作");
                
            }
        }
    }
 
    function xls_action(){
        
        session_start();
        
        $where = $_SESSION['comXls'] ? $_SESSION['comXls'] : array('orderby'=>'id');
        
        if(!empty($_POST['type'])){
            
            if(in_array("card",$_POST['type']) || in_array("password",$_POST['type']) || in_array("quota",$_POST['type']) || in_array("stime",$_POST['type']) || in_array("etime",$_POST['type'])){
                
                foreach($_POST['type'] as $v){
                    
                    $type[]    =    $v;
                }
            }
            $field    =    pylode(',', $type).',id';
        }else{
            
            $field    =    'id';
        }
        $prepaidM    =    $this -> MODEL('prepaid');
        
        $where['id']=    array('in',$_POST['pid']);
        
        $list        =    $prepaidM -> getList($where,array('field'=>$field));
        
        if(!empty($list)){
            
            $this->yunset("list",$list);
            
            $this->yunset("type",$_POST['type']);
            
            $this->MODEL('log')->addAdminLog("导出充值卡信息");
            
            header("Content-Type: application/vnd.ms-excel");
            
            header("Content-Disposition: attachment; filename=prepaid.xls");
            
            $this->yuntpl(array('admin/admin_prepaid_xls'));
        }
 
    }
 
    function add_action(){
        if($_POST['submit']){
            
            $prepaidM    =    $this->MODEL('prepaid');
            
            $return        =    $prepaidM->addInfo($_POST);
 
            $this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=admin_prepaid");
        }
        $this->yuntpl(array('admin/admin_prepaid_add'));
    }
    function rec_action(){
        $prepaidM    =    $this->MODEL('prepaid');
        
        intval($_GET['rec'])=='1'?$type='1':$type='2';
        
        $postdata['type']    =    $type;
        
        $where['id']        =    $_GET['id'];
        
        $return['id']        =    $prepaidM -> upInfo($postdata,$where,array('rec'=>'1'));
        
        $this->MODEL('log')->addAdminLog("充值卡(ID:".$_GET['id'].")状态设置成功!");
        
        echo $return['id']?1:0;die;
    }
 
    function del_action(){
        
        $prepaidM    =    $this -> MODEL('prepaid');
        
        $return        =    $prepaidM -> delInfo($_GET['del']);
        
        $this -> layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
        
    }
}
?>