commit | author | age
|
e2b48d
|
1 |
<?php |
B |
2 |
|
|
3 |
|
|
4 |
define('IN_ECS', true); |
|
5 |
|
|
6 |
require('../includes/init.php'); |
|
7 |
require('../includes/lib_order.php'); |
|
8 |
include('../includes/cls_json.php'); |
|
9 |
$json = new JSON; |
|
10 |
/* 载入语言文件 */ |
|
11 |
require_once('../languages/zh_cn/shopping_flow.php'); |
|
12 |
require_once('../languages/zh_cn/user.php'); |
|
13 |
|
|
14 |
$smarty->template_dir = ROOT_PATH . 'json/tpl';//app部分模板所在位置 |
|
15 |
|
|
16 |
/*------------------------------------------------------ */ |
|
17 |
//-- PROCESSOR |
|
18 |
/*------------------------------------------------------ */ |
|
19 |
|
|
20 |
$result = array('error'=>0,'result'=>''); |
|
21 |
|
|
22 |
$page = (isset($_REQUEST['page'])) ? intval($_REQUEST['page']) : 0; |
|
23 |
$num = 1; |
|
24 |
|
|
25 |
assign_template(); |
|
26 |
assign_dynamic('activity'); |
|
27 |
|
|
28 |
// 数据准备 |
|
29 |
|
|
30 |
/* 取得用户等级 */ |
|
31 |
$user_rank_list = array(); |
|
32 |
$user_rank_list[0] = $_LANG['not_user']; |
|
33 |
$sql = "SELECT rank_id, rank_name FROM " . $ecs->table('user_rank'); |
|
34 |
$res = $db->query($sql); |
|
35 |
while ($row = $db->fetchRow($res)) |
|
36 |
{ |
|
37 |
$user_rank_list[$row['rank_id']] = $row['rank_name']; |
|
38 |
} |
|
39 |
|
|
40 |
// 开始工作 |
|
41 |
|
|
42 |
//$sql = "SELECT * FROM " . $ecs->table('favourable_activity'). " ORDER BY `sort_order` ASC,`end_time` DESC"; |
|
43 |
$nowtime = time(); |
|
44 |
$sql = "SELECT fa.* FROM " . $ecs->table('favourable_activity'). " AS fa ". |
|
45 |
"WHERE fa.start_time<=".$nowtime." AND fa.end_time>=".$nowtime. |
|
46 |
" ORDER BY fa.`sort_order` ASC,fa.`end_time` DESC LIMIT ".$page*$num.",".$num; |
|
47 |
$res = $db->query($sql); |
|
48 |
|
|
49 |
$list = array(); |
|
50 |
while ($row = $db->fetchRow($res)) |
|
51 |
{ |
|
52 |
$row['start_time'] = local_date('Y-m-d H:i', $row['start_time']); |
|
53 |
$row['end_time'] = local_date('Y-m-d H:i', $row['end_time']); |
|
54 |
|
|
55 |
//享受优惠会员等级 |
|
56 |
$user_rank = explode(',', $row['user_rank']); |
|
57 |
$row['user_rank'] = array(); |
|
58 |
foreach($user_rank as $val) |
|
59 |
{ |
|
60 |
if (isset($user_rank_list[$val])) |
|
61 |
{ |
|
62 |
$row['user_rank'][] = $user_rank_list[$val]; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
//优惠范围类型、内容 |
|
67 |
if ($row['act_range'] != FAR_ALL && !empty($row['act_range_ext'])) |
|
68 |
{ |
|
69 |
if ($row['act_range'] == FAR_CATEGORY) |
|
70 |
{ |
|
71 |
$row['act_range'] = $_LANG['far_category']; |
|
72 |
$row['program'] = 'category.php?id='; |
|
73 |
$sql = "SELECT cat_id AS id, cat_name AS name FROM " . $ecs->table('category') . |
|
74 |
" WHERE cat_id " . db_create_in($row['act_range_ext']); |
|
75 |
} |
|
76 |
elseif ($row['act_range'] == FAR_BRAND) |
|
77 |
{ |
|
78 |
$row['act_range'] = $_LANG['far_brand']; |
|
79 |
$row['program'] = 'brand.php?id='; |
|
80 |
$sql = "SELECT brand_id AS id, brand_name AS name FROM " . $ecs->table('brand') . |
|
81 |
" WHERE brand_id " . db_create_in($row['act_range_ext']); |
|
82 |
} |
|
83 |
else |
|
84 |
{ |
|
85 |
$row['act_range'] = $_LANG['far_goods']; |
|
86 |
$row['program'] = 'goods.php?id='; |
|
87 |
$sql = "SELECT goods_id AS id, goods_name AS name FROM " . $ecs->table('goods') . |
|
88 |
" WHERE goods_id " . db_create_in($row['act_range_ext']); |
|
89 |
} |
|
90 |
$act_range_ext = $db->getAll($sql); |
|
91 |
$row['act_range_ext'] = $act_range_ext; |
|
92 |
} |
|
93 |
else |
|
94 |
{ |
|
95 |
$row['act_range'] = $_LANG['far_all']; |
|
96 |
} |
|
97 |
|
|
98 |
//优惠方式 |
|
99 |
$row['act_type_num'] = $row['act_type']; |
|
100 |
switch($row['act_type']) |
|
101 |
{ |
|
102 |
case 0: |
|
103 |
$row['act_type'] = $_LANG['fat_goods']; |
|
104 |
$row['gift'] = unserialize($row['gift']); |
|
105 |
if(is_array($row['gift'])) |
|
106 |
{ |
|
107 |
foreach($row['gift'] as $k=>$v) |
|
108 |
{ |
|
109 |
$row['gift'][$k]['thumb'] = get_image_path($v['id'], $db->getOne("SELECT goods_thumb FROM " . $ecs->table('goods') . " WHERE goods_id = '" . $v['id'] . "'"), true); |
|
110 |
} |
|
111 |
} |
|
112 |
break; |
|
113 |
case 1: |
|
114 |
$row['act_type'] = $_LANG['fat_price']; |
|
115 |
$row['act_type_ext'] .= $_LANG['unit_yuan']; |
|
116 |
$row['gift'] = array(); |
|
117 |
break; |
|
118 |
case 2: |
|
119 |
$row['act_type'] = $_LANG['fat_discount']; |
|
120 |
$row['act_type_ext'] .= "%"; |
|
121 |
$row['gift'] = array(); |
|
122 |
break; |
|
123 |
} |
|
124 |
|
|
125 |
if($row['supplier_id'] > 0){ |
|
126 |
$sql = "select code,value from " . $ecs->table('supplier_shop_config'). |
|
127 |
" where supplier_id=".$row['supplier_id']. |
|
128 |
" AND code in('shop_name','shop_logo')"; |
|
129 |
$r = $db->getAll($sql); |
|
130 |
foreach($r as $k=>$v){ |
|
131 |
$row[$v['code']] = $v['value']; |
|
132 |
} |
|
133 |
}else{ |
|
134 |
$row['shop_logo'] = './images/ziying.jpg'; |
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
$list[] = $row; |
|
139 |
} |
|
140 |
|
|
141 |
$smarty->assign('list', $list); |
|
142 |
|
|
143 |
$smarty->assign('lang', $_LANG); |
|
144 |
|
|
145 |
$result['result'] = $smarty->fetch('activity_app.lbi'); |
|
146 |
|
|
147 |
die($json->encode($result)); |
|
148 |
|