-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_log.php
215 lines (187 loc) · 7.34 KB
/
account_log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
/**
* ECSHOP 管理中心帐户变动记录
* ============================================================================
* * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: account_log.php 17217 2011-01-19 06:29:08Z liubo $
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
include_once(ROOT_PATH . 'includes/lib_order.php');
/*------------------------------------------------------ */
//-- 办事处列表
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list')
{
/* 检查参数 */
$user_id = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
if ($user_id <= 0)
{
sys_msg('invalid param');
}
$user = user_info($user_id);
if (empty($user))
{
sys_msg($_LANG['user_not_exist']);
}
$smarty->assign('user', $user);
if (empty($_REQUEST['account_type']) || !in_array($_REQUEST['account_type'],
array('user_money', 'frozen_money', 'rank_points', 'pay_points')))
{
$account_type = '';
}
else
{
$account_type = $_REQUEST['account_type'];
}
$smarty->assign('account_type', $account_type);
$smarty->assign('ur_here', $_LANG['account_list']);
$smarty->assign('action_link', array('text' => $_LANG['add_account'], 'href' => 'account_log.php?act=add&user_id=' . $user_id));
$smarty->assign('full_page', 1);
$account_list = get_accountlist($user_id, $account_type);
$smarty->assign('account_list', $account_list['account']);
$smarty->assign('filter', $account_list['filter']);
$smarty->assign('record_count', $account_list['record_count']);
$smarty->assign('page_count', $account_list['page_count']);
assign_query_info();
$smarty->display('account_list.htm');
}
/*------------------------------------------------------ */
//-- 排序、分页、查询
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'query')
{
/* 检查参数 */
$user_id = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
if ($user_id <= 0)
{
sys_msg('invalid param');
}
$user = user_info($user_id);
if (empty($user))
{
sys_msg($_LANG['user_not_exist']);
}
$smarty->assign('user', $user);
if (empty($_REQUEST['account_type']) || !in_array($_REQUEST['account_type'],
array('user_money', 'frozen_money', 'rank_points', 'pay_points')))
{
$account_type = '';
}
else
{
$account_type = $_REQUEST['account_type'];
}
$smarty->assign('account_type', $account_type);
$account_list = get_accountlist($user_id, $account_type);
$smarty->assign('account_list', $account_list['account']);
$smarty->assign('filter', $account_list['filter']);
$smarty->assign('record_count', $account_list['record_count']);
$smarty->assign('page_count', $account_list['page_count']);
make_json_result($smarty->fetch('account_list.htm'), '',
array('filter' => $account_list['filter'], 'page_count' => $account_list['page_count']));
}
/*------------------------------------------------------ */
//-- 调节帐户
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'add')
{
/* 检查权限 */
admin_priv('account_manage');
/* 检查参数 */
$user_id = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
if ($user_id <= 0)
{
sys_msg('invalid param');
}
$user = user_info($user_id);
if (empty($user))
{
sys_msg($_LANG['user_not_exist']);
}
$smarty->assign('user', $user);
/* 显示模板 */
$smarty->assign('ur_here', $_LANG['add_account']);
$smarty->assign('action_link', array('href' => 'account_log.php?act=list&user_id=' . $user_id, 'text' => $_LANG['account_list']));
assign_query_info();
$smarty->display('account_info.htm');
}
/*------------------------------------------------------ */
//-- 提交添加、编辑办事处
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update')
{
/* 检查权限 */
admin_priv('account_manage');
/* 检查参数 */
$user_id = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
if ($user_id <= 0)
{
sys_msg('invalid param');
}
$user = user_info($user_id);
if (empty($user))
{
sys_msg($_LANG['user_not_exist']);
}
/* 提交值 */
$change_desc = sub_str($_POST['change_desc'], 255, false);
$user_money = floatval($_POST['add_sub_user_money']) * abs(floatval($_POST['user_money']));
$frozen_money = floatval($_POST['add_sub_frozen_money']) * abs(floatval($_POST['frozen_money']));
$rank_points = floatval($_POST['add_sub_rank_points']) * abs(floatval($_POST['rank_points']));
$pay_points = floatval($_POST['add_sub_pay_points']) * abs(floatval($_POST['pay_points']));
if ($user_money == 0 && $frozen_money == 0 && $rank_points == 0 && $pay_points == 0)
{
sys_msg($_LANG['no_account_change']);
}
/* 保存 */
log_account_change($user_id, $user_money, $frozen_money, $rank_points, $pay_points, $change_desc, ACT_ADJUSTING);
/* 提示信息 */
$links = array(
array('href' => 'account_log.php?act=list&user_id=' . $user_id, 'text' => $_LANG['account_list'])
);
sys_msg($_LANG['log_account_change_ok'], 0, $links);
}
/**
* 取得帐户明细
* @param int $user_id 用户id
* @param string $account_type 帐户类型:空表示所有帐户,user_money表示可用资金,
* frozen_money表示冻结资金,rank_points表示等级积分,pay_points表示消费积分
* @return array
*/
function get_accountlist($user_id, $account_type = '')
{
/* 检查参数 */
$where = " WHERE user_id = '$user_id' ";
if (in_array($account_type, array('user_money', 'frozen_money', 'rank_points', 'pay_points')))
{
$where .= " AND $account_type <> 0 ";
}
/* 初始化分页参数 */
$filter = array(
'user_id' => $user_id,
'account_type' => $account_type
);
/* 查询记录总数,计算分页数 */
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('account_log') . $where;
$filter['record_count'] = $GLOBALS['db']->getOne($sql);
$filter = page_and_size($filter);
/* 查询记录 */
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('account_log') . $where .
" ORDER BY log_id DESC";
$res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$row['change_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['change_time']);
$arr[] = $row;
}
return array('account' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
?>