assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 /* 读出所有礼包信?*/ $now = gmtime(); $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE start_time <= '" . $now . "' AND end_time >= '" . $now . "' ORDER BY act_id"; $res = $GLOBALS['db']->getAll($sql); $list = array(); foreach ($res as $tempkey => $value) { $subtotal = 0; $i=1; //获取礼包? $row = unserialize($value['ext_info']); unset($value['ext_info']); if ($row) { foreach ($row as $key=>$val) { $res[$tempkey][$key] = $val; } } $sql = "SELECT pg.package_id, pg.goods_id, pg.product_id, pg.goods_number, pg.admin_id, p.goods_attr, g.goods_sn, g.goods_name, g.market_price, g.goods_thumb, IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS rank_price, g.goods_sn AS short_name, g.goods_sn AS url FROM " . $GLOBALS['ecs']->table('package_goods') . " AS pg LEFT JOIN ". $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id = pg.goods_id LEFT JOIN ". $GLOBALS['ecs']->table('products') . " AS p ON p.product_id = pg.product_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 pg.package_id = " . $value['act_id']. " ORDER BY pg.package_id, pg.goods_id"; $goods_ress = $GLOBALS['db']->query($sql); $goods_res = array(); while ($row = $GLOBALS['db']->fetchRow($goods_ress)) { if ($row['goods_id'] == $goods_id ) { $goods_res[0]=$row; } else { $goods_res[$i]=$row; $i++; } } foreach($goods_res as $key => $val) { $goods_id_array[] = $val['goods_id']; $sql = mysql_query("SELECT attr_value FROM ".$GLOBALS['ecs']->table('goods_attr')." WHERE goods_id = '".$val['goods_id']."' AND attr_id IN (SELECT attr_id FROM ".$GLOBALS['ecs']->table('attribute')." WHERE attr_name = '商品描述')"); if (mysql_num_rows($sql) == 1) $goods_res[$key]['short_name'] = mysql_result($sql, 0); $goods_res[$key]['url'] = build_uri('goods', array('gid'=>$val['goods_id']), $val['goods_name']); $goods_res[$key]['goods_thumb'] = get_image_path($val['goods_id'], $val['goods_thumb'], true); $goods_res[$key]['market_price'] = price_format($val['market_price']); $goods_res[$key]['rank_price'] = $val['rank_price'] * $val['goods_number']; $goods_res[$key]['goods_number'] = $val['goods_number']; $subtotal += $val['rank_price'] * $val['goods_number']; } /* 取商品属?*/ $sql = "SELECT ga.goods_attr_id, ga.attr_value FROM " .$GLOBALS['ecs']->table('goods_attr'). " AS ga, " .$GLOBALS['ecs']->table('attribute'). " AS a WHERE a.attr_id = ga.attr_id AND a.attr_type = 1 AND " . db_create_in($goods_id_array, 'goods_id'); $result_goods_attr = $GLOBALS['db']->getAll($sql); $_goods_attr = array(); foreach ($result_goods_attr as $value) { $_goods_attr[$value['goods_attr_id']] = $value['attr_value']; } /* 处理货品 */ $format = '[%s]'; foreach($goods_res as $key => $val) { if ($val['goods_attr'] != '') { $goods_attr_array = explode('|', $val['goods_attr']); $goods_attr = array(); foreach ($goods_attr_array as $_attr) { $goods_attr[] = $_goods_attr[$_attr]; } $goods_res[$key]['goods_attr_str'] = sprintf($format, implode('?, $goods_attr)); } } ksort($goods_res); //重新排序数组 /* 重新计算套餐内的商品折扣?*/ $res[$tempkey]['total_price']=$subtotal + $res[$tempkey]['install_price']; $res[$tempkey]['discount'] = round($res[$tempkey]['package_price'] / $res[$tempkey]['total_price'] * 100, 0); $last = $res[$tempkey]['discount'] % 10; switch($last) { case 0: $last = 0; break; case 1: $last = 0; break; case 2: $last = 0; break; case 3: $last = 0; break; case 4: $last = 5; break; case 5: $last = 5; break; case 6: $last = 5; break; case 7: $last = 5; break; case 8: $last = 5; break; case 9: $last = 0; break; } $res[$tempkey]['discount'] = substr($res[$tempkey]['discount'], 0, 1).$last; $res[$tempkey]['total_price'] = number_format($res[$tempkey]['total_price'], 0, '', ','); $res[$tempkey]['package_price'] = number_format($res[$tempkey]['package_price'], 0, '', ','); $res[$tempkey]['goods_list'] = $goods_res; $list = $res; } $smarty->assign('list', $list); $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('lang', $_LANG); $smarty->assign('feed_url', ($_CFG['rewrite'] == 1) ? "feed-typepackage.xml" : 'feed.php?type=package'); // RSS URL $smarty->display('package.dwt'); ?>
  • ͳкɫ 罨츣 2018-09-18
  • Ϻ԰ռȳ 2018-07-25
  • лɭרйҵ 2018-07-25
  • ϰƽͬ˹̹ͳҮл̸ 2018-07-24
  • ˰ѡƸչ 2018-07-23
  • СίίԱί 2018-07-22
  • ʦ۶ ¸齲۶-ʱѶ 2018-07-22
  • ̫2018ﰺ˿֮·̫гĻ 2018-07-21
  • ŮԱýǡ 2018-07-20
  • ʮŴҰйλ 2018-07-20
  • йͦԱ۲죩 2018-07-19