示例#1
0
function billing_description_account_owner_names($accData)
{
    lets_use('billing_account');
    if (!$accData) {
        return [];
    }
    $users = $sources = $result = [];
    foreach ($accData as &$accInfo) {
        $id = $accInfo[BILLING_ACCOUNT_FIELD_ID];
        $ownerId = $accInfo[BILLING_ACCOUNT_FIELD_OWNER_ID];
        switch ($accInfo[BILLING_ACCOUNT_FIELD_TYPE]) {
            case BILLING_ACCOUNT_TYPE_USER_MAIN:
            case BILLING_ACCOUNT_TYPE_USER_LOCKED:
                $users[$id] = $ownerId;
                break;
            case BILLING_ACCOUNT_TYPE_INCOMING:
                $sources[$id] = $ownerId;
                break;
            case BILLING_ACCOUNT_TYPE_SYSTEM:
            default:
                $result[$id] = '';
                break;
        }
    }
    lets_use('storage_db');
    $userNames = storage_db_get_rows('users', ['id', 'name'], [['id', $users]], [], 'id');
    $sourcesNames = storage_db_get_rows('money_source', ['id', 'name'], ['id', $sources], [], 'id');
    foreach ($users as $accId => $userId) {
        $result[$accId] = isset($userNames[$userId]) ? $userNames[$userId]['name'] : '';
    }
    foreach ($sources as $accId => $sourceId) {
        $result[$accId] = isset($sourcesNames[$sourceId]) ? $sourcesNames[$sourceId]['name'] : '';
    }
    return $result;
}
示例#2
0
function billing_account_get_accounts($accIds)
{
    lets_use('storage_db');
    if (!$accIds) {
        return [];
    }
    return storage_db_get_rows(BILLING_ACCOUNT_DB_TABLE, '*', [[BILLING_ACCOUNT_FIELD_ID, $accIds]]);
}
示例#3
0
function billing_transaction_get_accounts_transactions($accounts)
{
    lets_use('storage_db');
    $income = storage_db_get_rows(BILLING_TRANSACTION_DB_TABLE, '*', [[BILLING_TRANSACTION_FIELD_ACC_TO, $accounts]]);
    $outcome = storage_db_get_rows(BILLING_TRANSACTION_DB_TABLE, '*', [[BILLING_TRANSACTION_FIELD_ACC_FROM, $accounts]]);
    $result = [];
    foreach ($income as $transaction) {
        $result[$transaction[BILLING_TRANSACTION_FIELD_STARTED] << 32 | $transaction[BILLING_TRANSACTION_FIELD_ID]] = $transaction;
    }
    foreach ($outcome as $transaction) {
        $result[$transaction[BILLING_TRANSACTION_FIELD_STARTED] << 32 | $transaction[BILLING_TRANSACTION_FIELD_ID]] = $transaction;
    }
    krsort($result);
    return $result;
}
示例#4
0
function billing_balance_get_accounts($accIds)
{
    lets_use('storage_db');
    return storage_db_get_rows(BILLING_BALANCE_DB_TABLE, '*', [[BILLING_BALANCE_FIELD_ACCOUNT_ID, $accIds]], [], BILLING_BALANCE_FIELD_ACCOUNT_ID);
}
示例#5
0
function web_controller_order_mine()
{
    lets_use('storage_db', 'order_storage', 'user_self');
    $posts = order_storage_get_by_user(user_self_id());
    $authors = [];
    if ($posts) {
        $authors = storage_db_get_rows('users', '*', [['id', array_unique(array_column($posts, 'author_id'))]], [], 'id');
    }
    web_router_render_page('order', 'list', ['posts' => $posts, 'authors' => $authors]);
}
示例#6
0
function order_storage_get_author_list($userId)
{
    lets_use('storage_db');
    return storage_db_get_rows('orders', '*', null, ['ORDER BY' => 'id DESC']);
}
示例#7
0
function storage_db_get_value($table, $col, $where, $cond = [])
{
    $result = storage_db_get_rows($table, $col, $where, ['LIMIT' => 1]);
    return $result ? $result[0][$col] : $result;
}