Esempio n. 1
0
function rcl_edit_balance_user()
{
    $user_id = intval($_POST['user']);
    $balance = intval($_POST['balance']);
    $oldusercount = rcl_get_user_money($user_id);
    $new_cnt = $balance - $oldusercount;
    if (!$new_cnt) {
        return false;
    }
    if ($new_cnt < 0) {
        $type = 1;
    } else {
        $type = 2;
    }
    rcl_update_user_money($balance, $user_id);
    $new_cnt = abs((int) $new_cnt);
    do_action('admin_edit_user_count_rcl', $user_id, $new_cnt, __('The change in the balance', 'wp-recall'), $type);
    $log['otvet'] = 100;
    $log['user'] = $user_id;
    $log['balance'] = $balance;
    echo json_encode($log);
    exit;
}
 function pay_account($data)
 {
     if ($data->pay_type != 1) {
         return false;
     }
     $oldcount = rcl_get_user_money($data->user_id);
     if ($oldcount) {
         $newcount = $oldcount + $data->pay_summ;
     } else {
         $newcount = $data->pay_summ;
     }
     rcl_update_user_money($newcount, $data->user_id);
     do_action('payment_payservice_rcl', $data->user_id, $data->pay_summ, __('Top up personal account', 'wp-recall'), 2);
 }
function rcl_pay_order_private_account()
{
    global $user_ID, $wpdb, $rmag_options, $order;
    $order_id = intval($_POST['idorder']);
    if (!$order_id || !$user_ID) {
        $log['otvet'] = 1;
        echo json_encode($log);
        exit;
    }
    $order = rcl_get_order($order_id);
    //rcl_setup_orderdata($order);
    $oldusercount = rcl_get_user_money();
    if (!$oldusercount) {
        $log['otvet'] = 1;
        $log['recall'] = $order->order_price;
        echo json_encode($log);
        exit;
    }
    //print_r($order);
    $newusercount = $oldusercount - $order->order_price;
    if ($newusercount < 0) {
        $log['otvet'] = 1;
        $log['recall'] = $order->order_price;
        echo json_encode($log);
        exit;
    }
    rcl_update_user_money($newusercount);
    $result = rcl_update_status_order($order_id, 2);
    if (!$result) {
        $log['otvet'] = 1;
        $log['recall'] = 'Ошибка запроса!';
        echo json_encode($log);
        exit;
    }
    rcl_payment_order($order_id, $user_ID);
    do_action('payment_rcl', $user_ID, $order->order_price, $order_id, 2);
    $text = "<p>Ваш заказ успешно оплачен! Соответствующее уведомление было выслано администрации сервиса.</p>";
    $text = apply_filters('payment_order_text', $text);
    $log['recall'] = "<div style='clear: both;color:green;font-weight:bold;padding:10px; border:2px solid green;'>" . $text . "</div>";
    $log['count'] = $newusercount;
    $log['idorder'] = $order_id;
    $log['otvet'] = 100;
    echo json_encode($log);
    exit;
}