wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
e2b48d 1 <?php
B 2
3 /**
4  * 我的订单
5 */
6 ob_start();
7
8 define('IN_ECS', true);
9
10 require('../includes/init.php');
11 include('../includes/cls_json.php');
12 $json   = new JSON;
13
14
15 $smarty->template_dir = ROOT_PATH . 'json/tpl';//app部分模板所在位置
16     $page=$_GET['page']*10;
17     $uid=isset($_GET['uid']) ? intval($_GET['uid']) : 0;
18     $orderType=isset($_GET['orderType']) ? intval($_GET['orderType']) : 0;
19     if($uid == 0)
20     {
21          $res['result'] == "您还没下过订单^_^哦";
22          print_r(json_encode($res));
23          exit;
24     }
25     switch($orderType){
26         case 1:
27             $sql="SELECT * 
28         FROM  ".$ecs->table('order_info')."  WHERE user_id='$uid' AND pay_status='0' AND order_status != 2 ORDER BY order_id DESC
29         LIMIT $page,10";
30             break;
31         case 2:
32             $sql="SELECT * 
33         FROM  ".$ecs->table('order_info')."  WHERE user_id='$uid' AND shipping_status='0' AND order_status != 2 ORDER BY order_id DESC
34         LIMIT $page,10";
35             break;
36         case 3:
37             $sql="SELECT * 
38         FROM  ".$ecs->table('order_info')."  WHERE user_id='$uid'  AND shipping_status='1' AND order_status != 2 ORDER BY order_id DESC
39         LIMIT $page,10";
40             break;
41         case 4:
42             $sql="SELECT * 
43         FROM  ".$ecs->table('order_info')."  WHERE user_id='$uid' ORDER BY order_id DESC
44         LIMIT $page,10";
45             break;
46         default:
47             $sql="SELECT * 
48         FROM  ".$ecs->table('order_info')."  WHERE user_id='$uid' ORDER BY order_id DESC
49         LIMIT $page,10";
50             break;
51     }
52     $res = $db -> getAll($sql);
53     for($i=0;$i<count($res);$i++){
54         
55         $res[$i]['add_time']=local_date($GLOBALS['_CFG']['time_format'], $res[$i]['add_time']);;
56         
57         if($res[$i]['order_status']==0){
58             $res[$i]['order_status']="未确认";
59         }else if($res[$i]['order_status']==1){
60             $res[$i]['order_status']="已确认";
61         }else if($res[$i]['order_status']==2){
62             $res[$i]['order_status']="已取消";
63         }else if($res[$i]['order_status']==3){
64             $res[$i]['order_status']="无效";
65         }else if($res[$i]['order_status']==4){
66             $res[$i]['order_status']="退货";
67         }else if($res[$i]['order_status']==5){
68             $res[$i]['order_status']="已分单";
69         }
70         
71         if($res[$i]['shipping_status']==0){
72             $res[$i]['shipping_status']="未发货";
73         }else if($res[$i]['shipping_status']==1){
74             $res[$i]['shipping_status']="已发货";
75         }else if($res[$i]['shipping_status']==2){
76             $res[$i]['shipping_status']="已收货";
77         }else if($res[$i]['shipping_status']==3){
78             $res[$i]['shipping_status']="备货中";
79         }else if($res[$i]['shipping_status']==5){
80             $res[$i]['shipping_status']="配货中";
81         }
82         
83         if($res[$i]['pay_status']==0){
84             $res[$i]['pay_status']="未付款";
85         }else if($res[$i]['pay_status']==1){
86             $res[$i]['pay_status']="付款中";
87         }else if($res[$i]['pay_status']==2){
88             $res[$i]['pay_status']="已付款";
89             
90         }
91
92         $aa = $res[$i]['order_id'];
93         $sql ="SELECT g.goods_thumb,s.* FROM ".$ecs->table('order_goods')."as s,".$ecs->table('goods')." as g WHERE s.order_id='$aa' AND s.goods_id=g.goods_id";
94         $res[$i]['xiang'] = $db ->getAll($sql);
95         if($res[$i]['xiang'])
96         {
97             $count_money = $res[$i]['xiang'];
98             for($j=0;$j<count($count_money);$j++)
99             {
100                 $res[$i]['count_amount'] += $count_money[$j]['goods_number'] * $count_money[$j]['goods_price'];
101             }
102         }else
103         {
104             $res[$i]['count_amount'] = $res[$i]['order_amount'];
105         }
106         
107         $res[$i]['count_amount'] = ($res[$i]['count_amount'] + $res[$i]['shipping_fee'] + $res[$i]['insure_fee'] + $res[$i]['pay_fee'] + $res[$i]['pack_fee'] + $res[$i]['card_fee'] + $res[$i]['tax']) - ($res[$i]['discount'] + $res[$i]['bonus'] + $res[$i]['integral_money']);
108     }
109     
110     $smarty->assign('order_list',$res);
111      $res['result'] = $smarty->fetch('orderlist_app.lib');
112     print_r(json_encode($res));
113     ob_end_flush();
114 ?>
115