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
<?php
 
class company_order_controller extends siteadmin_controller{
    //设置高级搜索功能
    function set_search(){
        include (APP_PATH."/config/db.data.php");
        
        $search_list[]    =    array("param"=>"typezf","name"=>'支付类型',"value"=>array("alipay"=>"支付宝","wxpay"=>"微信支付","tenpay"=>"财富通","bank"=>"银行转帐"));
        
        $search_list[]    =    array("param"=>"typedd","name"=>'订单类型',"value"=>$arr_data['ordertype']);
        
        $search_list[]    =    array("param"=>"order_state","name"=>'订单状态',"value"=>array("0"=>"支付失败","1"=>"等待付款","2"=>"支付成功","3"=>"等待确认"));
        
        $lo_time        =    array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月');
        $search_list[]    =    array("param"=>"time","name"=>'充值时间',"value"=>$lo_time);
        
        $this -> yunset("search_list",$search_list);
    }
    function index_action(){
        $this -> set_search();
        
        $OrderM                            =    $this -> MODEL('companyorder');
        
        $where                            =   array();
       
        $keywordStr                        =   trim($_GET['keyword']);
        
        if(intval($_GET['comid'])){
            $where['uid']                =    intval($_GET['comid']);
            
            $urlarr['comid']            =    $_GET['comid'];
            
            $ComM                        =    $this -> MODEL('company');
            $comname                    =    $ComM -> getInfo($_GET['comid'],array('field'=>'name'));
            $this -> yunset("ccname",$comname['name']);
        }
        if($_GET['typezf']!=""){
            $where['order_type']        =    $_GET['typezf'];
 
            $urlarr['typezf']            =    $_GET['typezf'];
        }
        if($_GET['typedd']!=""){
            $where['type']                =    $_GET['typedd'];
 
            $urlarr['typedd']            =    $_GET['typedd'];
        }
        
        if($_GET['news_search']){
            if (!empty($keywordStr) && $_GET['typeca']=='1') {
                $where['order_id']        =    array('like', $keywordStr);
            }elseif(!empty($keywordStr) && $_GET['typeca']=='2'){
                $UserinfoM                =    $this -> MODEL('userinfo');
                $orderinfo                =    $UserinfoM -> getList(array('username'=>array('like',$keywordStr)),array('field'=>'uid'));
                
                if (is_array($orderinfo)){
                    foreach ($orderinfo as $val){
                        $orderuids[]    =    $val['uid'];
                    }
                    $where['uid']        =    array('in', pylode(",",$orderuids));
                }
            }
            $urlarr['keyword']            =    $keywordStr;
            $urlarr['typeca']            =    $_GET['typeca'];
            $urlarr['news_search']        =    $_GET['news_search'];
        }
        if($_GET['time']||$_GET['time_start1']!=""||$_GET['time_end1']!=""){
            $where['PHPYUNBTWSTART_B']    =   'AND';
            if($_GET['time']){
                if($_GET['time'] == 1){
                    $where['order_time'][]    =    array('>=',strtotime(date("Y-m-d 00:00:00")));
                }else{
                    $where['order_time'][]    =    array('>=',strtotime('-'.intval($_GET['time']).' day'));
                }
                $urlarr['time']                =    $_GET['time'];
            }
            if($_GET['time_start1']!=""){
                $where['order_time'][]        =    array('>=',strtotime($_GET['time_start1']." 00:00:00"));
 
                $urlarr['time_start1']        =    $_GET['time_start1'];
            }
            if($_GET['time_end1']!=""){
                $where['order_time'][]        =    array('<',strtotime($_GET['time_end1']." 23:59:59"));
 
                $urlarr['time_end1']        =    $_GET['time_end1'];
            }
            $where['PHPYUNBTWEND_B']    =    '';
        }
        if($_GET['order_state']!=""){
            $where['order_state']        =    $_GET['order_state'];
 
            $urlarr['order_state']        =    $_GET['order_state'];
        }
        if($_GET['fb']!=""){
            $where['is_invoice']        =    $_GET['fb'];
 
            $urlarr['fb']                =    $_GET['fb'];
        }
        $urlarr['page']                    =    "{{page}}";
        
        $pageurl                        =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM                            =    $this  -> MODEL('page');
        
        $pages                            =    $pageM -> pageList('company_order',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            //limit order 只有在列表查询时才需要
            if($_GET['order']){
                $where['orderby']        =    $_GET['t'].','.$_GET['order'];
 
                $urlarr['order']        =    $_GET['order'];
                $urlarr['t']            =    $_GET['t'];
            }else{
                $where['orderby']        =    array('id,desc');
            }
            $where['limit']                =    $pages['limit'];
            
            $rows                        =   $OrderM -> getList($where,array('utype'=>'admin','field'=>'id,uid,order_id,order_price,type,order_state,order_type,order_time,once_id'));
            //处理导出需要的where条件
            unset($where['limit']);
            
            session_start();
            $_SESSION['orderXls'] = $where;
        }
        //$this->yunset("get_type", $_GET);
        
        $this->yunset("rows",$rows);
        $this->siteadmin_tpl(array('admin_company_order'));
    }
    function edit_action()
    {
        $id         =    intval($_GET['id']);
        $OrderM  =    $this -> MODEL('companyorder');
        $row     =    $OrderM ->getInfo(array('id'=>$id));
        if($row['coupon']){
            $couponM  =  $this -> MODEL('coupon');
            $coupon      =  $couponM -> getCouponListOne(array('id'=>$row['coupon']),array('field'=>'id,coupon_amount'));
            if($coupon){
                // 总金额
                $row['price']              =  number_format(($row['order_price'] + $coupon['coupon_amount']),2);
                // 待付金额
                $row['order_price']          =  number_format($row['order_price'],2);
                // 优惠券金额
                $coupon['coupon_amount']  =  number_format($coupon['coupon_amount'],2);
            }
            $this -> yunset("coupon",$coupon);
        }
        $this -> yunset("row",$row);
        $this -> siteadmin_tpl(array('admin_company_order_edit'));
    }
    function save_action(){
        $id            =    intval($_POST['id']);
        $OrderM        =    $this -> MODEL('companyorder');
        if($_POST['coupon_amount']){
            $_POST['order_price'] = $_POST['order_price']+$_POST['coupon_amount'];
        }
        $mData      =   array(
            'order_price'        =>  $_POST['order_price'],
            'order_remark'        =>  $_POST['order_remark'],
            'is_invoice'        =>  $_POST['is_invoice']
        );
        $return        =    $OrderM  ->  upInfo($id, $mData);
        
        $this -> ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=company_order");
    }
    function setpay_action(){
        $this -> check_token();
        $id            =    intval($_GET['id']);
        $OrderM        =    $this -> MODEL('companyorder');
        $return        =    $OrderM -> setPay($id);
        $this -> layer_msg($return['msg'],$return['errcode'],0,$_SERVER['HTTP_REFERER']);
    }
    function xls_action(){
        $where = $_SESSION['orderXls'] ? $_SESSION['orderXls'] : array('orderby'=>'id');
        $OrderM                            =    $this -> MODEL('companyorder');
        if($_POST['uid']){
            $where['id']                =    array('in',pylode(',',$_POST['uid']));
        }
        if($_GET['time_start']!=""||$_GET['time_end']!=""){
            $where['PHPYUNBTWSTART_B']    =   'AND';
            if($_GET['time_start']!=""){
                $where['order_time']        =    array('>=',substr($_POST['time_start'],0,strlen($_POST['time_start'])-3));
            }
            if($_GET['time_end']!=""){
                $where['order_time']        =    array('<',substr($_POST['time_end'],0,strlen($_POST['time_end'])-3));
            }
            $where['PHPYUNBTWEND_B']    =    '';
        }
        
        $rows                            =   $OrderM -> getList($where,array('utype'=>'admin','field'=>'id,uid,order_id,order_price,type,order_state,order_type,order_time,once_id'));
        
        if(!empty($rows)){
            $this -> yunset("list",$rows);
            $this -> MODEL('log') -> addAdminLog("导出支付订单信息");
            header("Content-Type: application/vnd.ms-excel");
            header("Content-Disposition: attachment; filename=order.xls");
            $this -> siteadmin_tpl(array('admin_order_xls'));
        }else{
            $this -> ACT_layer_msg("没有可以导出的订单信息!",8,$_SERVER['HTTP_REFERER']);
        }
        
    }
    //删除
    function del_action(){
        $this -> check_token();
        $OrderM        =    $this -> MODEL('companyorder');
        $delID        =    is_array($_GET['del']) ? $_GET['del'] : $_GET['id'];
        $return        =    $OrderM -> del($delID,array('utype'=>'admin'));
        $this -> layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
    }
 
    function orderSum_action(){
        $MsgNum=$this->MODEL('msgNum');
        echo $MsgNum->orderSum();
    }
}
?>