0, 'message' => '', 'content' => ''); /* * 购物车确认订单页面配送方式 0 快递 1 自提 */ if($_REQUEST['act'] == 'shipping_type'){ /*------------------------------------------------------ */ //-- 改变配送方式 /*------------------------------------------------------ */ include_once('includes/lib_order.php'); include_once('includes/cls_json.php'); $json = new JSON; $result = array('error' => 0, 'massage' => '', 'content' => '', 'need_insure' => 0, 'payment' => 1); //商家 $ru_id = isset($_POST['ru_id']) ? intval($_POST['ru_id']) : 0; /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; /* 配送方式 */ $shipping_type = isset($_POST['type']) ? intval($_POST['type']) : 0; /* 获得收货人信息 */ $consignee = get_consignee($_SESSION['user_id']); /* 对商品信息赋值 */ $cart_goods = cart_goods($flow_type, $_SESSION['cart_value']); // 取得商品列表,计算合计 if (empty($cart_goods) || !check_consignee_info($consignee, $flow_type)) { //ecmoban模板堂 --zhuo start if(empty($cart_goods)){ $result['error'] = 1; $result['massage'] = $_LANG['no_goods_in_cart']; }elseif(!check_consignee_info($consignee, $flow_type)){ $result['error'] = 2; $result['massage'] = $_LANG['au_buy_after_login']; } //ecmoban模板堂 --zhuo end } else { /* 取得购物流程设置 */ $smarty->assign('config', $_CFG); /* 取得订单信息 */ $order = flow_order_info(); /* 保存 session */ $_SESSION['flow_order'] = $order; $_SESSION['merchants_shipping'][$ru_id]['shipping_type'] = $shipping_type; //ecmoban模板堂 --zhuo start $cart_goods_number = get_buy_cart_goods_number($flow_type, $_SESSION['cart_value']); $smarty->assign('cart_goods_number', $cart_goods_number); $consignee['province_name'] = get_goods_region_name($consignee['province']); $consignee['city_name'] = get_goods_region_name($consignee['city']); $consignee['district_name'] = get_goods_region_name($consignee['district']); $consignee['consignee_address'] = $consignee['province_name'] . $consignee['city_name'] . $consignee['district_name'] . $consignee['address']; $smarty->assign('consignee', $consignee); $cart_goods_list = cart_goods($flow_type, $_SESSION['cart_value'], 1); // 取得商品列表,计算合计 $smarty->assign('goods_list', $cart_goods_list); /* 计算订单的费用 */ $total = order_fee($order, $cart_goods, $consignee, 0, $_SESSION['cart_value'], 0, $cart_goods_list); $smarty->assign('total', $total); //ecmoban模板堂 --zhuo end /* 团购标志 */ if ($flow_type == CART_GROUP_BUY_GOODS) { $smarty->assign('is_group_buy', 1); } $result['content'] = $smarty->fetch('library/order_total.lbi'); } $result['ru_id'] = $ru_id; $result['shipping_type'] = $shipping_type; echo $json->encode($result); exit; } elseif ($_REQUEST['act'] == 'edit_invoice') { /*------------------------------------------------------ */ //-- 改变发票的设置 /*------------------------------------------------------ */ include_once('includes/cls_json.php'); $result = array('error' => 0, 'content' => ''); $json = new JSON(); /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; /* 获得收货人信息 */ $consignee = get_consignee($_SESSION['user_id']); /* 对商品信息赋值 */ $cart_goods = cart_goods($flow_type, $_SESSION['cart_value']); // 取得商品列表,计算合计 if (empty($cart_goods) || !check_consignee_info($consignee, $flow_type)) { $result['error'] = 1; die($json->encode($result)); } else { /* 取得购物流程设置 */ $smarty->assign('config', $_CFG); /* 如果能开发票,取得发票内容列表 */ if ((!isset($_CFG['can_invoice']) || $_CFG['can_invoice'] == '1') && isset($_CFG['invoice_content']) && trim($_CFG['invoice_content']) != '' && $flow_type != CART_EXCHANGE_GOODS) { $inv_content_list = explode("\n", str_replace("\r", '', $_CFG['invoice_content'])); $smarty->assign('inv_content_list', $inv_content_list); $inv_type_list = array(); foreach ($_CFG['invoice_type']['type'] as $key => $type) { if (!empty($type)) { $inv_type_list[$type] = $type . ' [' . floatval($_CFG['invoice_type']['rate'][$key]) . '%]'; } } //抬头名称 $sql = "SELECT * FROM ". $ecs->table('order_invoice') ." WHERE user_id='$_SESSION[user_id]' LIMIT 3"; $order_invoice = $db->getAll($sql); $smarty->assign('order_invoice', $order_invoice); $smarty->assign('inv_type_list', $inv_type_list); } $result['content'] = $smarty->fetch('library/invoice.lbi'); echo $json->encode($result); exit; } } elseif ($_REQUEST['act'] == 'update_invoicename') { /*------------------------------------------------------ */ //-- 保存发票抬头名称 /*------------------------------------------------------ */ include_once('includes/cls_json.php'); $result = array('error' => '', 'msg' => '', 'content' => ''); $json = new JSON(); $user_id = $_SESSION['user_id']; $inv_payee = !empty($_POST['inv_payee']) ? json_str_iconv(urldecode($_POST['inv_payee'])) : ''; $invoice_id = !empty($_POST['invoice_id']) ? $_POST['invoice_id'] : 0; if(empty($user_id) || empty($inv_payee)){ $result['error'] = 1; $result['msg'] = '参数错误'; }else{ if($invoice_id == 0){ $sql = "INSERT INTO ". $ecs->table('order_invoice') ." SET user_id='$user_id', inv_payee='$inv_payee'"; $db->query($sql); $result['invoice_id'] = $db->insert_id(); }else{ $sql = "UPDATE ". $ecs->table('order_invoice') ." SET inv_payee='$inv_payee' WHERE invoice_id='$invoice_id'"; $db->query($sql); $result['invoice_id'] = $invoice_id; } } echo $json->encode($result); exit; } elseif ($_REQUEST['act'] == 'del_invoicename') { /*------------------------------------------------------ */ //-- 删除发票抬头名称 /*------------------------------------------------------ */ include_once('includes/cls_json.php'); $result = array('error' => '', 'msg' => '', 'content' => ''); $json = new JSON(); $user_id = $_SESSION['user_id']; $invoice_id = !empty($_POST['invoice_id']) ? $_POST['invoice_id'] : 0; if(empty($user_id)){ $result['error'] = 1; $result['msg'] = '参数错误'; }else{ $sql = "DELETE FROM ". $ecs->table('order_invoice') ." WHERE invoice_id='$invoice_id'"; $db->query($sql); } echo $json->encode($result); exit; } elseif ($_REQUEST['act'] == 'gotoInvoice') { /*------------------------------------------------------ */ //-- 修改并保存发票的设置 /*------------------------------------------------------ */ include_once('includes/cls_json.php'); $result = array('error' => '', 'content' => ''); $json = new JSON(); $invoice_id = !empty($_POST['invoice_id']) ? json_str_iconv(urldecode($_POST['invoice_id'])) : 0; $inv_content = !empty($_POST['inv_content']) ? json_str_iconv(urldecode($_POST['inv_content'])) : ''; /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; /* 获得收货人信息 */ $consignee = get_consignee($_SESSION['user_id']); /* 对商品信息赋值 */ $cart_goods = cart_goods($flow_type, $_SESSION['cart_value']); // 取得商品列表,计算合计 if (empty($cart_goods) || !check_consignee_info($consignee, $flow_type)) { $result['error'] = $_LANG['no_goods_in_cart']; die($json->encode($result)); } else { /* 取得购物流程设置 */ $smarty->assign('config', $_CFG); /* 取得订单信息 */ $order = flow_order_info(); if ($inv_content) { if($invoice_id > 0){ $sql = "SELECT inv_payee FROM ". $ecs->table('order_invoice') ." WHERE invoice_id='$invoice_id'"; $inv_payee = $db->getOne($sql); }else{ $inv_payee = '个人'; } $order['need_inv'] = 1; $order['inv_type'] = $_CFG['invoice_type']['type'][0]; $order['inv_payee'] = $inv_payee; $order['inv_content'] = $inv_content; } else { $order['need_inv'] = 0; $order['inv_type'] = ''; $order['inv_payee'] = ''; $order['inv_content'] = ''; } //ecmoban模板堂 --zhuo start $cart_goods_number = get_buy_cart_goods_number($flow_type, $_SESSION['cart_value']); $smarty->assign('cart_goods_number', $cart_goods_number); $consignee['province_name'] = get_goods_region_name($consignee['province']); $consignee['city_name'] = get_goods_region_name($consignee['city']); $consignee['district_name'] = get_goods_region_name($consignee['district']); $consignee['consignee_address'] = $consignee['province_name'] . $consignee['city_name'] . $consignee['district_name'] . $consignee['address']; $smarty->assign('consignee', $consignee); $cart_goods_list = cart_goods($flow_type, $_SESSION['cart_value'], 1); // 取得商品列表,计算合计 $smarty->assign('goods_list', $cart_goods_list); /* 计算订单的费用 */ $total = order_fee($order, $cart_goods, $consignee, 0, $_SESSION['cart_value'], 0, $cart_goods_list); $smarty->assign('total', $total); //ecmoban模板堂 --zhuo end /* 团购标志 */ if ($flow_type == CART_GROUP_BUY_GOODS) { $smarty->assign('is_group_buy', 1); } $result['inv_payee'] = $order['inv_payee']; $result['inv_content'] = $order['inv_content']; $result['content'] = $smarty->fetch('library/order_total.lbi'); } } /* * 删除购物车商品 */ elseif($_REQUEST['act'] == 'delete_cart_goods'){ $cart_value = isset($_REQUEST['cart_value']) ? json_str_iconv($_REQUEST['cart_value']) : ''; if($cart_value){ $sql = "DELETE FROM " .$GLOBALS['ecs']->table('cart'). " WHERE rec_id IN($cart_value)"; $GLOBALS['db']->query($sql); } $result['cart_value'] = $cart_value; } /* * 删除并移除关注 */ elseif($_REQUEST['act'] == 'drop_to_collect'){ if ($_SESSION['user_id'] > 0) { $cart_value = isset($_REQUEST['cart_value']) ? json_str_iconv($_REQUEST['cart_value']) : ''; $goods_list = $db->getAll("SELECT goods_id, rec_id FROM " .$ecs->table('cart'). " WHERE rec_id IN($cart_value)"); foreach($goods_list as $row){ $count = $db->getOne("SELECT goods_id FROM " . $ecs->table('collect_goods') . " WHERE user_id = '$sess' AND goods_id = '" .$row['goods_id']. "'"); if (empty($count)) { $time = gmtime(); $sql = "INSERT INTO " .$GLOBALS['ecs']->table('collect_goods'). " (user_id, goods_id, add_time)" . "VALUES ('$sess', '" .$row['goods_id']. "', '$time')"; $db->query($sql); } flow_drop_cart_goods($row['rec_id']); } } } /* * 订单分页查询 */ else if($_REQUEST['act'] == 'user_order_gotopage'){ require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php'); include_once(ROOT_PATH . 'includes/lib_transaction.php'); $id = !empty($_GET['id']) ? json_str_iconv($_GET['id']) : array(); $page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1; $type = 0; if($id){ $id = explode("=", $id); } $where = ""; $order = ""; if(count($id) > 1){ $user_id = $id[0]; $id = explode("|", $id[1]); $order = get_str_array1($id); $where = get_order_search_keyword($order); $record_count = $db->getAll("SELECT oi.order_id FROM " .$ecs->table('order_info') ." as oi" . " left join " .$ecs->table('order_goods') ." as og on oi.order_id = og.order_id" . " WHERE oi.user_id = '$user_id' and oi.is_delete = '$show_type' " . " and (select count(*) from " .$GLOBALS['ecs']->table('order_info'). " as oi_2 where oi_2.main_order_id = oi.order_id) = 0 " . //主订单下有子订单时,则主订单不显示 $where . " group by oi.order_id"); $record_count = count($record_count); }else{ $user_id = $id[0]; $record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('order_info'). " as oi_1" . " WHERE oi_1.user_id = '$user_id' and oi_1.is_delete = '$type' " . " and (select count(*) from " .$GLOBALS['ecs']->table('order_info'). " as oi_2 where oi_2.main_order_id = oi_1.order_id) = 0 " //主订单下有子订单时,则主订单不显示 ); } $order->action = "order_list"; $orders = get_user_orders($user_id, $record_count, $page, $type, $where, $order); $smarty->assign('orders', $orders); $smarty->assign('action', $order->action); $result['content'] = $smarty->fetch("library/user_order_list.lbi"); /* * 店铺街分页查询 */ }else if($_REQUEST['act'] == 'store_shop_gotoPage'){ $id = !empty($_GET['id']) ? json_str_iconv($_GET['id']) : array(); $page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1; $type = isset($_GET['type']) && intval($_GET['type']) > 0 ? intval($_GET['type']) : 0; $libType = isset($_GET['libType']) && intval($_GET['libType']) > 0 ? intval($_GET['libType']) : 0; if($libType == 1){ $size = 10; }else{ $size = 15; } $sort = ""; $order = ""; $keywords = ""; $region_id = ""; $area_id = ""; $store_province = ""; $store_city = ""; $store_district = ""; if($id){ $id = explode("|", $id); $id = get_str_array2($id); $sort = isset($id['sort']) ? $id['sort'] : 'shop_id'; $order = isset($id['order']) ? $id['order'] : 'DESC'; $keywords = isset($id['keywords']) ? $id['keywords'] : ''; $region_id = isset($id['region_id']) ? $id['region_id'] : ''; $area_id = isset($id['area_id']) ? $id['area_id'] : ''; $store_province = isset($id['store_province']) ? $id['store_province'] : ''; $store_city = isset($id['store_city']) ? $id['store_city'] : ''; $store_district = isset($id['store_district']) ? $id['store_district'] : ''; $store_user = isset($id['store_user']) ? $id['store_user'] : ''; } $count = get_store_shop_count($keywords, $sort, $store_province, $store_city, $store_district); $store_shop_list = get_store_shop_list($libType, $keywords, $count, $size, $page, $sort, $order, $region_id, $area_id, $store_province, $store_city, $store_district, $store_user); $shop_list = $store_shop_list['shop_list']; $smarty->assign('store_shop_list', $shop_list); $smarty->assign('pager', $store_shop_list['pager']); $smarty->assign('count', $count); $smarty->assign('size', $size); if($libType == 1){ $result['content'] = $smarty->fetch("library/search_store_shop_list.lbi"); }else{ $result['content'] = $smarty->fetch("library/store_shop_list.lbi"); } } //分类树子分类 else if($_REQUEST['act'] == 'getCategoryCallback'){ $cat_id = isset($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0; $cat_topic_file = "category_topic" . $cat_id; $category_topic = read_static_cache($cat_topic_file); if($category_topic === false){ $category_topic = get_category_topic($cat_id); if($category_topic){ write_static_cache($cat_topic_file, $category_topic); } } $smarty->assign('category_topic', $category_topic); $cat_file = "category_tree_child" . $cat_id; $child_tree = read_static_cache($cat_file); //分类树子分类分类列表 if($child_tree === false) { $child_tree = get_category_parentChild_tree1($cat_id); write_static_cache($cat_file, $child_tree); } $smarty->assign('child_tree', $child_tree); //分类树品牌 $brands_file = "category_tree_brands" . $cat_id; $brands_ad = read_static_cache($brands_file); if($brands_ad === false) { $brands_ad = get_category_brands_ad($cat_id); write_static_cache($brands_file, $brands_ad); } $smarty->assign('brands_ad', $brands_ad); $result['cat_id'] = $cat_id; $result['topic_content'] = $smarty->fetch("library/index_cat_topic.lbi"); $result['cat_content'] = $smarty->fetch("library/index_cat_tree.lbi"); $result['brands_ad_content'] = $smarty->fetch("library/index_cat_brand_ad.lbi"); } //无货结算 else if($_REQUEST['act'] == 'goods_stock_exhausted'){ /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; $rec_number = isset($_REQUEST['rec_number']) ? htmlspecialchars($_REQUEST['rec_number']) : ''; //缺货商品 $warehouse_id = !empty($_REQUEST['warehouse_id']) ? intval($_REQUEST['warehouse_id']) : 0; $area_id = !empty($_REQUEST['area_id']) ? intval($_REQUEST['area_id']) : 0; if(!empty($rec_number)){ $cart_value = get_sc_str_replace($_SESSION['cart_value'], $rec_number); } /* 对商品信息赋值 */ $cart_goods_list = cart_goods($flow_type, $_SESSION['cart_value'], 1, $warehouse_id, $area_id); // 取得商品列表,计算合计 $cart_goods_list_new = cart_by_favourable($cart_goods_list); $GLOBALS['smarty']->assign('goods_list', $cart_goods_list_new); $GLOBALS['smarty']->assign('cart_value', $cart_value); $result['cart_value'] = $cart_value; $result['content'] = $GLOBALS['smarty']->fetch('library/goods_stock_exhausted.lbi'); } //分类树子分类 else if($_REQUEST['act'] == 'goods_delivery_area'){ include_once('includes/lib_transaction.php'); $_POST['area']=strip_tags(urldecode($_POST['area'])); $_POST['area'] = json_str_iconv($_POST['area']); $result = array('error' => 0, 'message' => '', 'content' => ''); $json = new JSON; if (empty($_POST['area'])) { $result['error'] = 1; die($json->encode($result)); } $area = $json->decode($_POST['area']); $province_id = $area->province_id; $city_id = $area->city_id; $district_id = $area->district_id; $goods_id = $area->goods_id; $user_id = $area->user_id; $region_id = $area->region_id; $area_id = $area->area_id; $merchant_id = $area->merchant_id; $province_list = get_warehouse_province(); $city_list = get_region_city_county($province_id); $district_list = get_region_city_county($city_id); $warehouse_list = get_warehouse_list_goods(); $warehouse_name = get_warehouse_name_id($region_id); $GLOBALS['smarty']->assign('province_list', $province_list); //省、直辖市 $GLOBALS['smarty']->assign('city_list', $city_list); //省下级市 $GLOBALS['smarty']->assign('district_list', $district_list);//市下级县 $GLOBALS['smarty']->assign('goods_id', $goods_id); //商品ID $GLOBALS['smarty']->assign('warehouse_list', $warehouse_list); $GLOBALS['smarty']->assign('warehouse_name', $warehouse_name); //仓库名称 $GLOBALS['smarty']->assign('region_id', $region_id); //商品仓库region_id $GLOBALS['smarty']->assign('user_id', $user_id); $GLOBALS['smarty']->assign('area_id', $area_id); //地区ID $GLOBALS['smarty']->assign('merchant_id', $merchant_id); //地区ID /* 获得用户所有的收货人信息 */ $consignee_list = get_new_consignee_list($_SESSION['user_id']); $GLOBALS['smarty']->assign('consignee_list', $consignee_list); //收货地址列表 /* 获取默认收货ID */ $address_id = $db->getOne("SELECT address_id FROM " .$ecs->table('users'). " WHERE user_id='" .$_SESSION['user_id']. "'"); $GLOBALS['smarty']->assign('address_id', $address_id); //收货地址列表 $province_row = get_region_name($province_id); $city_row = get_region_name($city_id); $district_row = get_region_name($district_id); $GLOBALS['smarty']->assign('province_row', $province_row); $GLOBALS['smarty']->assign('city_row', $city_row); $GLOBALS['smarty']->assign('district_row', $district_row); $GLOBALS['smarty']->assign('show_warehouse', $GLOBALS['_CFG']['show_warehouse']); //ecmoban模板堂 --zhuo 开启可选仓库 $result['content'] = $GLOBALS['smarty']->fetch('library/goods_delivery_area.lbi'); $result['warehouse_content'] = $GLOBALS['smarty']->fetch('library/goods_warehouse.lbi'); } echo $json->encode($result); //转化对象数组 function get_str_array1($order){ $arr = array(); foreach($order as $key=>$row){ $row = explode("@", $row); $arr[$row[0]] = $row[1]; } $arr = json_encode($arr); $arr = json_decode($arr); return $arr; } //转化数组 function get_str_array2($id){ $arr = array(); foreach($id as $key=>$row){ $row = explode("-", $row); $arr[$row[0]] = $row[1]; } return $arr; } ?>