function action_view() { $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; /* 取得参数:预售活动id */ $pre_sale_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($pre_sale_id <= 0) { ecs_header("Location: pre_sale.php\n"); exit; } /* 取得预售活动信息 */ $pre_sale = pre_sale_info($pre_sale_id); if (empty($pre_sale)) { ecs_header("Location: pre_sale.php\n"); exit; } // elseif ($pre_sale['is_on_sale'] == 0 || $pre_sale['is_alone_sale'] == 0) // { // header("Location: ./\n"); // exit; // } /* 评价数量 */ $pre_sale['comment_count'] = goods_comment_count($pre_sale['goods_id']); /* 累计销量 */ $pre_sale['sale_count'] = goods_sale_count($pre_sale['goods_id']); /* 赠送积分 */ $pre_sale['give_integral'] = $pre_sale['gift_integral']; /* 缓存id:语言,预售活动id,状态,(如果是进行中)当前数量和是否登录 */ $cache_id = $_CFG['lang'] . '-' . $pre_sale_id . '-' . $pre_sale['status']; // 活动进行中 if ($pre_sale['status'] == PSS_UNDER_WAY) { $cache_id = $cache_id . '-' . $pre_sale['valid_goods'] . '-' . intval($_SESSION['user_id'] > 0); } $cache_id = sprintf('%X', crc32($cache_id)); /* 如果没有缓存,生成缓存 */ if (!$smarty->is_cached('pre_sale_goods.dwt', $cache_id) || true) { $pre_sale['gmt_end_date'] = $pre_sale['end_date']; $smarty->assign('pre_sale', $pre_sale); /* 取得预售商品信息 */ $goods_id = $pre_sale['goods_id']; $goods = get_goods_info($goods_id); if (empty($goods)) { ecs_header("Location: pre_sale.php\n"); exit; } $goods['url'] = build_uri('goods', array('gid' => $goods_id), $goods['goods_name']); $goods = array_merge($goods, $pre_sale); $gift_integral = $pre_sale['gift_integral']; $goods['give_integral'] = $pre_sale['gift_integral']; // $parent_cat_id = get_parent_cat_id($goods['cat_id']); // $goods['child_cat'] = get_child_cat($parent_cat_id); // 相关分类 // $goods['get_cat_brands'] = get_cat_brands($parent_cat_id);; // 同类品牌 $smarty->assign('url', $_SERVER["REQUEST_URI"]); $smarty->assign('volume_price', $goods_volume_price); $smarty->assign('goods_id', $goods['goods_id']); $smarty->assign('promote_end_time', $goods['gmt_end_time']); $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $smarty->assign('promotion_info', get_promotion_info()); // yyy添加start $count1 = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " where comment_type=0 and id_value ='{$goods_id}' and status=1"); $smarty->assign('review_count', $count1); // 评论数 // 评价晒单 增加 by www.68ecshop.com $rank_num['rank_a'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank in (5,4)"); $rank_num['rank_b'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank in (3,2)"); $rank_num['rank_c'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND comment_rank = 1"); $rank_num['rank_total'] = $rank_num['rank_a'] + $rank_num['rank_b'] + $rank_num['rank_c']; $rank_num['rank_pa'] = $rank_num['rank_a'] > 0 ? round($rank_num['rank_a'] / $rank_num['rank_total'] * 100, 1) : 0; $rank_num['rank_pb'] = $rank_num['rank_b'] > 0 ? round($rank_num['rank_b'] / $rank_num['rank_total'] * 100, 1) : 0; $rank_num['rank_pc'] = $rank_num['rank_c'] > 0 ? round($rank_num['rank_c'] / $rank_num['rank_total'] * 100, 1) : 0; $rank_num['shaidan_num'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('shaidan') . " WHERE goods_id = '{$goods_id}' AND status = 1"); $smarty->assign('rank_num', $rank_num); $res = $GLOBALS['db']->getAll("SELECT * FROM " . $GLOBALS['ecs']->table('goods_tag') . " WHERE goods_id = '{$goods_id}' AND state = 1"); foreach ($res as $v) { $v['tag_num'] = $GLOBALS['db']->getOne("SELECT COUNT(*) AS num FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND status = 1 AND FIND_IN_SET({$v['tag_id']},comment_tag)"); $tag_arr[] = $v; } require_once 'includes/lib_comment.php'; $tag_arr = array_sort($tag_arr, 'tag_num', 'desc'); if ($tag_arr) { foreach ($tag_arr as $key => $val) { if ($_CFG['tag_show_num'] > 0) { if ($key + 1 <= $_CFG['tag_show_num']) { $comment_tags[] = $val; } } else { $comment_tags[] = $val; } } } $smarty->assign('comment_tags', $comment_tags); /* meta */ $smarty->assign('keywords', htmlspecialchars($goods['keywords'])); $smarty->assign('description', htmlspecialchars($goods['goods_brief'])); $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']); $smarty->assign('goods', $goods); $smarty->assign('goods_id', $goods['goods_id']); /* 取得商品的规格 */ $properties = get_goods_properties($goods_id); $smarty->assign('specification', $properties['spe']); // 商品规格 $smarty->assign('pictures', get_goods_gallery_attr_2($goods_id, $goods_attr_id)); // 商品相册 $smarty->assign('new_goods', get_recommend_goods('new')); // 最新商品 $smarty->assign('shop_country', $_CFG['shop_country']); /* 代码增加_start By www.ecshop68.com */ $sql_attr = "SELECT a.attr_id, ga.goods_attr_id FROM " . $GLOBALS['ecs']->table('attribute') . " AS a left join " . $GLOBALS['ecs']->table('goods_attr') . " AS ga on a.attr_id=ga.attr_id WHERE a.is_attr_gallery=1 and ga.goods_id='" . $goods_id . "' order by ga.goods_attr_id "; $goods_attr = $GLOBALS['db']->getRow($sql_attr); if ($goods_attr) { $goods_attr_id = $goods_attr['goods_attr_id']; $smarty->assign('attr_id', $goods_attr['attr_id']); } else { $smarty->assign('attr_id', 0); } $prod_exist_arr = array(); $sql_prod = "select goods_attr from " . $GLOBALS['ecs']->table('products') . " where product_number>0 and goods_id='{$goods_id}' order by goods_attr"; $res_prod = $GLOBALS['db']->query($sql_prod); while ($row_prod = $GLOBALS['db']->fetchRow($res_prod)) { $prod_exist_arr[] = "|" . $row_prod['goods_attr'] . "|"; } $smarty->assign('prod_exist_arr', $prod_exist_arr); // 模板赋值 $smarty->assign('cfg', $_CFG); assign_template(); $position = assign_ur_here(0, $goods['goods_name']); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 /* 代码增加_start By www.68ecshop.com */ $goods['supplier_name'] = "网站自营"; if ($goods['supplier_id'] > 0) { $sql_supplier = "SELECT s.supplier_id,s.supplier_name,s.add_time,sr.rank_name FROM " . $ecs->table("supplier") . " as s left join " . $ecs->table("supplier_rank") . " as sr ON s.rank_id=sr.rank_id WHERE s.supplier_id=" . $goods[supplier_id] . " AND s.status=1"; $shopuserinfo = $db->getRow($sql_supplier); $goods['supplier_name'] = $shopuserinfo['supplier_name']; get_dianpu_baseinfo($goods['supplier_id'], $shopuserinfo); } assign_dynamic('pre_sale_goods'); } // 更新商品点击次数 $sql = 'UPDATE ' . $GLOBALS['ecs']->table('goods') . ' SET click_count = click_count + 1 ' . "WHERE goods_id = '" . $pre_sale['goods_id'] . "'"; $GLOBALS['db']->query($sql); $smarty->assign('now_time', gmtime()); // 当前系统时间 $smarty->display('pre_sale_goods.dwt', $cache_id); }
$goods = get_goods_info($goods_id); if ($goods === false) { /* 如果没有找到任何记录则跳回到首页 */ ecs_header("Location: ./\n"); exit; } else { if ($goods['brand_id'] > 0) { $goods['goods_brand_url'] = build_uri('brand', array('bid' => $goods['brand_id']), $goods['goods_brand']); } /* 代码增加_start By www.68ecshop.com */ $goods['supplier_name'] = "网站自营"; if ($goods['supplier_id'] > 0) { $sql_supplier = "SELECT s.supplier_id,s.supplier_name,s.add_time,sr.rank_name FROM " . $ecs->table("supplier") . " as s left join " . $ecs->table("supplier_rank") . " as sr ON s.rank_id=sr.rank_id\n WHERE s.supplier_id=" . $goods[supplier_id] . " AND s.status=1"; $shopuserinfo = $db->getRow($sql_supplier); $goods['supplier_name'] = $shopuserinfo['supplier_name']; get_dianpu_baseinfo($goods['supplier_id'], $shopuserinfo); } /* 代码增加_end By www.68ecshop.com */ $shop_price = $goods['shop_price']; $linked_goods = get_linked_goods($goods_id); $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']); /* 购买该商品可以得到多少钱的红包 */ if ($goods['bonus_type_id'] > 0) { $time = gmtime(); $sql = "SELECT type_money FROM " . $ecs->table('bonus_type') . " WHERE type_id = '{$goods['bonus_type_id']}' " . " AND send_type = '" . SEND_BY_GOODS . "' " . " AND send_start_date <= '{$time}'" . " AND send_end_date >= '{$time}'"; $goods['bonus_money'] = floatval($db->getOne($sql)); if ($goods['bonus_money'] > 0) { $goods['bonus_money'] = price_format($goods['bonus_money']); } } /* 检查是否已经存在于用户的收藏夹 */
function action_chat() { $user_id = $_SESSION['user_id']; $smarty = get_smarty(); $ecs = get_ecs(); $db = get_database(); /** * 判断当前用户是为聊天系统的注册用户 */ $exist = check_of_username_exist($user_id); // 获取用户头像 if (!empty($user_id)) { $sql = "select password, headimg from " . $ecs->table('users') . " where user_id = '{$user_id}'"; $row = $db->getRow($sql); $headimg = $row['headimg']; $password = $row['password']; $smarty->assign('headimg', $headimg); } if (!$exist) { // 查询ECShop内用户信息 $sql = 'select a.user_id, a.password, a.email, a.user_name from ' . $ecs->table('users') . ' AS a where a.user_id = "' . $user_id . '"'; $user = $GLOBALS['db']->getRow($sql); if (empty($user)) { // 根据user_id未查找到任何用户信息 } // 用户不存在,创建用户信息 $username = $user_id; $password = $user['password']; $name = $user['user_name']; $email = $user['email']; $type = 10; $shop_id = -1; $result = create_of_user($username, $password, $name, $email, $type, $shop_id); if ($result) { // 创建成功 } else { // 创建失败 } } // 获取前端传来的商品编号、订单编号、店铺编号等 // 商品编号则显示商品信息 // 订单编号则显示订单信息 // 店铺编号则显示店铺信息 $goods_id = null; $supp_id = -1; $order_id = null; $customers = null; // 获取客服信息 $tab_items = array(); // 客服类型 $cus_types = CUSTOMER_SERVICE; // 记录需要发给客服的URL if (!empty($_REQUEST['chat_goods_id'])) { /* 咨询商品信息 */ $goods_id = $_REQUEST['chat_goods_id']; $goods = goods_info($goods_id); $smarty->assign('chat_goods', $goods); $smarty->assign('chat_goods_id', $goods_id); // 获取店铺信息 $supp_id = null; $tab_items[] = array("id" => "chat_goods", "name" => "咨询商品"); // 客服+售前 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE; } if (!empty($_REQUEST['chat_supp_id'])) { /* 店铺信息 */ $supp_id = $_REQUEST['chat_supp_id']; $supp_info = get_dianpu_baseinfo($supp_id); $smarty->assign('supp_info', $supp_info); $smarty->assign('chat_supp_id', $supp_id); $tab_items[] = array("id" => "chat_supp", "name" => "店铺信息"); // 客服+售前 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE; } if (!empty($_REQUEST['chat_order_id'])) { /* 咨询订单信息 */ require 'includes/lib_order.php'; $order_id = $_REQUEST['chat_order_id']; // 获取商品和店铺信息 $goods_id = null; $supp_id = null; $order = order_info($order_id); $order['order_status_text'] = $GLOBALS['_LANG']['os'][$order['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$order['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$order['shipping_status']]; $order['goods_list'] = order_goods($order_id); $smarty->assign('chat_order', $order); $smarty->assign('chat_order_id', $order_id); $smarty->assign('chat_order_sn', $order['order_sn']); $tab_items[] = array("id" => "chat_order", "name" => "咨询订单"); // 客服+售后 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_AFTER; } if (true) { /* 最近订单列表 */ require 'includes/lib_transaction_1.php'; // 获取用户最近的5条订单列表 $order_list = get_user_orders_1($user_id, 5, 0); // 所有客服忙碌状态,提示web端 $smarty->assign('order_list', $order_list); $smarty->assign('order_count', count($order_list)); $tab_items[] = array("id" => "chat_order_list", "name" => "最近订单"); // 客服 $cus_types = CUSTOMER_SERVICE; } // 获取客服信息 $customers = get_customers($cus_types, $supp_id); // 转换为JSON数据 $smarty->assign('tab_items', json_encode($tab_items)); $to = null; // 客服获取策略:0-顺序、1-随机、2-竞争 if (!empty($customers)) { // 暂时采用随机策略 $poliy = 1; if ($poliy == 0) { foreach ($customers as $customer) { $status = $customer['status']; if ($status == '在线' || $status == '空闲') { $to = $customer; break; // if(isset($customer['cus_status']) && count($customers) > 1) // { // if(time() - $customer['chat_time'] > 5*60) // { // set_customer_status($customer['cus_id'], 0); // $customer['cus_status'] = 0; // } // if($customer['cus_status'] == 0) // { // $to = $customer; // break; // } // } // else // { // $to = $customer; // break; // } } } } else { if ($poliy == 1) { /* 随进策略 */ $onlines = array(); foreach ($customers as $customer) { $status = $customer['status']; if ($status == '在线' || $status == '空闲') { $onlines[] = $customer; } } if (count($onlines) > 0) { $min = 1; $max = count($onlines); $i = mt_rand($min, $max); $to = $onlines[$i - 1]; } } else { } } if (empty($to)) { if ($supp_id == -1) { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!'); } else { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前店铺客服忙碌,请稍后联系!'); } } else { $xmpp_domain = get_xmpp_domain(); $_SESSION['OF_FROM'] = $user_id . '@' . $xmpp_domain; $_SESSION['OF_TO'] = $to['of_username'] . '@' . $xmpp_domain; $smarty->assign('from', $_SESSION['OF_FROM']); $smarty->assign('password', $password); // $smarty->assign('password', "123456"); $smarty->assign('to', '==to=='); $smarty->assign('username', $_SESSION['user_name']); $smarty->assign('customername', $to['cus_name']); // 存储在Session中方便其他地方使用 // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '客服<span class="kf_name">' . $to['cus_name'] . '</span>已加入会话!'); } } else { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!'); } // 打开聊天页面 $smarty->display('chat.dwt'); }