Example #1
0
/**
 * 查询会员余额的操作记录
 *
 * @access  public
 * @param   int     $user_id    会员ID
 * @param   int     $num        每页显示数量
 * @param   int     $start      开始显示的条数
 * @return  array
 */
function get_account_log($user_id, $num, $start)
{
    $account_log = array();
    $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('user_account') . " WHERE user_id = '{$user_id}'" . " AND process_type " . db_create_in(array(SURPLUS_SAVE, SURPLUS_RETURN)) . " ORDER BY add_time DESC";
    $res = $GLOBALS['db']->selectLimit($sql, $num, $start);
    if ($res) {
        include_once 'includes/modules/payment/payment.php';
        $pay_obj = new payment();
        while ($rows = $GLOBALS['db']->fetchRow($res)) {
            $rows['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $rows['add_time']);
            $rows['admin_note'] = nl2br(htmlspecialchars($rows['admin_note']));
            $rows['short_admin_note'] = $rows['admin_note'] > '' ? sub_str($rows['admin_note'], 30) : 'N/A';
            $rows['user_note'] = nl2br(htmlspecialchars($rows['user_note']));
            $rows['short_user_note'] = $rows['user_note'] > '' ? sub_str($rows['user_note'], 30) : 'N/A';
            $rows['pay_status'] = $rows['is_paid'] == 0 ? $GLOBALS['_LANG']['un_confirm'] : $GLOBALS['_LANG']['is_confirm'];
            $rows['amount'] = price_format(abs($rows['amount']), false);
            /* 会员的操作类型: 冲值,提现 */
            if ($rows['process_type'] == 0) {
                $rows['type'] = $GLOBALS['_LANG']['surplus_type_0'];
            } else {
                $rows['type'] = $GLOBALS['_LANG']['surplus_type_1'];
            }
            /* 支付方式的ID */
            /**2014-04-08 by hg/
               /* $sql = 'SELECT pay_id FROM ' .$GLOBALS['ecs']->table('payment').
                      " WHERE pay_name = '$rows[payment]' AND enabled = 1";
               $pid = $GLOBALS['db']->getOne($sql); */
            $pay_static = $pay_obj->order_set_and($rows['pay_num']);
            if (!empty($pay_static)) {
                $pid = $rows['pay_num'];
            } else {
                $pid = '';
            }
            /*end*/
            /* 如果是预付款而且还没有付款, 允许付款 */
            if ($rows['is_paid'] == 0 && $rows['process_type'] == 0) {
                $rows['handle'] = '<a href="user.php?act=pay&id=' . $rows['id'] . '&pid=' . $pid . '">' . $GLOBALS['_LANG']['pay'] . '</a>';
            }
            $account_log[] = $rows;
        }
        return $account_log;
    } else {
        return false;
    }
}