commit | author | age
|
3e083b
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 同城快递 |
|
5 |
*/ |
|
6 |
|
|
7 |
define('IN_ECS', true); |
|
8 |
|
|
9 |
require(dirname(__FILE__) . '/includes/init.php'); |
|
10 |
require(ROOT_PATH . 'includes/lib_order.php'); |
|
11 |
|
|
12 |
/* 快递单状态 */ |
|
13 |
$orderstatus_array = array( |
|
14 |
'1'=> array('name'=>'待确认', 'type'=>'0'), |
|
15 |
'2'=> array('name'=>'已确认未揽收', 'type'=>'0'), |
|
16 |
'3'=> array('name'=>'已确认已揽收', 'type'=>'0'), |
|
17 |
'4'=> array('name'=>'已签收', 'type'=>'1'), |
|
18 |
'5'=> array('name'=>'拒收', 'type'=>'2'), |
|
19 |
'6'=> array('name'=>'拒收已退回', 'type'=>'2'), |
|
20 |
'7'=> array('name'=>'已取消', 'type'=>'3'), |
|
21 |
); |
|
22 |
|
|
23 |
$action = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default'; |
|
24 |
$smarty->assign("action", $action); |
|
25 |
assign_template(); |
|
26 |
|
|
27 |
/* 同城快递 shopping_id */ |
|
28 |
$sql = "select shipping_id from ". $ecs->table('shipping') ." where shipping_code = 'tc_express' "; |
|
29 |
$shipping_id= $db->getOne($sql); |
|
30 |
|
|
31 |
/* ajax获取运费 */ |
|
32 |
if ($action=='get_shipping_fee') |
|
33 |
{ |
|
34 |
require(ROOT_PATH . 'includes/cls_json.php'); |
|
35 |
$region=array(); |
|
36 |
$json = new JSON; |
|
37 |
$result = array('error' => 0, 'message' => '', 'content' => ''); |
|
38 |
$_POST['goods']=strip_tags(urldecode($_POST['goods'])); |
|
39 |
$_POST['goods'] = json_str_iconv($_POST['goods']); |
|
40 |
$goods = $json->decode($_POST['goods']); |
|
41 |
|
|
42 |
$region['country'] = $goods->country; |
|
43 |
$region['province'] = $goods->province; |
|
44 |
$region['city'] = $goods->city; |
|
45 |
$region['district'] = $goods->district; |
|
46 |
$goods_weight = $goods->goods_weight; |
|
47 |
$shipping_info = shipping_area_info($shipping_id, $region); |
|
48 |
$shipping_fee = shipping_fee($shipping_info['shipping_code'],$shipping_info['configure'], $goods_weight, '0', '0'); |
|
49 |
|
|
50 |
$result['content'] = $shipping_fee; |
|
51 |
die($json->encode($result)); |
|
52 |
} |
|
53 |
|
|
54 |
/* ajax获取运单状态 */ |
|
55 |
if ($action=='get_OrderStatus') |
|
56 |
{ |
|
57 |
require(ROOT_PATH . 'includes/cls_json.php'); |
|
58 |
require( ROOT_PATH .'includes/cls_captcha.php'); |
|
59 |
$json = new JSON; |
|
60 |
$result = array('error' => 0, 'message' => '', 'content' => ''); |
|
61 |
$_POST['order']=strip_tags(urldecode($_POST['order'])); |
|
62 |
$_POST['order'] = json_str_iconv($_POST['order']); |
|
63 |
$order = $json->decode($_POST['order']); |
|
64 |
|
|
65 |
$validator = new captcha(); |
|
66 |
if (!$validator->check_word($order->captcha)) |
|
67 |
{ |
|
68 |
$result['content']='验证码不正确!'; |
|
69 |
die($json->encode($result)); |
|
70 |
} |
|
71 |
|
|
72 |
$sql="select order_id from ". $ecs->table('kuaidi_order') ." where order_sn='". $order->order_sn ."' "; |
|
73 |
$order_id = $db->getOne($sql); |
|
74 |
if(!$order_id) |
|
75 |
{ |
|
76 |
$result['content']='抱歉,没有您要的运单号哦!'; |
|
77 |
} |
|
78 |
else |
|
79 |
{ |
|
80 |
$sql="select * from ". $ecs->table('kuaidi_order_status') ." where order_id='$order_id' order by status_id"; |
|
81 |
$res_status = $db->query($sql); |
|
82 |
$have_shipping_info =0; |
|
83 |
$shipping_info =""; |
|
84 |
while($row_status = $db->fetchRow($res_status)) |
|
85 |
{ |
|
86 |
if ($row_status['status_display']==1) |
|
87 |
{ |
|
88 |
switch ($row_status['status_id']) |
|
89 |
{ |
|
90 |
case 1 : |
|
91 |
$shipping_info .= "您提交了订单,请等待确认。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
92 |
break; |
|
93 |
case 2 : |
|
94 |
$shipping_info .= "您的快件已经确认,等待快递员揽收。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
95 |
break; |
|
96 |
case 3 : |
|
97 |
$postman_id = $db->getOne("select postman_id from ".$ecs->table('kuaidi_order')." where order_sn='".$order->order_sn."'"); |
|
98 |
$postman_info = $db->getRow("select postman_name, mobile from ".$ecs->table('postman')." where postman_id=".$postman_id); |
|
99 |
$shipping_info .= "您的快件正在派送,快递员:".$postman_info['postman_name'].",电话:".$postman_info['mobile']." (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
100 |
break; |
|
101 |
case 4 : |
|
102 |
$shipping_info .= "您的快件已经签收。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
103 |
break; |
|
104 |
case 5 : |
|
105 |
$shipping_info .= "您的快件已被拒收。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
106 |
break; |
|
107 |
case 6 : |
|
108 |
$shipping_info .= "您拒收的快件已被退回。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
109 |
break; |
|
110 |
case 7 : |
|
111 |
$shipping_info .= "您的快件已经取消。 (".local_date('Y-m-d H:i:s', $row_status['status_time']).")"; |
|
112 |
break; |
|
113 |
} |
|
114 |
|
|
115 |
$shipping_info .= "<br>"; |
|
116 |
|
|
117 |
if ($row_status['status_id'] >= 1) |
|
118 |
{ |
|
119 |
$have_shipping_info++; |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
if ($have_shipping_info) |
|
124 |
{ |
|
125 |
$result['content'] = $shipping_info; |
|
126 |
} |
|
127 |
else |
|
128 |
{ |
|
129 |
$result['content']='抱歉,暂时还没有该运单的物流信息哦!'; |
|
130 |
} |
|
131 |
} |
|
132 |
die($json->encode($result)); |
|
133 |
|
|
134 |
} |
|
135 |
|
|
136 |
/* 保存快递单 */ |
|
137 |
if ($action=='save_kuaidi') |
|
138 |
{ |
|
139 |
|
|
140 |
if (isset($_POST['yzcode']) && $_POST['yzcode']==$_SESSION['yzcode']) |
|
141 |
{ |
|
142 |
$user_id = $_SESSION['user_id']; |
|
143 |
$send_name = $_POST['send_name'] ? addslashes(trim($_POST['send_name'])) : ""; |
|
144 |
$send_tel = $_POST['send_tel'] ? addslashes(trim($_POST['send_tel'])) : ""; |
|
145 |
$send_region_id = $_POST['send_region_id'] ? intval($_POST['send_region_id']) : "0"; |
|
146 |
$send_address = $_POST['send_address'] ? addslashes(trim($_POST['send_address'])) : ""; |
|
147 |
$to_name = $_POST['to_name'] ? addslashes(trim($_POST['to_name'])) : ""; |
|
148 |
$to_tel = $_POST['to_tel'] ? addslashes(trim($_POST['to_tel'])) : ""; |
|
149 |
$to_region_id = $_POST['to_region_id'] ? intval($_POST['to_region_id']) : "0"; |
|
150 |
$to_address = $_POST['to_address'] ? addslashes(trim($_POST['to_address'])) : ""; |
|
151 |
$goods_weight = $_POST['goods_weight'] ? addslashes(trim($_POST['goods_weight'])) : "1"; |
|
152 |
$goods_type = $_POST['goods_type'] ? intval($_POST['goods_type']) : "1"; |
|
153 |
$goods_name = $_POST['goods_name'] && $_POST['goods_name']!='填写物品名称' ? addslashes(trim($_POST['goods_name'])) : ""; |
|
154 |
$package_num = $_POST['package_num'] ? intval($_POST['package_num']) : "1"; |
|
155 |
$start_time = $_POST['start_time'] ? strtotime($_POST['start_time']) : "0"; |
|
156 |
$end_time = $_POST['end_time'] ? strtotime($_POST['end_time']) : "0"; |
|
157 |
$money = $_POST['money'] ? addslashes(trim($_POST['money'])) : "0"; |
|
158 |
|
|
159 |
$sql="insert into ". $ecs->table('kuaidi_order') ."(user_id, send_name, send_tel, send_region_id, send_address, to_name, to_tel, ". |
|
160 |
"to_region_id, to_address, goods_weight, goods_type, goods_name, package_num, start_time, end_time, money, add_time ) ". |
|
161 |
"values('$user_id', '$send_name', '$send_tel', '$send_region_id', '$send_address', '$to_name', '$to_tel', ". |
|
162 |
" '$to_region_id', '$to_address', '$goods_weight', '$goods_type', '$goods_name', '$package_num', '$start_time', '$end_time', '$money', '". gmtime()."' )"; |
|
163 |
$db->query($sql); |
|
164 |
$order_id = $db->insert_id(); |
|
165 |
foreach ($orderstatus_array AS $okey=>$oval) |
|
166 |
{ |
|
167 |
$status_display = $okey ==1 ? '1' : '0'; |
|
168 |
$sql="insert into ".$ecs->table('kuaidi_order_status'). |
|
169 |
"(order_id, status_id, status_name, status_type, status_display, status_time) ". |
|
170 |
"values('$order_id', '$okey', '$oval[name]', '$oval[type]', '$status_display', '" . gmtime() . "') "; |
|
171 |
$db->query($sql); |
|
172 |
} |
|
173 |
|
|
174 |
$smarty->assign('error', 0); |
|
175 |
$shop_name = $_CFG['shop_name'] ? $_CFG['shop_name'] : "XXX同城快递"; |
|
176 |
$smarty->assign('shop_name', $shop_name); |
|
177 |
$smarty->assign('message', $shop_name.'已收到您的寄件信息,请等待快递人员上门揽件!'); |
|
178 |
$_SESSION['yzcode'] = ''; |
|
179 |
} |
|
180 |
else |
|
181 |
{ |
|
182 |
$smarty->assign('error', 1); |
|
183 |
$smarty->assign('message', "请不要非法提交或重复提交!"); |
|
184 |
} |
|
185 |
$service_phone = $_CFG['service_phone'] ? $_CFG['service_phone'] : '01011112222'; |
|
186 |
$smarty->assign('service_phone', $service_phone); |
|
187 |
$smarty->display('kuaidi_transaction.dwt'); |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
/* 查询运单状态 */ |
|
192 |
if ($action=='query_kuaidi') |
|
193 |
{ |
|
194 |
$smarty->assign('rand', mt_rand()); |
|
195 |
$smarty->display('kuaidi_transaction.dwt'); |
|
196 |
} |
|
197 |
|
|
198 |
/* 查询运费 */ |
|
199 |
if ($action=='query_cost') |
|
200 |
{ |
|
201 |
/* 获取区域列表 */ |
|
202 |
if ($_CFG['shop_city']) |
|
203 |
{ |
|
204 |
$sql = "select * from ". $ecs->table('region') ." where parent_id='$_CFG[shop_city]' "; |
|
205 |
$district_list = $db->getAll($sql); |
|
206 |
$smarty->assign('district_list', $district_list); |
|
207 |
} |
|
208 |
$smarty->assign('shop_country', $_CFG['shop_country']); |
|
209 |
$smarty->assign('shop_province', $_CFG['shop_province']); |
|
210 |
$smarty->assign('shop_city', $_CFG['shop_city']); |
|
211 |
|
|
212 |
|
|
213 |
$smarty->display('kuaidi_transaction.dwt'); |
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
if ($action=='default') |
|
218 |
{ |
|
219 |
/* 获取区域列表 */ |
|
220 |
$shop_city = $_CFG['shop_city']; |
|
221 |
if ($shop_city) |
|
222 |
{ |
|
223 |
$shop_city_name = $db->getOne("select region_name from ". $ecs->table('region') ." where region_id=$shop_city "); |
|
224 |
$sql = "select * from ". $ecs->table('region') ." where parent_id='$shop_city' "; |
|
225 |
$district_list = $db->getAll($sql); |
|
226 |
$smarty->assign('district_list', $district_list); |
|
227 |
$smarty->assign('shop_city_name', $shop_city_name); |
|
228 |
} |
|
229 |
$smarty->assign('shop_country', $_CFG['shop_country']); |
|
230 |
$smarty->assign('shop_province', $_CFG['shop_province']); |
|
231 |
$smarty->assign('shop_city', $_CFG['shop_city']); |
|
232 |
|
|
233 |
if(!empty($_CFG['qq'])){ |
|
234 |
$qqinfo = explode(',',$_CFG['qq']); |
|
235 |
$smarty->assign('qq', $qqinfo[1]); |
|
236 |
} |
|
237 |
|
|
238 |
$yzcode=mt_rand(0,1000000); |
|
239 |
$_SESSION['yzcode'] = $yzcode; |
|
240 |
$smarty->assign('yzcode', $yzcode); |
|
241 |
|
|
242 |
$smarty->display('kuaidi.dwt'); |
|
243 |
} |
|
244 |
/*------------------------------------------------------ */ |
|
245 |
//-- PRIVATE FUNCTION |
|
246 |
/*------------------------------------------------------ */ |
|
247 |
?> |