Example #1
0
function address_to_store()
{
    $_COOKIE['region_3'] = 0;
    //把第三级设置成空
    $_COOKIE['region_4'] = 0;
    //把第四级设置成空
    $address = cookie_to_str();
    //组织地址
    $stockArray = get_address_by_store($address);
    //查询地址对应哪些仓库
    $goodsIds = get_index_goods($stockArray);
    //获取仓库下的所有商品id
    return $goodsIds;
}
Example #2
0
    $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
    include_once 'includes/cls_json.php';
    $json = new JSON();
    $result = array('error' => 0, 'content' => '', 'type' => $rec_type, 'cat_id' => $cat_id);
    $children = get_children($cat_id);
    $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children));
    // 推荐商品
    $smarty->assign('cat_rec_sign', 1);
    $result['content'] = $smarty->fetch('library/recommend_' . $rec_array[$rec_type] . '.lbi');
    die($json->encode($result));
}
/*------------------------------------------------------ */
//-- 判断是否存在缓存,如果存在则调用缓存,反之读取相应内容
/*------------------------------------------------------ */
/* 缓存编号 */
$cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang'] . '-' . implode('', cookie_to_str())));
$tpl = 'index';
if ($_REQUEST['district'] == 1080) {
    //$tpl = 'index2';
}
$cityGoodsIdStr = get_goods_by_address();
//file_put_contents('./'.implode('',cookie_to_str()).'.txt',$cityGoodsIdStr);
if (!$smarty->is_cached($tpl . '.dwt', $cache_id)) {
    assign_template();
    $position = assign_ur_here();
    $smarty->assign('page_title', $position['title']);
    // 页面标题
    $smarty->assign('ur_here', $position['ur_here']);
    // 当前位置
    /* meta information */
    $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords']));
Example #3
0
    $json = new JSON();
    //$goodslist = category_get_goods($children, $brand, $price_min, $price_max, '', $size, $page, $sort, $order, $limit);
    $goodslist = brand_get_goods($brand_id, $cate, $size, $page, $sort, $order, $ext, $limit);
    foreach ($goodslist as $val) {
        $smarty->assign('goods', $val);
        $res[]['info'] = $GLOBALS['smarty']->fetch('library/goods_list_ajax.lbi');
    }
    /*
        if(count($goodslist)>0){
        	$smarty->assign('goods_list', $goodslist);
        	$res[]['info']  = $GLOBALS['smarty']->fetch('library/goods_list_ajax.lbi');
        }*/
    die($json->encode($res));
}
/* 页面的缓存ID */
$cache_id = sprintf('%X', crc32($brand_id . '-' . $display . '-' . $sort . '-' . $order . '-' . $page . '-' . $size . '-' . $_SESSION['user_rank'] . '-' . $_CFG['lang'] . '-' . $cate . '-' . implode('', cookie_to_str())));
if (!$smarty->is_cached('brand.dwt', $cache_id)) {
    $brand_info = get_brand_info($brand_id);
    if (empty($brand_info)) {
        ecs_header("Location: ./\n");
        exit;
    }
    $smarty->assign('data_dir', DATA_DIR);
    $smarty->assign('keywords', htmlspecialchars($brand_info['brand_desc']));
    $smarty->assign('description', htmlspecialchars($brand_info['brand_desc']));
    /* 赋值固定内容 */
    assign_template();
    $position = assign_ur_here($cate, $brand_info['brand_name']);
    $smarty->assign('page_title', $position['title']);
    // 页面标题
    $smarty->assign('ur_here', $position['ur_here']);
Example #4
0
/**
 * 获取商品对应城市下是否有库存
 * @param int $goodId  商品id
 * @param string $attrValue 商品属性组合串
 * @return int $stock 商品库存值
 */
function is_have_stock($goodId, $attrValue = '')
{
    global $db, $ecs;
    $where = " sgs.goods_id=" . intval($goodId);
    $attrValue = trim($attrValue);
    $attrValue = str_replace(',', '|', $attrValue);
    if (!empty($attrValue)) {
        $where .= " AND sgs.goods_attr='" . $attrValue . "'";
    }
    $stock = 0;
    $address = cookie_to_str();
    $stockArray = get_address_by_store($address);
    if (is_array($stockArray)) {
        $sql = "SELECT sgs.store_number,sgs.store_id,sgs.goods_attr FROM " . $ecs->table('store_goods_stock') . " as sgs," . $ecs->table('store_main') . " as sm WHERE " . $where . "  and sm.parent_id in (" . implode(',', $stockArray) . ") and sgs.store_id = sm.store_id";
        $ret = $db->query($sql);
        if ($ret) {
            while ($row = $db->fetchRow($ret)) {
                if (!empty($attrValue) && $row['goods_attr'] == $attrValue && $row['store_number'] > 0) {
                    return $row['store_number'];
                }
                $stock = $stock > $row['store_number'] ? $stock : $row['store_number'];
            }
        }
    }
    return $stock;
}
Example #5
0
    $store_id = intval($_REQUEST['store_id']);
    $level = intval($_REQUEST['type']);
    setcookie('region_' . $level, $store_id);
    $_COOKIE['region_' . $level] = $store_id;
    $_REQUEST[$_REQUEST['datainfo'][$level]] = $store_id;
    for ($i = 1; $i <= 4; $i++) {
        if ($i > $level) {
            setcookie('region_' . $i, 0);
            $_COOKIE['region_' . $i] = 0;
            $_REQUEST[$_REQUEST['datainfo'][$i]] = 0;
        }
    }
}
$tpl = 'stores.dwt';
//当前地址下对应仓库的店铺显示
$address = cookie_to_str();
$keywords = isset($_REQUEST['keywords']) ? trim(addslashes(htmlspecialchars($_REQUEST['keywords']))) : '';
$cache_id = sprintf('%X', crc32($category_id . '-' . implode('', $address) . '-' . date('ymd') . '-' . $keywords));
if (!$smarty->is_cached($tpl, $cache_id)) {
    //店铺分类
    $cats = get_all_category();
    //店铺列表
    $shop_list = get_all_supplier($address);
    //echo "<pre>";
    //print_r($shop_list);
    //推荐分类中的店铺
    $tuijian = get_tuijian_shop($cats['tuijian']);
    /* 模板赋值 */
    assign_template();
    $position = assign_ur_here();
    $smarty->assign('page_title', $position['title']);
Example #6
0
/**
 * 获取商品对应城市下是否有库存
 * @param int $goodId  商品id
 * @param string $attrValue 商品属性组合串
 * @param book  $isapp
 * @return int $stock 商品库存值
 */
function is_have_stock($goodId, $attrValue = '', $isapp = false)
{
    global $db, $ecs;
    $where = " sgs.goods_id=" . intval($goodId);
    //$attrValue = trim($attrValue);
    //$attrValue = str_replace(',','|',$attrValue);
    if (!empty($attrValue)) {
        if (!is_array($attrValue)) {
            $attrValue = str_replace('|', ',', $attrValue);
            $attrids = explode(',', $attrValue);
        } else {
            $attrids = $attrValue;
        }
        $goods_attr_array = sort_goods_attr_id_array($attrids);
        $attrValue = implode("|", $goods_attr_array['sort']);
        $where .= " AND sgs.goods_attr='" . $attrValue . "'";
    }
    $stock = 0;
    $info = array();
    $address = cookie_to_str();
    $stockArray = get_address_by_store($address);
    if (is_array($stockArray)) {
        $sql = "SELECT sgs.store_number,sgs.store_id,sgs.goods_attr,sm.store_name FROM " . $ecs->table('store_goods_stock') . " as sgs," . $ecs->table('store_main') . " as sm WHERE " . $where . "  and sm.parent_id in (" . implode(',', $stockArray) . ") and sgs.store_id = sm.store_id";
        $ret = $db->query($sql);
        if ($ret) {
            while ($row = $db->fetchRow($ret)) {
                if (!empty($attrValue) && $row['goods_attr'] == $attrValue && $row['store_number'] > 0) {
                    if ($isapp) {
                        return array('attr_num' => $row['store_number'], 'c_name' => $row['store_name']);
                    } else {
                        return $row['store_number'];
                    }
                }
                $stock = $stock > $row['store_number'] ? $stock : $row['store_number'];
                if ($isapp) {
                    $info = array('attr_num' => $stock, 'c_name' => $row['store_name']);
                }
            }
        }
    }
    return $isapp ? $info : $stock;
}
Example #7
0
    foreach ($goodslist as $val) {
        $smarty->assign('goods', $val);
        $res[]['info'] = $GLOBALS['smarty']->fetch('library/goods_list_ajax.lbi');
    }
    /*
        if(count($goodslist)>0){
        	$smarty->assign('goods_list', $goodslist);
        	$res[]['info']  = $GLOBALS['smarty']->fetch('library/goods_list_ajax.lbi');
        }*/
    die($json->encode($res));
}
/*------------------------------------------------------ */
//-- PROCESSOR
/*------------------------------------------------------ */
/* 页面的缓存ID */
$cache_id = sprintf('%X', crc32($cat_id . '-' . $display . '-' . $sort . '-' . $order . '-' . $page . '-' . $size . '-' . $_SESSION['user_rank'] . '-' . $other_has . '-' . $_CFG['lang'] . '-' . $brand . '-' . $price_max . '-' . $price_min . '-' . $filter_attr_str . '-' . $filter . '-' . $mystock . '-' . implode('', cookie_to_str())));
//morestock_morecity
if (!$smarty->is_cached('category.dwt', $cache_id)) {
    /* 如果页面没有被缓存则重新获取页面的内容 */
    $children = get_children($cat_id);
    $cat = get_cat_info($cat_id);
    // 获得分类的相关信息
    if (!empty($cat)) {
        $smarty->assign('keywords', htmlspecialchars($cat['keywords']));
        $smarty->assign('description', htmlspecialchars($cat['cat_desc']));
        $smarty->assign('cat_style', htmlspecialchars($cat['style']));
        $smarty->assign('catname', htmlspecialchars($cat['cat_name']));
    } else {
        /* 如果分类不存在则返回首页 */
        ecs_header("Location: ./\n");
        exit;
Example #8
0
/**
* 根据城市来获取商品有哪些
*/
function get_goods_by_address()
{
    global $db, $ecs;
    $address = cookie_to_str();
    $stockArray = get_address_by_store($address);
    if (is_array($stockArray)) {
        $sql = "select DISTINCT(s.goods_id) from " . $ecs->table('store_goods_stock') . " AS s left join " . $ecs->table('store_main') . " AS m on s.store_id=m.store_id where m.parent_id in (" . implode(',', $stockArray) . ") and s.store_number>0 ";
        $goods_list_s = $db->getColCached($sql);
        file_put_contents('./777' . implode(',', $stockArray) . '.txt', $sql);
        if ($goods_list_s) {
            return db_create_in($goods_list_s, 'g.goods_id');
        }
    }
    return false;
}
Example #9
0
/**
* 获取当前地址的信息内容
*/
function get_select_address_name()
{
    global $db, $ecs;
    $address = cookie_to_str();
    $address = array_filter($address);
    unset($address['province']);
    if (empty($address)) {
        return '区域';
    }
    $sql = "select region_name from " . $ecs->table('region') . " where region_id in(" . implode(',', $address) . ") order by region_id ";
    $ret = '';
    $region_names = $db->getAll($sql);
    $count = count($region_names) - 1;
    foreach ($region_names as $key => $val) {
        if ($key == $count || $key == $count - 1) {
            $ret .= $val['region_name'] . " ";
        }
    }
    return trim($ret, " ");
}