commit | author | age
|
e2b48d
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 订单详情 |
|
5 |
*/ |
|
6 |
ob_start(); |
|
7 |
define('IN_ECS', true); |
|
8 |
|
|
9 |
require('../includes/init.php'); |
|
10 |
include('../includes/cls_json.php'); |
|
11 |
require('includes/safety_mysql.php'); |
|
12 |
$json = new JSON; |
|
13 |
|
|
14 |
|
|
15 |
$smarty->template_dir = ROOT_PATH . 'json/tpl';//app部分模板所在位置 |
|
16 |
/*require('includes/safety_mysql.php'); |
|
17 |
define('IN_ECS', true); |
|
18 |
require('../includes/init.php');*/ |
|
19 |
$order_id = isset($_REQUEST['order_id']) ? intval($_REQUEST['order_id']) : 0; |
|
20 |
$result=array(); |
|
21 |
$sql="SELECT * FROM ".$ecs->table('order_info')." WHERE order_id='$order_id' "; |
|
22 |
//print_r($sql); |
|
23 |
$res = $db -> getAll($sql); |
|
24 |
for($i=0;$i<count($res);$i++) |
|
25 |
{ |
|
26 |
$res[$i]['add_time']=local_date($GLOBALS['_CFG']['time_format'], $res['add_time']);//下单时间 |
|
27 |
$res[$i]['confirm_time']=local_date($GLOBALS['_CFG']['time_format'], $res['confirm_time']);//确定时间 |
|
28 |
if($res[$i]['order_status']==0){ |
|
29 |
$res[$i]['order_status']="未确认"; |
|
30 |
}else if($res[$i]['order_status']==1){ |
|
31 |
$res[$i]['order_status']="已确认"; |
|
32 |
}else if($res[$i]['order_status']==2){ |
|
33 |
$res[$i]['order_status']="已取消"; |
|
34 |
}else if($res[$i]['order_status']==3){ |
|
35 |
$res[$i]['order_status']="无效"; |
|
36 |
}else if($res[$i]['order_status']==4){ |
|
37 |
$res[$i]['order_status']="退货"; |
|
38 |
}else if($res[$i]['order_status']==5){ |
|
39 |
$res[$i]['order_status']="已分单"; |
|
40 |
} |
|
41 |
$res[$i]['shipping_time']=local_date($GLOBALS['_CFG']['time_format'], $res['shipping_time']);//配送时间 |
|
42 |
if($res[$i]['shipping_status']==0){ |
|
43 |
$res[$i]['shipping_status']="未发货"; |
|
44 |
}else if($res[$i]['shipping_status']==1){ |
|
45 |
$res[$i]['shipping_status']="已发货"; |
|
46 |
}else if($res[$i]['shipping_status']==2){ |
|
47 |
$res[$i]['shipping_status']="已收货"; |
|
48 |
}else if($res[$i]['shipping_status']==3){ |
|
49 |
$res[$i]['shipping_status']="备货中"; |
|
50 |
}else if($res[$i]['shipping_status']==5){ |
|
51 |
$res[$i]['shipping_status']="配货中"; |
|
52 |
} |
|
53 |
$res[$i]['pay_time']=local_date($GLOBALS['_CFG']['time_format'], $res['pay_time']);//支付时间 |
|
54 |
|
|
55 |
if($res[$i]['pay_status']==0){ |
|
56 |
$res[$i]['pay_status']="未付款"; |
|
57 |
}else if($res[$i]['pay_status']==1){ |
|
58 |
$res[$i]['pay_status']="付款中"; |
|
59 |
}else if($res[$i]['pay_status']==2){ |
|
60 |
$res[$i]['pay_status']="已付款"; |
|
61 |
} |
|
62 |
$res[$i]['inv_complete_address'] = get_inv_complete_address($res[$i]); |
|
63 |
$aa = $res[$i]['order_id']; |
|
64 |
$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"; |
|
65 |
$res[$i]['xiang'] = $db ->getAll($sql); |
|
66 |
if($res[$i]['xiang']) |
|
67 |
{ |
|
68 |
$count_money = $res[$i]['xiang']; |
|
69 |
for($j=0;$j<count($count_money);$j++) |
|
70 |
{ |
|
71 |
$res[$i]['count_goods_amount'] += $count_money[$j]['goods_number'] * $count_money[$j]['goods_price']; |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
$res[$i]['count_amount'] = ($res[$i]['count_goods_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']); |
|
76 |
|
|
77 |
} |
|
78 |
//$result['orderInfo']=$res; |
|
79 |
|
|
80 |
$sql ="SELECT g.goods_thumb,s.* FROM ".$ecs->table('order_goods')."as s,".$ecs->table('goods')." as g WHERE s.order_id='$order_id' AND s.goods_id=g.goods_id"; |
|
81 |
$resa = $db -> getAll($sql); |
|
82 |
|
|
83 |
$smarty->assign('order_info',$res); |
|
84 |
$smarty->assign('order_goods',$resa); |
|
85 |
|
|
86 |
$result['result'] = $smarty->fetch('order_app.lib'); |
|
87 |
//file_put_contents('./22.txt',$result); |
|
88 |
print_r(json_encode($result)); |
|
89 |
//发票地址 |
|
90 |
function get_inv_complete_address($order) |
|
91 |
{ |
|
92 |
if($order['inv_type'] == 'normal_invoice') |
|
93 |
{ |
|
94 |
$address = trim(get_inv_complete_region($order['order_id'],$order['inv_type'])); |
|
95 |
if(empty($address)) |
|
96 |
{ |
|
97 |
return $order['address']; |
|
98 |
} |
|
99 |
else |
|
100 |
{ |
|
101 |
return '['.$address.'] '.$order['address']; |
|
102 |
} |
|
103 |
} |
|
104 |
elseif($order['inv_type'] == 'vat_invoice') |
|
105 |
{ |
|
106 |
$address = trim(get_inv_complete_region($order['order_id'],$order['inv_type'])); |
|
107 |
if(empty($address)) |
|
108 |
{ |
|
109 |
return $order['inv_consignee_address']; |
|
110 |
} |
|
111 |
else |
|
112 |
{ |
|
113 |
return '['.$address.'] '.$order['inv_consignee_address']; |
|
114 |
} |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
return ''; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
function get_inv_complete_region($order_id,$inv_type) |
|
123 |
{ |
|
124 |
if(!empty($order_id)) |
|
125 |
{ |
|
126 |
if($inv_type == 'normal_invoice') |
|
127 |
{ |
|
128 |
$sql = "SELECT concat(IFNULL(c.region_name, ''), ' ', IFNULL(p.region_name, ''), " . |
|
129 |
"' ', IFNULL(t.region_name, ''), ' ', IFNULL(d.region_name, '')) AS region " . |
|
130 |
"FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . |
|
131 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS c ON o.country = c.region_id " . |
|
132 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS p ON o.province = p.region_id " . |
|
133 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS t ON o.city = t.region_id " . |
|
134 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS d ON o.district = d.region_id " . |
|
135 |
"WHERE o.order_id = '$order_id'"; |
|
136 |
return $GLOBALS['db']->getOne($sql); |
|
137 |
} |
|
138 |
elseif($inv_type == 'vat_invoice') |
|
139 |
{ |
|
140 |
$sql = "SELECT concat(IFNULL(p.region_name, ''), " . |
|
141 |
"' ', IFNULL(t.region_name, ''), ' ', IFNULL(d.region_name, '')) AS region " . |
|
142 |
"FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . |
|
143 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS p ON o.inv_consignee_province = p.region_id " . |
|
144 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS t ON o.inv_consignee_city = t.region_id " . |
|
145 |
"LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS d ON o.inv_consignee_district = d.region_id " . |
|
146 |
"WHERE o.order_id = '$order_id'"; |
|
147 |
return $GLOBALS['db']->getOne($sql); |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
return ' '; |
|
152 |
} |
|
153 |
} |
|
154 |
else |
|
155 |
{ |
|
156 |
return ' '; |
|
157 |
} |
|
158 |
} |
|
159 |
ob_end_flush(); |
|
160 |
?> |