コード例 #1
0
ファイル: storage.php プロジェクト: ekudel/vkt
/**
 * Return:
 * null - error
 * false - no object
 * balance - success
 */
function markOrderExecuted($orderId, $customerId, $executorId, $commission)
{
    $userInfo = getUserInfoById($executorId);
    if (!$userInfo || getIfExists($userInfo, 'role') !== ROLE_EXECUTOR) {
        return null;
    }
    $dbInfo = getDbForWaitingOrders($customerId);
    $link = $dbInfo ? connect($dbInfo) : null;
    if (!$link || !\database\beginTransaction($link)) {
        return null;
    }
    $result = doMarkOrderExecuted($link, $orderId, $customerId, $executorId, $commission);
    if (!$result) {
        \database\rollbackTransaction($link);
        return $result;
    }
    $userInfo = \storage\getUserInfoById($executorId);
    if (!$userInfo) {
        \database\rollbackTransaction($link);
        return null;
    }
    return \database\commitTransaction($link) ? $userInfo['balance'] : null;
}
コード例 #2
0
ファイル: get_my_orders.php プロジェクト: ekudel/vkt
}
$list = [];
foreach ($orders as $order) {
    $element = ['order_id' => getCompositeOrderId($order), 'customer_id' => $order['customer_id'], 'description' => $order['description'], 'time' => $order['time']];
    $price = getIfExists($order, 'price');
    if ($price) {
        $element['price'] = number_format($price, 2);
    }
    $profit = getIfExists($order, 'profit');
    if ($profit) {
        $element['profit'] = $profit;
    }
    $doneTime = getIfExists($order, 'done_time');
    if ($doneTime) {
        $element['done_time'] = $doneTime;
    }
    if ($role === ROLE_CUSTOMER) {
        $executorId = getIfExists($order, 'executor_id');
        $executorInfo = $executorId ? \storage\getUserInfoById($executorId) : null;
        $executorName = $executorInfo ? getIfExists($executorInfo, 'name') : null;
        if (!is_null($executorName)) {
            $element['executor'] = $executorName;
        }
    }
    array_push($list, $element);
    if (sizeof($list) == $count) {
        break;
    }
}
$hasMore = sizeof($orders) > $count;
echo jsonEncode(['list' => $list, 'has_more' => $hasMore ? 'true' : 'value']);
コード例 #3
0
ファイル: index.php プロジェクト: ekudel/vkt
<?php

require_once 'libraries/common.php';
$userId = \sessions\getCurrentUserId();
if (!is_null($userId)) {
    $userInfo = \storage\getUserInfoById($userId);
    if (is_null($userInfo)) {
        \sessions\logout();
    }
} else {
    $userInfo = null;
}
if (is_null($userInfo)) {
    $title = msg('login.title');
    ob_start();
    include 'login.php';
    $content = ob_get_clean();
} else {
    $title = msg('home.title');
    ob_start();
    if ($userInfo['role'] == ROLE_EXECUTOR) {
        include 'home_executor.php';
    } else {
        include 'home_customer.php';
    }
    $content = ob_get_clean();
}
include 'main_template.php';