chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
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
<?php
/*
* $Author :PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
*
* 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class admin_comorder_controller extends adminCommon{
    function index_action(){
        $OrderM    =    $this -> MODEL('companyorder');
        $where    =    array();
        if($_GET['order_state']){
            $where['order_state']    =    $_GET['order_state'];
            $urlarr['order_state']    =    $_GET['order_state'];
        }
        $urlarr['c']    =    $_GET['c'];
        $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){
            $where['orderby']    =    'id';
            $where['limit']        =    $pages['limit'];
            $rows                =   $OrderM -> getList($where,array('utype'=>'admin'));
        }
        $this->yunset("backurl", basename($_SERVER['HTTP_REFERER']));
        $this->yunset("rows",$rows);
        $this->yunset("headertitle","充值记录");
        $this->yuntpl(array('wapadmin/admin_comorder'));
    }
    function edit_action(){
        $OrderM        =    $this -> MODEL('companyorder');
        $CouponM    =   $this -> MODEL('coupon');
        $row        =    $OrderM ->getInfo(array('id'=>intval($_GET['id'])));
        if($row['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);
        if($_POST['update']){
            $_POST    =    $this->post_trim($_POST);
            if($_FILES['order_pic']['tmp_name']){
                $upArr    =  array(
                    'file'    =>    $_FILES['order_pic'],
                    'dir'    =>    'order',    
                );
                $uploadM    =    $this -> MODEL('upload');
                $pic        =    $uploadM -> newUpload($upArr);
                if (!empty($pic['msg'])){
                    $this->ACT_layer_msg($pic['msg'],8);
                }elseif (!empty($pic['picurl'])){
                    $pictures    =    $pic['picurl'];
                }
            }
            if(isset($pictures)){
                $_POST['order_pic']    =    $pictures;
            }
            $mData      =   array(
                'order_price'    =>  $_POST['order_price'],
                'order_remark'    =>  $_POST['order_remark'],
                'is_invoice'    =>  $_POST['is_invoice'],
                'order_pic'        =>    $_POST['order_pic'],
            );
            if($row['order_pic']){
                $mData['order_pic']    =    $row['order_pic'];
            }
            $return        =    $OrderM  ->  upInfo(intval($_POST['id']),$mData);
            $data['msg']=$return['msg'];
            $data['url']=$_POST['lasturl'].'&last=1';
            $this->yunset("layer",$data);
        }
        // 修改完返回来源列表页路径
        $lasturl=$_SERVER['HTTP_REFERER'];
        if(strpos($lasturl, 'a=edit')===false){
            if(strpos($lasturl, 'c=admin_comorder')!==false){
                $this->cookie->setcookie('lasturl',$lasturl,time()+300);
                $_COOKIE['lasturl']=$lasturl;
            }
        }
        $this->yunset('lasturl',$_COOKIE['lasturl']);
        // 上面为空点击返回则回到列表首页
        if(intval($_GET['last']==1)){
            $backurl='index.php?c=admin_comorder';
            $this->yunset("backurl", $backurl);
        }
        $this->yunset("headertitle","充值记录详情");
        $this->yuntpl(array('wapadmin/admin_comorder_show'));
    }
    
    function setpay_action(){
        $OrderM        =    $this -> MODEL('companyorder');
        $return        =    $OrderM -> setPay(intval($_GET['id']));
        $this -> layer_msg($return['msg'],$return['errcode'],0,$_SERVER['HTTP_REFERER']);
    }
    //删除
    function del_action(){
        $OrderM        =    $this -> MODEL('companyorder');
        $delid        =    (int)$_GET['id'];
        $return        =    $OrderM -> del($delid,array('utype'=>'admin'));
        $this -> layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
    }
}
?>