wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
3e083b 1 <?php
B 2
3 /**
4  * 超值礼包列表
5  */
6
7 define('IN_ECS', true);
8
9 require(dirname(__FILE__) . '/includes/init.php');
10 require_once(ROOT_PATH . 'includes/lib_order.php');
11 include_once(ROOT_PATH . 'includes/lib_transaction.php');
12
13 /* 载入语言文件 */
14 require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/shopping_flow.php');
15 require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');
16 require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/admin/package.php');
17
18 /*------------------------------------------------------ */
19 //-- PROCESSOR
20 /*------------------------------------------------------ */
21
22 assign_template();
23 assign_dynamic('package');
24 $position = assign_ur_here(0, $_LANG['shopping_package']);
25 $smarty->assign('page_title',       $position['title']);    // 页面标题
26 $smarty->assign('ur_here',          $position['ur_here']);  // 当前位置
27
28 /* 读出所有礼包信息 */
29
30 $now = gmtime();
31
32 $sql = "SELECT * FROM " . $ecs->table('goods_activity'). " WHERE `start_time` <= '$now' AND `end_time` >= '$now' AND `act_type` = '4' ORDER BY `end_time`";
33 $res = $db->query($sql);
34
35 $list = array();
36 while ($row = $db->fetchRow($res))
37 {
38     $row['start_time']  = local_date('Y-m-d H:i', $row['start_time']);
39     $row['end_time']    = local_date('Y-m-d H:i', $row['end_time']);
40     $ext_arr = unserialize($row['ext_info']);
41     unset($row['ext_info']);
42     if ($ext_arr)
43     {
44         foreach ($ext_arr as $key=>$val)
45         {
46             $row[$key] = $val;
47         }
48     }
49
50     $sql = "SELECT pg.package_id, pg.goods_id, pg.goods_number, pg.admin_id, ".
51            " g.goods_sn, g.goods_name, g.shop_price, g.goods_thumb, ".
52            " IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS rank_price " .
53            " FROM " . $GLOBALS['ecs']->table('package_goods') . " AS pg ".
54            "   LEFT JOIN ". $GLOBALS['ecs']->table('goods') . " AS g ".
55            "   ON g.goods_id = pg.goods_id ".
56            " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
57                 "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
58            " WHERE pg.package_id = " . $row['act_id']. " ".
59             
60             " AND g.is_delete = 0 AND g.is_on_sale = 1 " .
61           
62            " ORDER BY pg.goods_id";
63
64     $goods_res = $GLOBALS['db']->getAll($sql);
65
66     $subtotal = 0;
67     foreach($goods_res as $key => $val)
68     {
69         $goods_res[$key]['goods_thumb']  = get_image_path($val['goods_id'], $val['goods_thumb'], true);
70         $goods_res[$key]['shop_price'] = price_format($val['shop_price']);
71         $goods_res[$key]['rank_price']   = price_format($val['rank_price']);
72         $subtotal += $val['rank_price'] * $val['goods_number'];
73     }
74
75
76     $row['goods_list']    = $goods_res;
77     $row['goods_list_count'] = count($row['goods_list']);
78     $row['subtotal']      = price_format($subtotal);
79     $row['saving']        = price_format(($subtotal - $row['package_price']));
80     $row['package_price'] = price_format($row['package_price']);
81
82     $list[] = $row;
83 }
84
85 $smarty->assign('list',             $list);
86
87 $smarty->assign('helps',            get_shop_help());       // 网店帮助
88 $smarty->assign('lang',             $_LANG);
89
90 $smarty->assign('feed_url',         ($_CFG['rewrite'] == 1) ? "feed-typepackage.xml" : 'feed.php?type=package'); // RSS URL
91 $smarty->display('package.dwt');
92