本文整理汇总了PHP中get_final_price函数的典型用法代码示例。如果您正苦于以下问题:PHP get_final_price函数的具体用法?PHP get_final_price怎么用?PHP get_final_price使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_final_price函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update_cart
/**
* 更新购物车中的商品
*/
function update_cart()
{
global $ecs, $db;
//删除已下架商品
$sql = "DELETE c FROM " . $ecs->table('cart', 'c') . " WHERE " . get_cart_cond('c.') . " AND NOT EXISTS (SELECT 1 FROM " . $ecs->table('goods', 'g') . " WHERE g.goods_id = c.goods_id AND g.is_on_sale = 1 AND g.is_delete = 0) " . " AND c.extension_code <> 'flash_sale' AND c.rec_type = " . CART_GENERAL_GOODS;
$db->query($sql);
//删除已过期限时抢购
$now = time();
$sql = "DELETE c FROM " . $ecs->table('cart', 'c') . " WHERE " . get_cart_cond('c.') . " AND NOT EXISTS (SELECT 1 FROM " . $ecs->table('flash_sale', 'f') . " WHERE f.id = c.extension_id AND f.is_on_sale = 1 AND f.start_time <= {$now} AND f.end_time > {$now}) " . " AND c.extension_code = 'flash_sale' AND c.rec_type = " . CART_GENERAL_GOODS;
$db->query($sql);
//限时抢购商品限购数量检查
check_cartgoods_number(true);
//更新产品价格、规格等
$sql = "SELECT c.rec_id, c.goods_id, c.goods_number, c.goods_attr_id, g.goods_name, g.market_price, g.shop_price, g.amount_desc, g.free_more FROM " . $ecs->table('cart', 'c') . ',' . $ecs->table('goods', 'g') . " WHERE c.goods_id = g.goods_id AND c.extension_code <> 'flash_sale' AND " . get_cart_cond('c.');
$query = $db->query($sql);
while ($rs = $db->fetch_array($query)) {
$spec = explode(',', $rs['goods_attr_id']);
$goods_attr = get_goods_attr_info($spec);
if (empty($goods_attr)) {
$goods_attr = $rs['amount_desc'];
} else {
$goods_attr = $rs['amount_desc'] . "\n" . $goods_attr;
}
$cart = array('goods_name' => $rs['goods_name'], 'market_price' => $rs['market_price'], 'goods_price' => get_final_price($rs['goods_id'], $rs['goods_number'], true, $spec), 'goods_attr' => $goods_attr, 'free_more' => $rs['free_more']);
$db->autoExecute($ecs->table('cart'), $cart, 'UPDATE', 'rec_id=' . $rs['rec_id']);
}
}
开发者ID:GYWang1983,项目名称:fruit,代码行数:30,代码来源:lib_order.php
示例2: JSON
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'price') {
include 'includes/cls_json.php';
$json = new JSON();
$res = array('err_msg' => '', 'result' => '', 'qty' => 1);
$attr_id = isset($_REQUEST['attr']) ? explode(',', $_REQUEST['attr']) : array();
$number = isset($_REQUEST['number']) ? intval($_REQUEST['number']) : 1;
if ($goods_id == 0) {
$res['err_msg'] = $_LANG['err_change_attr'];
$res['err_no'] = 1;
} else {
if ($number == 0) {
$res['qty'] = $number = 1;
} else {
$res['qty'] = $number;
}
$shop_price = get_final_price($goods_id, $number, true, $attr_id);
$res['result'] = price_format($shop_price * $number);
}
die($json->encode($res));
}
/* 修改 start by zhouH*/
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'getGoodsInfo') {
include 'includes/cls_json.php';
$json = new JSON();
$res = array('err_msg' => '', 'result' => '', 'goods_img' => '');
$goods_id = $_REQUEST['id'];
if (!empty($goods_id)) {
/* 获得商品的信息 */
$goods = get_goods_info($goods_id);
$res['result'] = $goods;
$res['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($goods['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $goods['goods_name'];
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:31,代码来源:goods.php
示例3: flow_update_cart
/**
* 更新购物车中的商品数量
*
* @access public
* @param array $arr
* @return void
*/
function flow_update_cart($arr)
{
/* 处理 */
foreach ($arr as $key => $val) {
$val = intval(make_semiangle($val));
if ($val <= 0 && !is_numeric($key)) {
continue;
}
//查询:
$sql = "SELECT `goods_id`, `goods_attr_id`, `product_id`, `extension_code` FROM" . $GLOBALS['ecs']->table('cart') . " WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
$goods = $GLOBALS['db']->getRow($sql);
$sql = "SELECT g.goods_name, g.goods_number " . "FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('cart') . " AS c " . "WHERE g.goods_id = c.goods_id AND c.rec_id = '{$key}'";
$row = $GLOBALS['db']->getRow($sql);
//查询:系统启用了库存,检查输入的商品数量是否有效
if (intval($GLOBALS['_CFG']['use_storage']) > 0 && $goods['extension_code'] != 'package_buy') {
if ($row['goods_number'] < $val) {
show_message(sprintf($GLOBALS['_LANG']['stock_insufficiency'], $row['goods_name'], $row['goods_number'], $row['goods_number']));
exit;
}
/* 是货品 */
$goods['product_id'] = trim($goods['product_id']);
if (!empty($goods['product_id'])) {
$sql = "SELECT product_number FROM " . $GLOBALS['ecs']->table('products') . " WHERE goods_id = '" . $goods['goods_id'] . "' AND product_id = '" . $goods['product_id'] . "'";
$product_number = $GLOBALS['db']->getOne($sql);
if ($product_number < $val) {
show_message(sprintf($GLOBALS['_LANG']['stock_insufficiency'], $row['goods_name'], $product_number['product_number'], $product_number['product_number']));
exit;
}
}
} elseif (intval($GLOBALS['_CFG']['use_storage']) > 0 && $goods['extension_code'] == 'package_buy') {
if (judge_package_stock($goods['goods_id'], $val)) {
show_message($GLOBALS['_LANG']['package_stock_insufficiency']);
exit;
}
}
/* 查询:检查该项是否为基本件 以及是否存在配件 */
/* 此处配件是指添加商品时附加的并且是设置了优惠价格的配件 此类配件都有parent_id goods_number为1 */
$sql = "SELECT b.goods_number, b.rec_id\n FROM " . $GLOBALS['ecs']->table('cart') . " a, " . $GLOBALS['ecs']->table('cart') . " b\n WHERE a.rec_id = '{$key}'\n AND a.session_id = '" . SESS_ID . "'\n AND a.extension_code <> 'package_buy'\n AND b.parent_id = a.goods_id\n AND b.session_id = '" . SESS_ID . "'";
$offers_accessories_res = $GLOBALS['db']->query($sql);
//订货数量大于0
if ($val > 0) {
/* 判断是否为超出数量的优惠价格的配件 删除*/
$row_num = 1;
while ($offers_accessories_row = $GLOBALS['db']->fetchRow($offers_accessories_res)) {
if ($row_num > $val) {
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND rec_id = '" . $offers_accessories_row['rec_id'] . "' LIMIT 1";
$GLOBALS['db']->query($sql);
}
$row_num++;
}
/* 处理超值礼包 */
if ($goods['extension_code'] == 'package_buy') {
//更新购物车中的商品数量
$sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$val}' WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
} else {
$attr_id = empty($goods['goods_attr_id']) ? array() : explode(',', $goods['goods_attr_id']);
$goods_price = get_final_price($goods['goods_id'], $val, true, $attr_id);
//更新购物车中的商品数量
$sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$val}', goods_price = '{$goods_price}' WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
}
} else {
/* 如果是基本件并且有优惠价格的配件则删除优惠价格的配件 */
while ($offers_accessories_row = $GLOBALS['db']->fetchRow($offers_accessories_res)) {
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND rec_id = '" . $offers_accessories_row['rec_id'] . "' LIMIT 1";
$GLOBALS['db']->query($sql);
}
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
}
$GLOBALS['db']->query($sql);
}
/* 删除所有赠品 */
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND is_gift <> 0";
$GLOBALS['db']->query($sql);
}
开发者ID:will0306,项目名称:bianli100,代码行数:81,代码来源:flow.php
示例4: recalculate_price
/**
* 重新计算购物车中的商品价格:目的是当用户登录时享受会员价格,当用户退出登录时不享受会员价格
* 如果商品有促销,价格不变
*
* @access public
* @return void
*/
function recalculate_price()
{
/* 取得有可能改变价格的商品:除配件和赠品之外的商品 */
$sql = 'SELECT c.rec_id, c.goods_id, c.goods_attr_id, g.promote_price, g.promote_start_date, c.goods_number,' . "g.promote_end_date, IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS member_price " . 'FROM ' . $GLOBALS['ecs']->table('cart') . ' AS c ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = c.goods_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' " . "WHERE session_id = '" . SESS_ID . "' AND c.parent_id = 0 AND c.is_gift = 0 AND c.goods_id > 0 " . "AND c.rec_type = '" . CART_GENERAL_GOODS . "' AND c.extension_code <> 'package_buy'";
$res = $GLOBALS['db']->getAll($sql);
foreach ($res as $row) {
$attr_id = empty($row['goods_attr_id']) ? array() : explode(',', $row['goods_attr_id']);
$goods_price = get_final_price($row['goods_id'], $row['goods_number'], true, $attr_id);
$goods_sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_price = '{$goods_price}' " . "WHERE goods_id = '" . $row['goods_id'] . "' AND session_id = '" . SESS_ID . "' AND rec_id = '" . $row['rec_id'] . "'";
$GLOBALS['db']->query($goods_sql);
}
/* 删除赠品,重新选择 */
$GLOBALS['db']->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND is_gift > 0");
}
开发者ID:YangZeSummer,项目名称:NanJingSecond-Hand,代码行数:21,代码来源:lib_main.php
示例5: die
$res['err_no'] = 1;
}
}
die($json->encode($res));
}
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'allprice') {
include 'includes/cls_json.php';
$json = new JSON();
$res = array('err_msg' => '', 'result' => '', 'qty' => 1);
$number = isset($_REQUEST['number']) ? intval($_REQUEST['number']) : 1;
$attr_id = isset($_REQUEST['attr']) ? $_REQUEST['attr'] : array();
if (empty($attr_id)) {
$attr_id = 0;
}
$res['attr_num'] = get_product_attr_num($goods_id, $attr_id);
$min_price = get_final_price($goods_id, $number, true, 0);
$mark_price_min = get_mark_price($goods_id);
$sql = "SELECT *\n\t\t\tFROM " . $ecs->table('goods_attr') . "\n\t\t\tWHERE `goods_id` =" . $goods_id;
$row = $GLOBALS['db']->getAll($sql);
//file_put_contents('./88.txt',var_export($row,true));
if ($row) {
$ret = array();
foreach ($row as $key => $val) {
if ($val['attr_price']) {
$ret[$val['attr_id']][$val['attr_price']] = $val;
}
}
$ret1 = $ret2 = $ret3 = $ret4 = array();
foreach ($ret as $k => $v) {
ksort($v);
$ret2 = end($v);
开发者ID:firsteam,项目名称:falcons,代码行数:31,代码来源:goods.php
示例6: flow_update_cart
function flow_update_cart($arr)
{
foreach ($arr as $key => $val) {
$val = intval(make_semiangle($val));
if ($val <= 0 && !is_numeric($key)) {
continue;
}
$sql = "SELECT `goods_id`, `goods_attr_id`, `product_id`, `extension_code` FROM" . $GLOBALS['ecs']->table('cart') . " WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
$goods = $GLOBALS['db']->getRow($sql);
$sql = "SELECT g.goods_name, g.goods_number " . "FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('cart') . " AS c " . "WHERE g.goods_id = c.goods_id AND c.rec_id = '{$key}'";
$row = $GLOBALS['db']->getRow($sql);
if (intval($GLOBALS['_CFG']['use_storage']) > 0 && $goods['extension_code'] != 'package_buy') {
if ($row['goods_number'] < $val) {
show_message(sprintf($GLOBALS['_LANG']['stock_insufficiency'], $row['goods_name'], $row['goods_number'], $row['goods_number']));
exit;
}
$goods['product_id'] = trim($goods['product_id']);
if (!empty($goods['product_id'])) {
$sql = "SELECT product_number FROM " . $GLOBALS['ecs']->table('products') . " WHERE goods_id = '" . $goods['goods_id'] . "' AND product_id = '" . $goods['product_id'] . "'";
$product_number = $GLOBALS['db']->getOne($sql);
if ($product_number < $val) {
show_message(sprintf($GLOBALS['_LANG']['stock_insufficiency'], $row['goods_name'], $product_number['product_number'], $product_number['product_number']));
exit;
}
}
} elseif (intval($GLOBALS['_CFG']['use_storage']) > 0 && $goods['extension_code'] == 'package_buy') {
if (judge_package_stock($goods['goods_id'], $val)) {
show_message($GLOBALS['_LANG']['package_stock_insufficiency']);
exit;
}
}
$sql = "SELECT b.goods_number, b.rec_id\r\n FROM " . $GLOBALS['ecs']->table('cart') . " a, " . $GLOBALS['ecs']->table('cart') . " b\r\n WHERE a.rec_id = '{$key}'\r\n AND a.session_id = '" . SESS_ID . "'\r\n AND a.extension_code <> 'package_buy'\r\n AND b.parent_id = a.goods_id\r\n AND b.session_id = '" . SESS_ID . "'";
$offers_accessories_res = $GLOBALS['db']->query($sql);
if ($val > 0) {
$row_num = 1;
while ($offers_accessories_row = $GLOBALS['db']->fetchRow($offers_accessories_res)) {
if ($row_num > $val) {
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND rec_id = '" . $offers_accessories_row['rec_id'] . "' LIMIT 1";
$GLOBALS['db']->query($sql);
}
$row_num++;
}
if ($goods['extension_code'] == 'package_buy') {
$sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$val}' WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
} else {
$attr_id = empty($goods['goods_attr_id']) ? array() : explode(',', $goods['goods_attr_id']);
$goods_price = get_final_price($goods['goods_id'], $val, true, $attr_id);
$sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$val}', goods_price = '{$goods_price}' WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
}
} else {
while ($offers_accessories_row = $GLOBALS['db']->fetchRow($offers_accessories_res)) {
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND rec_id = '" . $offers_accessories_row['rec_id'] . "' LIMIT 1";
$GLOBALS['db']->query($sql);
}
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE rec_id='{$key}' AND session_id='" . SESS_ID . "'";
}
$GLOBALS['db']->query($sql);
}
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND is_gift <> 0";
$GLOBALS['db']->query($sql);
}
开发者ID:duynhan07,项目名称:ecshop-vietnam,代码行数:61,代码来源:flow.php
示例7: tongbu_cart_price
function tongbu_cart_price($goods_id)
{
global $db, $ecs;
$sql = "select c.rec_id,c.goods_id,c.goods_attr_id,c.user_id,c.session_id,g.market_price from " . $ecs->table('cart') . " as c left join " . $ecs->table('goods') . " as g on c.goods_id=g.goods_id where c.goods_id=" . $goods_id . " and c.rec_type='" . CART_GENERAL_GOODS . "' AND c.extension_code <> 'package_buy'";
$query = $db->query($sql);
while ($row = $db->fetchRow($query)) {
if ($row['user_id'] > 0) {
//已经有用户的商品
$sql1 = "select u.user_rank,IFNULL(ur.discount,100) as discount from " . $ecs->table('users') . " as u left join " . $ecs->table('user_rank') . " as ur on u.user_rank=ur.rank_id where u.user_id=" . $row['user_id'];
$data = $db->getRow($sql1);
$GLOBALS['tongbu_user_discount'] = $data['discount'] / 100;
$GLOBALS['tongbu_user_rank'] = $data['user_rank'];
} else {
$GLOBALS['tongbu_user_discount'] = 1;
$GLOBALS['tongbu_user_rank'] = 1;
}
$attr_id = empty($row['goods_attr_id']) ? array() : explode(',', $row['goods_attr_id']);
$price = get_final_price($row['goods_id'], 1, true, $attr_id);
$db->query("update " . $ecs->table('cart') . " set market_price='" . $row['market_price'] . "',goods_price='" . $price . "' where rec_id=" . $row['rec_id']);
}
}
开发者ID:moonlight-wang,项目名称:feilun,代码行数:21,代码来源:goods.php
示例8: addto_cart
/**
* 添加商品到购物车
*
* @access public
* @param integer $goods_id 商品编号
* @param integer $num 商品数量
* @param array $spec 规格值对应的id数组
* @param integer $parent 基本件
* @return boolean
*/
function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0)
{
$GLOBALS['err']->clean();
$_parent_id = $parent;
/* 取得商品信息 */
$sql = "SELECT g.goods_name, g.goods_sn, g.is_on_sale, g.is_real, " . "g.market_price, g.cost_price, g.shop_price AS org_price, g.promote_price, g.promote_start_date, " . "g.promote_end_date, g.goods_weight, g.integral, g.extension_code, " . "g.goods_number, g.is_alone_sale, g.is_shipping," . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price " . " FROM " . $GLOBALS['ecs']->table('goods') . " AS g " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE g.goods_id = '{$goods_id}'" . " AND g.is_delete = 0";
$goods = $GLOBALS['db']->getRow($sql);
if (empty($goods)) {
$GLOBALS['err']->add($GLOBALS['_LANG']['goods_not_exists'], ERR_NOT_EXISTS);
return false;
}
/* 如果是作为配件添加到购物车的,需要先检查购物车里面是否已经有基本件 */
if ($parent > 0) {
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('cart') . " WHERE goods_id='{$parent}' AND session_id='" . SESS_ID . "' AND extension_code <> 'package_buy'";
if ($GLOBALS['db']->getOne($sql) == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['no_basic_goods'], ERR_NO_BASIC_GOODS);
return false;
}
}
/* 是否正在销售 */
if ($goods['is_on_sale'] == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['not_on_sale'], ERR_NOT_ON_SALE);
return false;
}
/* 不是配件时检查是否允许单独销售 */
if (empty($parent) && $goods['is_alone_sale'] == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['cannt_alone_sale'], ERR_CANNT_ALONE_SALE);
return false;
}
/* 如果商品有规格则取规格商品信息 配件除外 */
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('products') . " WHERE goods_id = '{$goods_id}' LIMIT 0, 1";
$prod = $GLOBALS['db']->getRow($sql);
if (is_spec($spec) && !empty($prod)) {
$product_info = get_products_info($goods_id, $spec);
}
if (empty($product_info)) {
$product_info = array('product_number' => '', 'product_id' => 0);
}
/* 检查:库存 */
if ($GLOBALS['_CFG']['use_storage'] == 1) {
//检查:商品购买数量是否大于总库存
if ($num > $goods['goods_number']) {
$GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], $goods['goods_number']), ERR_OUT_OF_STOCK);
return false;
}
//商品存在规格 是货品 检查该货品库存
if (is_spec($spec) && !empty($prod)) {
if (!empty($spec)) {
/* 取规格的货品库存 */
if ($num > $product_info['product_number']) {
$GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], $product_info['product_number']), ERR_OUT_OF_STOCK);
return false;
}
}
}
}
/* 计算商品的促销价格 */
$spec_price = spec_price($spec);
$goods_price = get_final_price($goods_id, $num, true, $spec);
$goods['market_price'] += $spec_price;
$goods_attr = get_goods_attr_info($spec);
$goods_attr_id = join(',', $spec);
/* 初始化要插入购物车的基本件数据 */
$parent = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $goods_id, 'goods_sn' => addslashes($goods['goods_sn']), 'product_id' => $product_info['product_id'], 'goods_name' => addslashes($goods['goods_name']), 'market_price' => $goods['market_price'], 'goods_attr' => addslashes($goods_attr), 'goods_attr_id' => $goods_attr_id, 'cost_price' => $goods['cost_price'], 'is_real' => $goods['is_real'], 'extension_code' => $goods['extension_code'], 'is_gift' => 0, 'is_shipping' => $goods['is_shipping'], 'add_time' => gmtime(), 'rec_type' => CART_GENERAL_GOODS);
//初始化为普通商品
$_SESSION['flow_type'] = CART_GENERAL_GOODS;
/* 如果该配件在添加为基本件的配件时,所设置的“配件价格”比原价低,即此配件在价格上提供了优惠, */
/* 则按照该配件的优惠价格卖,但是每一个基本件只能购买一个优惠价格的“该配件”,多买的“该配件”不享 */
/* 受此优惠 */
$basic_list = array();
$sql = "SELECT parent_id, goods_price " . "FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE goods_id = '{$goods_id}'" . " AND goods_price < '{$goods_price}'" . " AND parent_id = '{$_parent_id}'" . " ORDER BY goods_price";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$basic_list[$row['parent_id']] = $row['goods_price'];
}
/* 取得购物车中该商品每个基本件的数量 */
$basic_count_list = array();
if ($basic_list) {
$sql = "SELECT goods_id, SUM(goods_number) AS count " . "FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "'" . " AND parent_id = 0" . " AND extension_code <> 'package_buy' " . " AND goods_id " . db_create_in(array_keys($basic_list)) . " GROUP BY goods_id";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$basic_count_list[$row['goods_id']] = $row['count'];
}
}
/* 取得购物车中该商品每个基本件已有该商品配件数量,计算出每个基本件还能有几个该商品配件 */
/* 一个基本件对应一个该商品配件 */
if ($basic_count_list) {
$sql = "SELECT parent_id, SUM(goods_number) AS count " . "FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "'" . " AND goods_id = '{$goods_id}'" . " AND extension_code <> 'package_buy' " . " AND parent_id " . db_create_in(array_keys($basic_count_list)) . " GROUP BY parent_id";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
//.........这里部分代码省略.........
开发者ID:seanguo166,项目名称:yinoos,代码行数:101,代码来源:lib_order.php
示例9: get_goods_info
/**
* 获得商品的详细信息
*
* @access public
* @param integer $goods_id
* @return void
*/
function get_goods_info($goods_id)
{
$time = gmtime();
$sql = 'SELECT g.*, c.measure_unit, b.brand_id, b.brand_logo, g.comments_number, g.sales_volume,b.brand_name AS goods_brand, m.type_money AS bonus_money, ' . 'IFNULL(AVG(r.comment_rank), 0) AS comment_rank, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS rank_price " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON g.cat_id = c.cat_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON g.brand_id = b.brand_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('comment') . ' AS r ' . 'ON r.id_value = g.goods_id AND comment_type = 0 AND r.parent_id = 0 AND r.status = 1 ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('bonus_type') . ' AS m ' . "ON g.bonus_type_id = m.type_id AND m.send_start_date <= '{$time}' AND m.send_end_date >= '{$time}'" . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.goods_id = '{$goods_id}' AND g.is_delete = 0 " . "GROUP BY g.goods_id";
$row = $GLOBALS['db']->getRow($sql);
/*add by hg for date 2014-04-24 获取实际库存*/
/* if($row['host_goods_id']){
$row['goods_number'] = host_number($row['host_goods_id']);
} 作用暂时不需要*/
/*end*/
if ($row !== false) {
/* 用户评论级别取整 */
$row['comment_rank'] = ceil($row['comment_rank']) == 0 ? 5 : ceil($row['comment_rank']);
/* 折扣节省计算 by ecmoban start */
if ($row['market_price'] > 0) {
$discount_arr = get_discount($row['goods_id']);
//函数get_discount参数goods_id
}
$row['zhekou'] = $discount_arr['discount'];
//zhekou
$row['jiesheng'] = $discount_arr['jiesheng'];
//jiesheng
/* 折扣节省计算 by ecmoban end */
/* 获得商品的销售价格 */
$row['market_price'] = price_format($row['market_price'], true, true);
//$row['shop_price_formated'] = price_format($row['shop_price']);
$row['shop_price_formated'] = price_format(get_final_price($goods_id));
/* 修正促销价格 */
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
} else {
$promote_price = 0;
}
/* 处理商品水印图片 */
$watermark_img = '';
if ($promote_price != 0) {
$watermark_img = "watermark_promote";
} elseif ($row['is_new'] != 0) {
$watermark_img = "watermark_new";
} elseif ($row['is_best'] != 0) {
$watermark_img = "watermark_best";
} elseif ($row['is_hot'] != 0) {
$watermark_img = 'watermark_hot';
}
if ($watermark_img != '') {
$row['watermark_img'] = $watermark_img;
}
$row['promote_price_org'] = $promote_price;
$row['promote_price'] = price_format($promote_price);
/* 修正重量显示 */
$row['goods_weight'] = intval($row['goods_weight']) > 0 ? $row['goods_weight'] . $GLOBALS['_LANG']['kilogram'] : $row['goods_weight'] * 1000 . $GLOBALS['_LANG']['gram'];
/* 修正上架时间显示 */
$row['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
/* 促销时间倒计时 */
$time = gmtime();
if ($time >= $row['promote_start_date'] && $time <= $row['promote_end_date']) {
$row['gmt_end_time'] = $row['promote_end_date'];
} else {
$row['gmt_end_time'] = 0;
}
/* 是否显示商品库存数量 */
$row['goods_number'] = $GLOBALS['_CFG']['use_storage'] == 1 ? $row['goods_number'] : '';
/* 修正积分:转换为可使用多少积分(原来是可以使用多少钱的积分) */
$row['integral'] = $GLOBALS['_CFG']['integral_scale'] ? round($row['integral'] * 100 / $GLOBALS['_CFG']['integral_scale']) : 0;
/* 修正优惠券 */
$row['bonus_money'] = $row['bonus_money'] == 0 ? 0 : price_format($row['bonus_money'], false);
/* 修正商品图片 */
$row['goods_img'] = get_image_path($goods_id, $row['goods_img']);
$row['goods_thumb'] = get_image_path($goods_id, $row['goods_thumb'], true);
return $row;
} else {
return false;
}
}
开发者ID:dlpc,项目名称:ecshop,代码行数:81,代码来源:lib_goods.php
示例10: get_goods_by_txm
/**
* 根据条形码获取对应商品信息
* @param array $info 条形码数组信息
*/
function get_goods_by_txm($info)
{
global $db, $ecs;
$sql = "select bc.*,g.* from " . $ecs->table('bar_code') . " as bc left join " . $ecs->table('goods') . " as g on bc.goods_id=g.goods_id where bc.bar_code in(" . implode(',', $info) . ")";
$ret = $db->query($sql);
$goodsinfo = array();
while ($row = $db->fetchRow($ret)) {
$attr_info = get_goods_attr_txm($row['goods_id'], $row['taypes']);
//获取商品属性信息
if (empty($attr_info['info'])) {
$goods_number = $row['goods_number'];
$attr_ids = '';
$row['goods_attr'] = $row['goods_attr_id'] = $row['goods_attr_price'] = '';
} else {
$attr_ids = array_keys($attr_info['info']);
$attr_ids = sort_goods_attr_id_array($attr_ids);
//商品属性id排序
$row['goods_attr_id'] = implode(',', $attr_ids['sort']);
$row['goods_attr'] = $attr_info['info'];
$row['goods_attr_price'] = is_array($attr_info['price']) ? array_sum($attr_info['price']) : 0;
$goods_number = get_goods_nums_txm($row['goods_id'], $attr_ids['sort']);
//货品总数量
}
$goodsinfo[$row['bar_code']]['goods_id'] = $row['goods_id'];
$goodsinfo[$row['bar_code']]['goods_name'] = $row['goods_name'];
$goodsinfo[$row['bar_code']]['goods_sn'] = $row['goods_sn'];
$goodsinfo[$row['bar_code']]['product_id'] = '';
$goodsinfo[$row['bar_code']]['goods_name'] = $row['goods_name'];
$goodsinfo[$row['bar_code']]['market_price'] = $row['market_price'] + $row['goods_attr_price'];
$goodsinfo[$row['bar_code']]['goods_price'] = get_final_price($row['goods_id'], 1, true, $attr_ids['sort']);
//最终结算价格
$goodsinfo[$row['bar_code']]['goods_number'] = intval($goods_number);
$goodsinfo[$row['bar_code']]['goods_attr'] = $row['goods_attr'];
$goodsinfo[$row['bar_code']]['goods_attr_id'] = $row['goods_attr_id'];
$goodsinfo[$row['bar_code']]['goods_attr_price'] = $row['goods_attr_price'];
$goodsinfo[$row['bar_code']]['goods_thumb'] = $row['goods_thumb'];
$goodsinfo[$row['bar_code']]['goods_img'] = $row['goods_img'];
}
return $goodsinfo;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:44,代码来源:lib_goods.php
示例11: recalculate_price
/**
* 重新计算购物车中的商品价格:目的是当用户登录时享受会员价格,当用户退出登录时不享受会员价格
* 如果商品有促销,价格不变
*
* @access public
* @return void
*/
function recalculate_price()
{
/* 取得有可能改变价格的商品:除配件和赠品之外的商品 */
$sql = 'SELECT c.rec_id, c.goods_id, c.goods_attr_id, g.promote_price, g.promote_start_date, c.goods_number,' . "g.promote_end_date, IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS member_price " . 'FROM ' . $GLOBALS['ecs']->table('cart') . ' AS c ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = c.goods_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' " . "WHERE session_id = '" . SESS_ID . "' AND c.parent_id = 0 AND c.is_gift = 0 AND c.goods_id > 0 " . "AND c.rec_type = '" . CART_GENERAL_GOODS . "' AND c.extension_code <> 'package_buy'";
$res = $GLOBALS['db']->getAll($sql);
foreach ($res as $row) {
$attr_id = empty($row['goods_attr_id']) ? array() : explode(',', $row['goods_attr_id']);
$goods_price = get_final_price($row['goods_id'], $row['goods_number'], true, $attr_id);
$goods_sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_price = '{$goods_price}' " . "WHERE goods_id = '" . $row['goods_id'] . "' AND session_id = '" . SESS_ID . "' AND rec_id = '" . $row['rec_id'] . "'";
$GLOBALS['db']->query($goods_sql);
}
/* 代码增加_start By www.68ecshop.com */
$time1 = local_strtotime('today');
$time2 = local_strtotime('today') + 86400;
$sql = "select rec_id,goods_id,goods_attr,goods_number " . " from " . $GLOBALS['ecs']->table('cart') . " where user_id=0 " . " AND session_id = '" . SESS_ID . "' AND parent_id = 0 " . " AND is_gift = 0 AND goods_id > 0 " . "AND rec_type = '" . CART_GENERAL_GOODS . "' AND extension_code <> 'package_buy' ";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$sql = "select rec_id from " . $GLOBALS['ecs']->table('cart') . " where user_id='" . $_SESSION['user_id'] . "' " . " AND add_time >='{$time1}' and add_time<'{$time2}' " . " AND goods_id='{$row['goods_id']}' and goods_attr= '{$row['goods_attr']}' ";
$rec_id = $GLOBALS['db']->getOne($sql);
if ($rec_id) {
$sql = "update " . $GLOBALS['ecs']->table('cart') . " set goods_number= goods_number + " . $row['goods_number'] . " where rec_id='{$rec_id}' ";
$GLOBALS['db']->query($sql);
$sql = "delete from " . $GLOBALS['ecs']->table('cart') . " where rec_id='" . $row['rec_id'] . "'";
$GLOBALS['db']->query($sql);
} else {
$sql = "update " . $GLOBALS['ecs']->table('cart') . " set user_id='{$_SESSION['user_id']}' " . " where rec_id='" . $row['rec_id'] . "'";
$GLOBALS['db']->query($sql);
}
}
/* 代码增加_end By www.68ecshop.com */
/* 删除赠品,重新选择 */
$GLOBALS['db']->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND is_gift > 0");
}
开发者ID:firsteam,项目名称:falcons,代码行数:40,代码来源:lib_main.php
示例12: get_discount
function get_discount($goods_id)
{
/*$sql = 'SELECT market_price,shop_price,promote_price FROM '.$GLOBALS['ecs']->table('goods')." WHERE goods_id = $goods_id ";
$row = $GLOBALS['db']->getRow($sql);
$price=$row['market_price']; //原价
if($row['promote_price'] > 0) //如果促销价大于0则现价为促销价
{
$nowprice=$row['promote_price']; //现价
}
else //否则为本店价
{
$nowprice=$row['shop_price']; //现价
}
$jiesheng=$price-$nowprice; //节省金额
*/
$final_price = get_final_price($goods_id);
$sql = 'SELECT market_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = {$goods_id} ";
$market_price = $GLOBALS['db']->getOne($sql);
$jiesheng = $market_price - $final_price;
//节省金额
$arr['jiesheng'] = $jiesheng;
//$discount折扣计算
if ($final_price > 0) {
$arr['discount'] = round(10 * ($final_price / $market_price), 1);
} else {
$arr['discount'] = 0;
}
if ($arr['discount'] <= 0) {
$arr['discount'] = 0;
}
return $arr;
}
开发者ID:dlpc,项目名称:ecshop,代码行数:36,代码来源:lib_ecmoban.php
示例13: addto_cart
/**
* 添加商品到购物车
*
* @access public
* @param integer $goods_id 商品编号
* @param integer $num 商品数量
* @param array $spec 规格
* @param integer $parent 基本件
* @return boolean
*/
function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0)
{
$GLOBALS['err']->clean();
/* 取得商品信息 */
$sql = "SELECT g.goods_name, g.goods_sn, g.is_on_sale, g.is_real, " . "g.market_price, g.shop_price AS org_price, g.promote_price, g.promote_start_date, " . "g.promote_end_date, g.goods_weight, g.integral, g.extension_code, " . "g.goods_number, g.is_alone_sale, " . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price " . " FROM " . $GLOBALS['ecs']->table('goods') . " AS g " . " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " WHERE g.goods_id = '{$goods_id}'" . " AND g.is_delete = 0";
$goods = $GLOBALS['db']->getRow($sql);
if (empty($goods)) {
$GLOBALS['err']->add($GLOBALS['_LANG']['goods_not_exists'], ERR_NOT_EXISTS);
return false;
}
/* 如果是作为配件添加到购物车的,需要先检查购物车里面是否已经有基本件 */
if ($parent > 0) {
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('cart') . " WHERE goods_id='{$parent}' AND session_id='" . SESS_ID . "'";
if ($GLOBALS['db']->getOne($sql) == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['no_basic_goods'], ERR_NO_BASIC_GOODS);
return false;
}
/* 检查该配件是否已经添加过了。 */
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('cart') . " WHERE goods_id = '{$goods_id}' AND parent_id='{$parent}' AND session_id='" . SESS_ID . "'";
if ($GLOBALS['db']->getOne($sql) > 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['fitting_goods_exists'], ERR_NOT_EXISTS);
return false;
}
}
/* 是否正在销售 */
if ($goods['is_on_sale'] == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['not_on_sale'], ERR_NOT_ON_SALE);
return false;
}
/* 不是配件时检查是否允许单独销售 */
if (empty($parent) && $goods['is_alone_sale'] == 0) {
$GLOBALS['err']->add($GLOBALS['_LANG']['cannt_alone_sale'], ERR_CANNT_ALONE_SALE);
return false;
}
/* 检查库存 */
if ($GLOBALS['_CFG']['use_storage'] == 1 && $num > $goods['goods_number']) {
$num = $goods['goods_number'];
$GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['shortage'], $num), ERR_OUT_OF_STOCK);
return false;
}
/* 计算商品的促销价格 */
$spec_price = spec_price($spec);
$goods_price = get_final_price($goods_id, $num, true, $spec);
$goods['market_price'] += $spec_price;
$goods_attr = get_goods_attr_info($spec);
$goods_attr_id = join(',', $spec);
/* 初始化要插入购物车的基本件数据 */
$parent = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $goods_id, 'goods_sn' => addslashes($goods['goods_sn']), 'goods_name' => addslashes($goods['goods_name']), 'market_price' => $goods['market_price'], 'goods_attr' => addslashes($goods_attr), 'goods_attr_id' => $goods_attr_id, 'is_real' => $goods['is_real'], 'extension_code' => $goods['extension_code'], 'is_gift' => 0, 'rec_type' => CART_GENERAL_GOODS);
/* 取得该商品的基本件和该商品作为其配件的价格(条件是价格低) */
$basic_list = array();
$sql = "SELECT parent_id, goods_price " . "FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE goods_id = '{$goods_id}'" . " AND goods_price < '{$goods_price}'" . " ORDER BY goods_price";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$basic_list[$row['parent_id']] = $row['goods_price'];
}
/* 取得购物车中该商品每个基本件的数量 */
$basic_count_list = array();
if ($basic_list) {
$sql = "SELECT goods_id, SUM(goods_number) AS count " . "FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "'" . " AND parent_id = 0" . " AND goods_id " . db_create_in(array_keys($basic_list)) . " GROUP BY goods_id";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$basic_count_list[$row['goods_id']] = $row['count'];
}
}
/* 取得购物车中该商品每个基本件已有该商品配件数量,计算出每个基本件还能有几个该商品配件 */
if ($basic_count_list) {
$sql = "SELECT parent_id, SUM(goods_number) AS count " . "FROM " . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "'" . " AND goods_id = '{$goods_id}'" . " AND parent_id " . db_create_in(array_keys($basic_count_list)) . " GROUP BY parent_id";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$basic_count_list[$row['parent_id']] -= $row['count'];
}
}
/* 循环插入配件 */
foreach ($basic_list as $parent_id => $fitting_price) {
/* 如果已全部插入,退出 */
if ($num <= 0) {
break;
}
/* 如果该基本件不再购物车中,执行下一个 */
if (!isset($basic_count_list[$parent_id])) {
continue;
}
/* 如果该基本件的配件数量已满,执行下一个基本件 */
if ($basic_count_list[$parent_id] <= 0) {
continue;
}
/* 作为该基本件的配件插入 */
$parent['goods_price'] = max($fitting_price, 0);
$parent['goods_number'] = min($num, $basic_count_list[$parent_id]);
$parent['parent_id'] = $parent_id;
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zishashop-svn-to-git,代码行数:101,代码来源:lib_order.php
示例14: addto_cart
/**
* 添加商品到购物车
*
* @access public
* @param integer $goods_id 商品编号
* @param integer $num 商品数量
* @param array $spec 规格值对应的id数组
* @param integer $parent 基本件
* @return boolean
*/
function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0)
{
$GLOBALS['err']->clean();
$_parent_id = $parent;
/*ccx 2015-03-03 判断该商品是否已经通过自动下架功能 start*/
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('auto_manage') . " WHERE item_id = {$goods_id} AND type = 'goods' ";
|
请发表评论