本文整理汇总了PHP中get_goods_info函数的典型用法代码示例。如果您正苦于以下问题:PHP get_goods_info函数的具体用法?PHP get_goods_info怎么用?PHP get_goods_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_goods_info函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$root = array();
$email = strim($GLOBALS['request']['email']);
//用户名或邮箱
$pwd = strim($GLOBALS['request']['pwd']);
//密码
$id = intval($GLOBALS['request']['id']);
$user_id = intval($GLOBALS['user_info']['id']);
//检查用户,用户密码
$user = user_check($email, $pwd);
$user_id = intval($user['id']);
// if ($user_id >0){
require APP_ROOT_PATH . 'app/Lib/deal.php';
require APP_ROOT_PATH . 'app/Lib/uc_goods_func.php';
$root['user_login_status'] = 1;
$root['response_code'] = 1;
if ($id == 0) {
app_redirect(url("index"));
}
$goods = get_goods_info($id, $user_id);
if (!$goods) {
app_redirect(url("index"));
}
$root['goods_description'] = $goods['description'];
$root['user_can_buy_number'] = $goods['user_can_buy_number'];
if ($goods['goods_type_id'] > 0) {
$goods_type_attr = get_goods_attr($goods['goods_type_id'], $id);
$root['has_stock'] = $goods_type_attr['has_stock'];
$root['goods_type_attr'] = $goods_type_attr['goods_type_attr'];
$root['json_attr_stock'] = json_encode($goods_type_attr['attr_stock']);
} else {
$has_stock = 1;
//$GLOBALS['tmpl']->assign("has_stock",$has_stock);
$root['has_stock'] = $has_stock;
}
$root['goods'] = $goods;
// }else{
// $root['response_code'] = 0;
// $root['show_err'] ="未登录";
// $root['user_login_status'] = 0;
// }
$root['program_title'] = "商品详情";
output($root);
}
示例2: view
function view()
{
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$goods_id = isset($_GET['id']) ? intval($_GET['id']) : 1;
$isdetail = isset($_GET['isdetail']) ? intval($_GET['isdetail']) : 0;
if ($isdetail == 0) {
$r_data = get_goods_info($goods_id);
} else {
$r_data = get_goods_info_detail($goods_id);
}
return $r_data;
break;
default:
return 'This API can not support ' . $_SERVER['REQUEST_METHOD'] . ' method';
break;
}
}
示例3: index
public function index()
{
$root = array();
$email = strim($GLOBALS['request']['email']);
//用户名或邮箱
$pwd = strim($GLOBALS['request']['pwd']);
//密码
$goods_id = intval($GLOBALS['request']['id']);
$number = intval($GLOBALS['request']['number']);
$user_id = intval($GLOBALS['user_info']['id']);
//检查用户,用户密码
$user = user_check($email, $pwd);
$user_id = intval($user['id']);
if ($user_id > 0) {
require APP_ROOT_PATH . 'app/Lib/deal.php';
require APP_ROOT_PATH . 'app/Lib/uc_goods_func.php';
$root['user_login_status'] = 1;
$root['response_code'] = 1;
$goods = get_goods_info($goods_id, $user_id);
$sql = "SELECT * from " . DB_PREFIX . "user_address where user_id = '{$user_id}' and is_default = 1 ";
$user_address = $GLOBALS['db']->getRow($sql);
$is_number = $GLOBALS['db']->getOne("SELECT count(*) from " . DB_PREFIX . "user_address where user_id = '{$user_id}' and is_default = 1");
if ($is_number != 0) {
$is_address = 1;
} else {
$is_address = 0;
}
$root['is_address'] = $is_address;
$root['user_address'] = $user_address;
$root['goods'] = $goods;
$root['goods_id'] = $goods_id;
$root['number'] = $number;
$root['needscore'] = $goods['score'] * $number;
} else {
$root['response_code'] = 0;
$root['show_err'] = "未登录";
$root['user_login_status'] = 0;
}
$root['program_title'] = "确认兑换";
output($root);
}
示例4: action_affiliate
//.........这里部分代码省略.........
for ($i = 1; $i <= $num; $i++) {
$count = 0;
if ($up_uid) {
$sql = "SELECT user_id FROM " . $ecs->table('users') . " WHERE parent_id IN({$up_uid})";
$query = $db->query($sql);
$up_uid = '';
while ($rt = $db->fetch_array($query)) {
$up_uid .= $up_uid ? ",'{$rt['user_id']}'" : "'{$rt['user_id']}'";
if ($i < $num) {
$all_uid .= ", '{$rt['user_id']}'";
}
$count++;
}
}
$affdb[$i]['num'] = $count;
$affdb[$i]['point'] = $affiliate['item'][$i - 1]['level_point'];
$affdb[$i]['money'] = $affiliate['item'][$i - 1]['level_money'];
}
$smarty->assign('affdb', $affdb);
$sqlcount = "SELECT count(*) FROM " . $ecs->table('order_info') . " o" . " LEFT JOIN" . $ecs->table('users') . " u ON o.user_id = u.user_id" . " LEFT JOIN " . $ecs->table('affiliate_log') . " a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (u.parent_id IN ({$all_uid}) AND o.is_separate = 0 OR a.user_id = '{$user_id}' AND o.is_separate > 0)";
$sql = "SELECT o.*, a.log_id, a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type FROM " . $ecs->table('order_info') . " o" . " LEFT JOIN" . $ecs->table('users') . " u ON o.user_id = u.user_id" . " LEFT JOIN " . $ecs->table('affiliate_log') . " a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (u.parent_id IN ({$all_uid}) AND o.is_separate = 0 OR a.user_id = '{$user_id}' AND o.is_separate > 0)" . " ORDER BY order_id DESC";
/*
* SQL解释:
*
* 订单、用户、分成记录关联
* 一个订单可能有多个分成记录
*
* 1、订单有效 o.user_id > 0
* 2、满足以下之一:
* a.直接下线的未分成订单 u.parent_id IN ($all_uid) AND o.is_separate = 0
* 其中$all_uid为该ID及其下线(不包含最后一层下线)
* b.全部已分成订单 a.user_id = '$user_id' AND o.is_separate > 0
*
*/
$affiliate_intro = nl2br(sprintf($_LANG['affiliate_intro'][$affiliate['config']['separate_by']], $affiliate['config']['expire'], $_LANG['expire_unit'][$affiliate['config']['expire_unit']], $affiliate['config']['level_register_all'], $affiliate['config']['level_register_up'], $affiliate['config']['level_money_all'], $affiliate['config']['level_point_all']));
} else {
// 推荐订单分成
$sqlcount = "SELECT count(*) FROM " . $ecs->table('order_info') . " o" . " LEFT JOIN" . $ecs->table('users') . " u ON o.user_id = u.user_id" . " LEFT JOIN " . $ecs->table('affiliate_log') . " a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (o.parent_id = '{$user_id}' AND o.is_separate = 0 OR a.user_id = '{$user_id}' AND o.is_separate > 0)";
$sql = "SELECT o.*, a.log_id,a.user_id as suid, a.user_name as auser, a.money, a.point, a.separate_type,u.parent_id as up FROM " . $ecs->table('order_info') . " o" . " LEFT JOIN" . $ecs->table('users') . " u ON o.user_id = u.user_id" . " LEFT JOIN " . $ecs->table('affiliate_log') . " a ON o.order_id = a.order_id" . " WHERE o.user_id > 0 AND (o.parent_id = '{$user_id}' AND o.is_separate = 0 OR a.user_id = '{$user_id}' AND o.is_separate > 0)" . " ORDER BY order_id DESC";
/*
* SQL解释:
*
* 订单、用户、分成记录关联
* 一个订单可能有多个分成记录
*
* 1、订单有效 o.user_id > 0
* 2、满足以下之一:
* a.订单下线的未分成订单 o.parent_id = '$user_id' AND o.is_separate = 0
* b.全部已分成订单 a.user_id = '$user_id' AND o.is_separate > 0
*
*/
$affiliate_intro = nl2br(sprintf($_LANG['affiliate_intro'][$affiliate['config']['separate_by']], $affiliate['config']['expire'], $_LANG['expire_unit'][$affiliate['config']['expire_unit']], $affiliate['config']['level_money_all'], $affiliate['config']['level_point_all']));
}
$count = $db->getOne($sqlcount);
$max_page = $count > 0 ? ceil($count / $size) : 1;
if ($page > $max_page) {
$page = $max_page;
}
$res = $db->SelectLimit($sql, $size, ($page - 1) * $size);
$logdb = array();
while ($rt = $GLOBALS['db']->fetchRow($res)) {
if (!empty($rt['suid'])) {
// 在affiliate_log有记录
if ($rt['separate_type'] == -1 || $rt['separate_type'] == -2) {
// 已被撤销
$rt['is_separate'] = 3;
}
}
$rt['order_sn'] = substr($rt['order_sn'], 0, strlen($rt['order_sn']) - 5) . "***" . substr($rt['order_sn'], -2, 2);
$logdb[] = $rt;
}
$url_format = "user.php?act=affiliate&page=";
$pager = array('page' => $page, 'size' => $size, 'sort' => '', 'order' => '', 'record_count' => $count, 'page_count' => $max_page, 'page_first' => $url_format . '1', 'page_prev' => $page > 1 ? $url_format . ($page - 1) : "javascript:;", 'page_next' => $page < $max_page ? $url_format . ($page + 1) : "javascript:;", 'page_last' => $url_format . $max_page, 'array' => array());
for ($i = 1; $i <= $max_page; $i++) {
$pager['array'][$i] = $i;
}
$smarty->assign('url_format', $url_format);
$smarty->assign('pager', $pager);
$smarty->assign('affiliate_intro', $affiliate_intro);
$smarty->assign('affiliate_type', $affiliate['config']['separate_by']);
$smarty->assign('logdb', $logdb);
} else {
// 单个商品推荐
$smarty->assign('userid', $user_id);
$smarty->assign('goodsid', $goodsid);
$types = array(1, 2, 3, 4, 5);
$smarty->assign('types', $types);
$goods = get_goods_info($goodsid);
$shopurl = $ecs->url();
$goods['goods_img'] = strpos($goods['goods_img'], 'http://') === false && strpos($goods['goods_img'], 'https://') === false ? $shopurl . $goods['goods_img'] : $goods['goods_img'];
$goods['goods_thumb'] = strpos($goods['goods_thumb'], 'http://') === false && strpos($goods['goods_thumb'], 'https://') === false ? $shopurl . $goods['goods_thumb'] : $goods['goods_thumb'];
$goods['shop_price'] = price_format($goods['shop_price']);
$smarty->assign('goods', $goods);
}
$smarty->assign('shopname', $_CFG['shop_name']);
$smarty->assign('userid', $user_id);
$smarty->assign('shopurl', $ecs->url());
$smarty->assign('logosrc', 'themes/' . $_CFG['template'] . '/images/logo.gif');
$smarty->display('user_clips.dwt');
}
示例5: get_footer
if ($GLOBALS['_CFG']['comment_check'] == 1) {
$smarty->assign('info', '您的评论已成功发表, 请等待管理员的审核!');
} else {
$smarty->assign('info', '您的评论已成功发表, 感谢您的参与!');
}
}
}
$smarty->assign('footer', get_footer());
$smarty->display('comment_success.dwt');
} else {
/* 读取商品信息 */
$_LANG['kilogram'] = '千克';
$_LANG['gram'] = '克';
$_LANG['home'] = '首页';
$smarty->assign('goods_id', $goods_id);
$goods_info = get_goods_info($goods_id);
$goods_info['goods_name'] = encode_output($goods_info['goods_name']);
$goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
$smarty->assign('goods_info', $goods_info);
/* 读评论信息 */
$comment = assign_comment_wap($goods_id, 'comments');
$num = $comment['pager']['record_count'];
if ($num > 0) {
$page_num = '5';
$page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
$pages = ceil($num / $page_num);
if ($page <= 0) {
$page = 1;
}
if ($pages == 0) {
$pages = 1;
示例6: array
$pager = array('page' => $page, 'size' => $size, 'sort' => '', 'order' => '', 'record_count' => $count, 'page_count' => $max_page, 'page_first' => $url_format . '1', 'page_prev' => $page > 1 ? $url_format . ($page - 1) : "javascript:;", 'page_next' => $page < $max_page ? $url_format . ($page + 1) : "javascript:;", 'page_last' => $url_format . $max_page, 'array' => array());
for ($i = 1; $i <= $max_page; $i++) {
$pager['array'][$i] = $i;
}
$smarty->assign('url_format', $url_format);
$smarty->assign('pager', $pager);
$smarty->assign('affiliate_intro', $affiliate_intro);
$smarty->assign('affiliate_type', $affiliate['config']['separate_by']);
$smarty->assign('logdb', $logdb);
} else {
//单个商品推荐
$smarty->assign('userid', $user_id);
$smarty->assign('goodsid', $goodsid);
$types = array(1, 2, 3, 4, 5);
$smarty->assign('types', $types);
$goods = get_goods_info($goodsid);
$shopurl = $ecs->url();
$goods['goods_img'] = strpos($goods['goods_img'], 'http://') === false && strpos($goods['goods_img'], 'https://') === false ? $shopurl . $goods['goods_img'] : $goods['goods_img'];
$goods['goods_thumb'] = strpos($goods['goods_thumb'], 'http://') === false && strpos($goods['goods_thumb'], 'https://') === false ? $shopurl . $goods['goods_thumb'] : $goods['goods_thumb'];
$goods['shop_price'] = price_format($goods['shop_price']);
$smarty->assign('goods', $goods);
}
$smarty->assign('shopname', $_CFG['shop_name']);
$smarty->assign('userid', $user_id);
$smarty->assign('shopurl', $ecs->url());
$smarty->assign('logosrc', 'themes/' . $_CFG['template'] . '/images/logo.gif');
$smarty->display('user_clips.dwt');
} elseif ($action == 'email_list') {
$job = $_GET['job'];
if ($job == 'add' || $job == 'del') {
if (isset($_SESSION['last_email_query'])) {
示例7: die
// 该订单允许使用的积分
$user_points = $user_info['pay_points'];
// 用户的积分总数
if ($points > $user_points) {
die($_LANG['integral_not_enough']);
}
if ($points > $flow_points) {
die(sprintf($_LANG['integral_too_much'], $flow_points));
}
exit;
} elseif ($_REQUEST['step'] == 'done') {
include_once 'includes/lib_clips.php';
include_once 'includes/lib_payment.php';
/* 取得购物类型 */
foreach ($cart_goods as $key => $value) {
$goods_tmp = get_goods_info($value['goods_id']);
$cart_goods[$key]['goods_img'] = $goods_tmp['goods_img'];
}
$flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
/* 检查购物车中是否有商品 */
$sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND parent_id = 0 AND is_gift = 0 AND rec_type = '{$flow_type}'";
if ($db->getOne($sql) == 0) {
show_message($_LANG['no_goods_in_cart'], '', '', 'warning');
}
/* 检查商品库存 */
/* 如果使用库存,且下订单时减库存,则减少库存 */
if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) {
$cart_goods_stock = get_cart_goods();
$_cart_goods_stock = array();
foreach ($cart_goods_stock['goods_list'] as $value) {
$_cart_goods_stock[$value['rec_id']] = $value['goods_number'];
示例8: get_collected_goods
/**
* 购买此商品的人还喜欢(从用户收藏夹里取)chen-0925
*
* @access public
* @param integer $goods_id
* @return array
*/
function get_collected_goods($goods_id)
{
$sql = "select distinct oi.user_id from " . $GLOBALS['ecs']->table('order_info') . " as oi join " . $GLOBALS['ecs']->table('order_goods') . " as og " . " on oi.order_id = og.order_id " . " where og.goods_id = {$goods_id} order by rand() limit 4";
$users = $GLOBALS['db']->getAll($sql);
for ($i = 0; $i < count($users); $i++) {
$users[$i] = $users[$i]['user_id'];
}
$sql = "select distinct goods_id from " . $GLOBALS['ecs']->table('collect_goods') . " where goods_id != {$goods_id} and " . db_create_in($users, 'user_id') . " order by rand() limit 4";
$goods = $GLOBALS['db']->getAll($sql);
$tmp = array();
for ($i = 0; $i < count($goods); $i++) {
$goods[$i] = get_goods_info($goods[$i]['goods_id']);
$tmp[$i]['goods_id'] = $goods[$i]['goods_id'];
$tmp[$i]['goods_thumb'] = $goods[$i]['goods_thumb'];
$tmp[$i]['rank_price'] = $goods[$i]['rank_price'];
}
return $tmp;
}
示例9: getGoodsInfo
function getGoodsInfo($id)
{
return get_goods_info($id);
}
示例10: doexchange
public function doexchange()
{
$user_id = $GLOBALS['user_info']['id'];
$address_id = intval($_REQUEST['address_id']);
$add_addr = intval($_REQUEST['add_addr']);
$goods_id = intval($_REQUEST['goods_id']);
$number = intval($_REQUEST['number']);
$attr = $_REQUEST['attr'];
if ($user_id == 0) {
$return['info'] = "请先登录!";
$return['status'] = 2;
ajax_return($return);
}
if ($number <= 0) {
$return['info'] = "请输入正确的兑换数量";
$return['status'] = 0;
ajax_return($return);
}
$return = array("jump" => url("index", "uc_goods_order"));
$goods = get_goods_info($goods_id, $user_id);
if ($goods <= 0) {
$return['info'] = "商品不存在";
$return['status'] = 0;
ajax_return($return);
}
if ($number > $goods['user_can_buy_number']) {
$return['info'] = "超出你所能兑换的数量";
$return['status'] = 0;
ajax_return($return);
}
//判断是否有属性库存
$attr_stocks = get_attr_stock($goods, $number, $goods_id, $attr);
if ($add_addr == 1 && $goods['is_delivery'] == 1) {
$user_name = strim($_REQUEST['user_name']);
//收货名称
if ($user_name == "") {
$return['info'] = "请输入收货人姓名";
$return['status'] = 0;
ajax_return($return);
}
$user_phone = strim($_REQUEST['user_phone']);
if ($user_phone == "") {
$return['info'] = "请输入收货人电话";
$return['status'] = 0;
ajax_return($return);
}
$user_address = strim($_REQUEST['user_address']);
if ($user_address == "") {
$return['info'] = "请输入收货人地址";
$return['status'] = 0;
ajax_return($return);
}
//提交地址
$addr_data['user_id'] = $user_id;
$addr_data['name'] = $user_name;
$addr_data['address'] = $user_address;
$addr_data['phone'] = $user_phone;
$addr_data['is_default'] = 1;
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_address", $addr_data, "INSERT");
$address_id = $GLOBALS['db']->insert_id();
if (intval($address_id) == 0) {
$return['info'] = "地址保存失败";
$return['status'] = 0;
ajax_return($return);
}
}
//库存属性 star
$order_data = array();
if (isset($temp_attr_stock[$attr_str])) {
$GLOBALS['db']->query("UPDATE " . DB_PREFIX . "goods_attr_stock SET buy_count = buy_count +" . $number . " WHERE id=" . $temp_attr_stock[$attr_str]['id']);
$order_data['attr_stock_id'] = $temp_attr_stock[$attr_str]['id'];
}
if ($attr) {
$order_data['attr'] = serialize($attr);
}
//库存属性 end
$user_info = $GLOBALS['user_info'];
if (($goods['score'] + $goods_attr_scoresum) * $number > $user_info['score']) {
$return['info'] = "积分不足,无法兑换";
$return['status'] = 0;
ajax_return($return);
}
$order_data['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99);
$order_data['goods_id'] = $goods_id;
$order_data['goods_name'] = $goods['name'];
$order_data['score'] = $goods['score'];
$order_data['total_score'] = ($goods['score'] + $goods_attr_scoresum) * $number;
//总积分 =(积分+属性积分)*数量
$order_data['number'] = $number;
//数量
$order_data['delivery_sn'] = "";
//快递单号
$order_data['order_status'] = 0;
//(0:未发货;1:已发货)
$order_data['user_id'] = $user_id;
$order_data['ex_time'] = TIME_UTC;
$order_data['ex_date'] = to_date(TIME_UTC, "Y-m-d");
$order_data['delivery_time'] = "";
$order_data['delivery_date'] = "";
$order_data['is_delivery'] = $goods['is_delivery'];
//.........这里部分代码省略.........
示例11: action_view
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);
//.........这里部分代码省略.........
示例12: index
public function index()
{
$root = array();
$email = strim($GLOBALS['request']['email']);
//用户名或邮箱
$pwd = strim($GLOBALS['request']['pwd']);
//密码
$user_id = intval($GLOBALS['user_info']['id']);
$address_id = intval($GLOBALS['request']['address_id']);
$goods_id = intval($GLOBALS['request']['id']);
$number = intval($GLOBALS['request']['number']);
//检查用户,用户密码
$user = user_check($email, $pwd);
$root['user_info'] = $user;
$user_id = intval($user['id']);
if ($user_id > 0) {
require APP_ROOT_PATH . 'app/Lib/deal.php';
require APP_ROOT_PATH . 'app/Lib/uc_goods_func.php';
if ($number <= 0) {
$root['show_err'] = "请输入正确的兑换数量";
$root['status'] = 0;
}
$return = array("jump" => url("index", "uc_goods_order"));
$goods = get_goods_info($goods_id, $user_id);
if ($goods <= 0) {
$root['show_err'] = "商品不存在";
$root['status'] = 0;
}
if ($number > $goods['user_can_buy_number']) {
$root['show_err'] = "超出你所能兑换的数量";
$root['status'] = 0;
}
if ($address_id == 0 || $address_id == "") {
$root['show_err'] = "请填写收货信息";
$root['status'] = 0;
output($root);
}
if ($goods_id == 0 || $goods_id == "") {
$root['show_err'] = "没有该物品";
$root['status'] = 0;
output($root);
}
$user_info = $GLOBALS['user_info'];
if ($goods['score'] * $number > $user_info['score']) {
$root['show_err'] = "积分不足,无法兑换";
$root['status'] = 0;
}
$order_data['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99);
$order_data['goods_id'] = $goods_id;
$order_data['goods_name'] = $goods['name'];
$order_data['score'] = $goods['score'];
$order_data['total_score'] = $goods['score'] * $number;
//总积分 =(积分+属性积分)*数量
$order_data['number'] = $number;
//数量
$order_data['delivery_sn'] = "";
//快递单号
$order_data['order_status'] = 0;
//(0:未发货;1:已发货)
$order_data['user_id'] = $user_id;
$order_data['ex_time'] = TIME_UTC;
$order_data['ex_date'] = to_date(TIME_UTC, "Y-m-d");
$order_data['delivery_time'] = "";
$order_data['delivery_date'] = "";
$order_data['is_delivery'] = $goods['is_delivery'];
require_once APP_ROOT_PATH . "system/libs/user.php";
if (intval($goods['is_delivery']) == 1) {
$sql = "SELECT * from " . DB_PREFIX . "user_address where id = " . $address_id;
$address_info = $GLOBALS['db']->getRow($sql);
//提交订单
$order_data['delivery_addr'] = strim($address_info['address']);
$order_data['delivery_tel'] = strim($address_info['phone']);
$order_data['delivery_name'] = strim($address_info['name']);
}
$GLOBALS['db']->autoExecute(DB_PREFIX . "goods_order", $order_data, "INSERT");
if ($GLOBALS['db']->affected_rows()) {
//订单提交成功,增加购买用户数和扣除积分
$goods_data['buy_number'] = $goods['buy_number'] + $number;
$goods_data['invented_number'] = $goods['invented_number'] + 1;
$GLOBALS['db']->autoExecute(DB_PREFIX . "goods", $goods_data, "UPDATE", "id=" . $goods['id']);
$msg = '积分兑换商品<a href="' . url("index", "goods_information#index", array("id" => $goods['id'])) . '" target="_blank">' . $order_data['goods_name'] . '</a>';
modify_account(array('score' => -$order_data['total_score']), $GLOBALS['user_info']['id'], $msg, 22);
$root['show_err'] = "兑换成功";
$root['status'] = 1;
} else {
$root['show_err'] = "兑换失败";
$root['status'] = 0;
}
} else {
$root['response_code'] = 0;
$root['show_err'] = "未登录";
$root['user_login_status'] = 0;
}
$root['program_title'] = "商品详情";
output($root);
}