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 |
|
|
11 |
$tg_id = $_SESSION['takegoods_id_68ecshop']; |
|
12 |
$user_id = $_SESSION['user_id']; |
|
13 |
|
|
14 |
if (empty($tg_id) || empty($user_id)) |
|
15 |
{ |
|
16 |
header("Location:user.php?act=tg_login"); |
|
17 |
} |
|
18 |
|
|
19 |
/*------------------------------------------------------ */ |
|
20 |
//-- act 操作项的初始化 |
|
21 |
/*------------------------------------------------------ */ |
|
22 |
if (empty($_REQUEST['act'])) |
|
23 |
{ |
|
24 |
$_REQUEST['act'] = 'list'; |
|
25 |
} |
|
26 |
|
|
27 |
/*------------------------------------------------------ */ |
|
28 |
//-- PROCESSOR |
|
29 |
/*------------------------------------------------------ */ |
|
30 |
|
|
31 |
|
|
32 |
/*------------------------------------------------------ */ |
|
33 |
//-- 退出提货券登录 |
|
34 |
/*------------------------------------------------------ */ |
|
35 |
if ($_REQUEST['act'] == 'logout') |
|
36 |
{ |
|
37 |
$_SESSION['takegoods_id_68ecshop']=0; |
|
38 |
$_SESSION['takegoods_sn_68ecshop']=''; |
|
39 |
header("Location:user.php?act=tg_login"); |
|
40 |
} |
|
41 |
|
|
42 |
/*------------------------------------------------------ */ |
|
43 |
//-- 提货券商品列表 |
|
44 |
/*------------------------------------------------------ */ |
|
45 |
if ($_REQUEST['act'] == 'list') |
|
46 |
{ |
|
47 |
/* 初始化分页信息 */ |
|
48 |
$page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; |
|
49 |
$size = isset($_CFG['page_size']) && intval($_CFG['page_size']) > 0 ? intval($_CFG['page_size']) : 10; |
|
50 |
|
|
51 |
|
|
52 |
assign_template(); |
|
53 |
$smarty->assign('keywords', '提货商品列表'); |
|
54 |
$smarty->assign('description', '提货商品列表'); |
|
55 |
$smarty->assign('page_title', '提货商品列表'); // 页面标题 |
|
56 |
$smarty->assign('ur_here', '<a href="." class="index">首页</a><span class="crumbs-arrow">></span><span class="last">提货</span>'); // 当前位置 |
|
57 |
$smarty->assign('categories', get_categories_tree()); // 分类树 |
|
58 |
$smarty->assign('helps', get_shop_help()); // 网店帮助 |
|
59 |
$smarty->assign('top_goods', get_top10()); // 销售排行 |
|
60 |
$smarty->assign('promotion_info', get_promotion_info()); // 促销活动信息 |
|
61 |
$smarty->assign('cainixihuan', get_cainixihuan()); //猜你喜欢 |
|
62 |
|
|
63 |
$sql = "select tg.*, tt.type_money_count,tt.type_money from ".$ecs->table('takegoods')."AS tg left join ".$ecs->table('takegoods_type')."AS tt on tg.type_id = tt.type_id where tg.tg_id='$tg_id' "; |
|
64 |
$rowtg = $db->getRow($sql); |
|
65 |
$rowtg['num_used'] = ($rowtg['used_time'] == 0) ? 0 : count(explode('@',$rowtg['used_time'])); |
|
66 |
$rowtg['num_surplus'] = $rowtg['type_money_count'] - $rowtg['num_used']; |
|
67 |
|
|
68 |
$smarty->assign('rowtg', $rowtg); |
|
69 |
|
|
70 |
$sql = "select goods_ids from ". $ecs->table('takegoods_goods') ." where tg_id = '$tg_id' "; |
|
71 |
$goods_ids = $db->getOne($sql); |
|
72 |
if (empty($goods_ids)) |
|
73 |
{ |
|
74 |
$sql = "select goods_ids from ". $ecs->table('takegoods_type_goods') ." where tg_type_id = '$rowtg[type_id]' "; |
|
75 |
$goods_ids = $db->getOne($sql); |
|
76 |
} |
|
77 |
|
|
78 |
$sql = "select goods_id, goods_name, goods_thumb,shop_price from ". $ecs->table('goods') ." where goods_id ". db_create_in($goods_ids); |
|
79 |
$res = $db->query($sql); |
|
80 |
while ($row=$db->fetchRow($res)) |
|
81 |
{ |
|
82 |
$row['shop_price'] = price_format($row['shop_price']); |
|
83 |
$row['goods_shortname'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; |
|
84 |
$row['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); |
|
85 |
$row['goods_url'] =build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); |
|
86 |
$goods_list[] = $row; |
|
87 |
} |
|
88 |
$smarty->assign('goods_list', $goods_list); |
|
89 |
|
|
90 |
|
|
91 |
$smarty->assign('country_list', get_regions()); |
|
92 |
$smarty->assign('shop_country', $_CFG['shop_country']); |
|
93 |
$smarty->assign('shop_province_list', get_regions(1, $_CFG['shop_country'])); |
|
94 |
$consignee_list[] = array('country' => $_CFG['shop_country']); |
|
95 |
$smarty->assign('name_of_region', array($_CFG['name_of_region_1'], $_CFG['name_of_region_2'], $_CFG['name_of_region_3'], $_CFG['name_of_region_4'])); |
|
96 |
$smarty->assign('consignee_list', $consignee_list); |
|
97 |
$province_list = array(); |
|
98 |
foreach ($consignee_list as $region_id => $consignee) |
|
99 |
{ |
|
100 |
$consignee['country'] = isset($consignee['country']) ? intval($consignee['country']) : 0; |
|
101 |
$consignee['province'] = isset($consignee['province']) ? intval($consignee['province']) : 0; |
|
102 |
$province_list[$region_id] = get_regions(1, $consignee['country']); |
|
103 |
|
|
104 |
} |
|
105 |
$smarty->assign('province_list', $province_list); |
|
106 |
|
|
107 |
$smarty->display('takegoods.dwt'); |
|
108 |
} |
|
109 |
|
|
110 |
/*------------------------------------------------------ */ |
|
111 |
//-- 提货 |
|
112 |
/*------------------------------------------------------ */ |
|
113 |
elseif ($_REQUEST['act'] == 'take') |
|
114 |
{ |
|
115 |
$goods_id = isset($_POST['goods_id']) ? intval($_POST['goods_id']) : 0; |
|
116 |
$takegoods_sn_68ecshop = $_SESSION['takegoods_sn_68ecshop']; |
|
117 |
$takegoods_id_68ecshop = isset($_POST['takegoods_id_68ecshop']) ? intval($_POST['takegoods_id_68ecshop']) : 0; |
|
118 |
if (empty($takegoods_id_68ecshop)) |
|
119 |
{ |
|
120 |
show_message('错误操作', '返回上一页', 'takegoods.php', 'error'); |
|
121 |
} |
|
122 |
else |
|
123 |
{ |
|
124 |
$sql = "select goods_ids from ". $ecs->table('takegoods_goods') ." where tg_id='$takegoods_id_68ecshop' "; |
|
125 |
$goods_ids = $db->getOne($sql); |
|
126 |
if (empty($goods_ids)) |
|
127 |
{ |
|
128 |
$sql = "select tgtg.goods_ids from ". $ecs->table('takegoods') ." AS tg left join ". $ecs->table('takegoods_type_goods') . |
|
129 |
" AS tgtg on tgtg.tg_type_id=tg.type_id ". |
|
130 |
" where tg.tg_id='$takegoods_id_68ecshop' "; |
|
131 |
$goods_ids = $db->getOne($sql); |
|
132 |
} |
|
133 |
//echo $goods_ids."???".$goods_id;exit; |
|
134 |
if (strstr(",".$goods_ids.",", ",".$goods_id.",")===FALSE) |
|
135 |
{ |
|
136 |
show_message('非法操作,请不要乱来', '返回上一页', 'takegoods.php', 'error'); |
|
137 |
} |
|
138 |
$sql = "select tg.used_time, tt.type_money_count from ". $ecs->table('takegoods') ."AS tg left join ".$ecs->table('takegoods_type')."AS tt on tg.type_id = tt.type_id where tg.tg_id='$takegoods_id_68ecshop' "; |
|
139 |
$take_have = $db->getRow($sql); |
|
140 |
if (!empty($take_have['used_time']) && count(explode('@',$take_have['used_time'])) >= $take_have['type_money_count']) |
|
141 |
{ |
|
142 |
show_message('对不起,该提货卡提货次数已用完!', '返回上一页', 'takegoods.php', 'error'); |
|
143 |
} |
|
144 |
} |
|
145 |
$add_time = gmtime(); |
|
146 |
$goods_name = $db->getOne("select goods_name from ". $ecs->table('goods') . " where goods_id= '$goods_id' "); |
|
147 |
$country = $_POST['country'] ? intval($_POST['country']) : 0; |
|
148 |
$province = $_POST['province'] ? intval($_POST['province']) : 0; |
|
149 |
$city = $_POST['city'] ? intval($_POST['city']) : 0; |
|
150 |
$district = $_POST['district'] ? intval($_POST['district']) : 0; |
|
151 |
$address = $_POST['address'] ? trim($_POST['address']) : ''; |
|
152 |
$consignee = $_POST['consignee'] ? trim($_POST['consignee']) : ''; |
|
153 |
$mobile = $_POST['mobile'] ? trim($_POST['mobile']) : ''; |
|
154 |
$email = $_POST['email'] ? trim($_POST['email']) : ''; |
|
155 |
$sql = "insert into ". $ecs->table('takegoods_order') . "(tg_id, tg_sn, user_id, goods_id, goods_name, country, province, city, district, address, consignee,mobile,email,add_time )". |
|
156 |
" value('$takegoods_id_68ecshop', '$takegoods_sn_68ecshop', '$user_id', '$goods_id', '$goods_name', '$country', '$province','$city','$district', '$address', '$consignee' , '$mobile', '$email', '$add_time')"; |
|
157 |
$db->query($sql); |
|
158 |
$tg_order_id = $db->insert_id(); |
|
159 |
|
|
160 |
$add_time_sql = "select tg_order_id, used_time from ".$ecs->table('takegoods')." where tg_id='$takegoods_id_68ecshop'"; |
|
161 |
$add_time_db = $db->getRow($add_time_sql); |
|
162 |
if ($add_time_db['used_time'] != 0) |
|
163 |
{ |
|
164 |
$tg_order_id = $add_time_db['tg_order_id']."@".$tg_order_id; |
|
165 |
$add_time = $add_time_db['used_time']."@".$add_time; |
|
166 |
} |
|
167 |
|
|
168 |
$sql = "update ". $ecs->table('takegoods') ." set tg_order_id='$tg_order_id', used_time='$add_time' where tg_id='$takegoods_id_68ecshop' "; |
|
169 |
$db->query($sql); |
|
170 |
|
|
171 |
if ($_CFG['takegoods_send_email'] =='1' || $_CFG['takegoods_send_sms'] == '1' ) |
|
172 |
{ |
|
173 |
$take_user_name = $db->getOne("select user_name from ". $ecs->table('users') ." where user_id='$user_id' "); |
|
174 |
$content1 = '会员 '. $take_user_name .' 于 '.local_date('Y-m-d H:i:s')." 提货成功!请尽快安排发货。"; |
|
175 |
$content2 = '恭喜您于 '.local_date('Y-m-d H:i:s')." 提货成功!商家会尽快安排给您发货。"; |
|
176 |
if ($_CFG['takegoods_send_email'] == '1') |
|
177 |
{ |
|
178 |
$admin_email = $db->getOne("select email from ". $ecs->table('admin_user') ." where user_id=1 "); |
|
179 |
send_mail($_CFG['shop_name'], $admin_email, '卡号:'. $takegoods_sn_68ecshop .' 提货成功', $content1, 0); |
|
180 |
send_mail($_CFG['shop_name'], $email, '卡号:'. $takegoods_sn_68ecshop .' 提货成功', $content2, 0); |
|
181 |
} |
|
182 |
if ($_CFG['takegoods_send_sms'] == '1' ) |
|
183 |
{ |
|
184 |
|
|
185 |
include_once('send.php'); |
|
186 |
sendSMS($_CFG['sms_shop_mobile'],$content1); |
|
187 |
sendSMS($mobile,$content2); |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
|
|
192 |
$country_name = $db->getOne("select region_name from ". $ecs->table('region') ." where region_id='$country' "); |
|
193 |
$province_name = $db->getOne("select region_name from ". $ecs->table('region') ." where region_id='$province' "); |
|
194 |
$city_name = $db->getOne("select region_name from ". $ecs->table('region') ." where region_id='$city' "); |
|
195 |
$district_name = $db->getOne("select region_name from ". $ecs->table('region') ." where region_id='$district' "); |
|
196 |
|
|
197 |
|
|
198 |
show_message('提货成功,货品将配送到'. $country_name .' '.$province_name.' '. $city_name. ' '.$district_name.' '.$address.',请注意查收', '去购物', '.'); |
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
/*------------------------------------------------------ */ |
|
203 |
//-- 兑换 |
|
204 |
/*------------------------------------------------------ */ |
|
205 |
|
|
206 |
elseif ($_REQUEST['act'] == 'buy') |
|
207 |
{ |
|
208 |
|
|
209 |
} |
|
210 |
|
|
211 |
/*------------------------------------------------------ */ |
|
212 |
//-- PRIVATE FUNCTION |
|
213 |
/*------------------------------------------------------ */ |
|
214 |
|
|
215 |
|
|
216 |
/** |
|
217 |
* 获得积分兑换商品的详细信息 |
|
218 |
* |
|
219 |
* @access public |
|
220 |
* @param integer $goods_id |
|
221 |
* @return void |
|
222 |
*/ |
|
223 |
function get_exchange_goods_info($goods_id) |
|
224 |
{ |
|
225 |
$time = gmtime(); |
|
226 |
$sql = 'SELECT g.*, c.measure_unit, b.brand_id, b.brand_name AS goods_brand, eg.exchange_integral, eg.is_exchange ' . |
|
227 |
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . |
|
228 |
'LEFT JOIN ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg ON g.goods_id = eg.goods_id ' . |
|
229 |
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON g.cat_id = c.cat_id ' . |
|
230 |
'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON g.brand_id = b.brand_id ' . |
|
231 |
"WHERE g.goods_id = '$goods_id' AND g.is_delete = 0 " . |
|
232 |
'GROUP BY g.goods_id'; |
|
233 |
|
|
234 |
$row = $GLOBALS['db']->getRow($sql); |
|
235 |
|
|
236 |
if ($row !== false) |
|
237 |
{ |
|
238 |
/* 处理商品水印图片 */ |
|
239 |
$watermark_img = ''; |
|
240 |
|
|
241 |
if ($row['is_new'] != 0) |
|
242 |
{ |
|
243 |
$watermark_img = "watermark_new"; |
|
244 |
} |
|
245 |
elseif ($row['is_best'] != 0) |
|
246 |
{ |
|
247 |
$watermark_img = "watermark_best"; |
|
248 |
} |
|
249 |
elseif ($row['is_hot'] != 0) |
|
250 |
{ |
|
251 |
$watermark_img = 'watermark_hot'; |
|
252 |
} |
|
253 |
|
|
254 |
if ($watermark_img != '') |
|
255 |
{ |
|
256 |
$row['watermark_img'] = $watermark_img; |
|
257 |
} |
|
258 |
|
|
259 |
/* 修正重量显示 */ |
|
260 |
$row['goods_weight'] = (intval($row['goods_weight']) > 0) ? |
|
261 |
$row['goods_weight'] . $GLOBALS['_LANG']['kilogram'] : |
|
262 |
($row['goods_weight'] * 1000) . $GLOBALS['_LANG']['gram']; |
|
263 |
|
|
264 |
/* 修正上架时间显示 */ |
|
265 |
$row['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); |
|
266 |
|
|
267 |
/* 修正商品图片 */ |
|
268 |
$row['goods_img'] = get_image_path($goods_id, $row['goods_img']); |
|
269 |
$row['goods_thumb'] = get_image_path($goods_id, $row['goods_thumb'], true); |
|
270 |
|
|
271 |
return $row; |
|
272 |
} |
|
273 |
else |
|
274 |
{ |
|
275 |
return false; |
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
|
|
280 |
?> |