add order route
This commit is contained in:
@@ -221,6 +221,37 @@ function client_find_email_kuri($mail){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# узнаем id клиента по мылу или создаем его
|
||||||
|
function api_add_client($mail){
|
||||||
|
|
||||||
|
$find_mail = dbl_get("SELECT `client_id`, `clienthash` FROM `clients` WHERE `clientmail` = '$mail' LIMIT 1");
|
||||||
|
|
||||||
|
if (isset($find_mail['client_id'])){
|
||||||
|
$result = $find_mail['clienthash'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$add['clientmail'] = $mail;
|
||||||
|
$add['clienthash'] = md5($mail);
|
||||||
|
$add['clientdate'] = date("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
$res = db_insert('clients', $add, 'chitatel');
|
||||||
|
|
||||||
|
if ($res > 0){
|
||||||
|
$result = $add['clienthash'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function client_find_hash($hash){
|
function client_find_hash($hash){
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ function bookid_kuri($slug) {
|
|||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT
|
SELECT
|
||||||
`price_id`, `pricename`, `categoryname`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `price`, `sub`
|
`price_id`, `pricename`, `categoryname`, `priceslug`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `price`, `offline_price`, `sub`
|
||||||
FROM
|
FROM
|
||||||
`price`
|
`price`
|
||||||
LEFT JOIN `pricecategory`
|
LEFT JOIN `pricecategory`
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ define('VIEWPATH', SITEPATH.'views/');
|
|||||||
define('API', 'http://api.argumenti.ru/');
|
define('API', 'http://api.argumenti.ru/');
|
||||||
define('IMGSRV', 'https://imgurl.argumenti.ru/');
|
define('IMGSRV', 'https://imgurl.argumenti.ru/');
|
||||||
|
|
||||||
|
define('PAYSITE', 'https://pay.argumenti.ru/'); //сервис оплаты
|
||||||
|
|
||||||
/** отправка уведомлений */
|
/** отправка уведомлений */
|
||||||
/*set('noreply',
|
/*set('noreply',
|
||||||
[
|
[
|
||||||
@@ -57,3 +59,4 @@ db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOh
|
|||||||
db_config('chitatel', 'mysql:host=mysql;dbname=argumentiru', 'chitatel', 'hjYu78kl*90Uio');
|
db_config('chitatel', 'mysql:host=mysql;dbname=argumentiru', 'chitatel', 'hjYu78kl*90Uio');
|
||||||
db_config('klan', 'mysql:host=mysql;dbname=argumentiru', 'klan', 'zpFGhyuRty765Jk');
|
db_config('klan', 'mysql:host=mysql;dbname=argumentiru', 'klan', 'zpFGhyuRty765Jk');
|
||||||
|
|
||||||
|
// GRANT ALL PRIVILEGES ON argumentiru.* TO 'hitatel'@'%' IDENTIFIED BY 'hjYu78kl*90Uio'
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ require 'routes/auth.php';
|
|||||||
require 'routes/pdfserver.php';
|
require 'routes/pdfserver.php';
|
||||||
require 'routes/email.php';
|
require 'routes/email.php';
|
||||||
require 'routes/books.php';
|
require 'routes/books.php';
|
||||||
|
require 'routes/order.php';
|
||||||
|
|
||||||
#api
|
#api
|
||||||
require 'api/apiclient.php';
|
require 'api/apiclient.php';
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ function product_kuri($slug){
|
|||||||
|
|
||||||
$book = bookid_kuri($slug);
|
$book = bookid_kuri($slug);
|
||||||
|
|
||||||
|
|
||||||
$breadcrumbs = [
|
$breadcrumbs = [
|
||||||
$book['categoryname'] => SITE.'category/'.$book['categoryslug'],
|
$book['categoryname'] => SITE.'category/'.$book['categoryslug'],
|
||||||
'page' => $book['pricename']
|
'page' => $book['pricename']
|
||||||
@@ -25,6 +24,11 @@ function product_kuri($slug){
|
|||||||
# купил ли эту книжку
|
# купил ли эту книжку
|
||||||
$buy_status = client_status_book($books['book_id'], CLIENT_ID);
|
$buy_status = client_status_book($books['book_id'], CLIENT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# линки на оформление заказа
|
||||||
|
$link_online = SITE.'checkout/'.$book['priceslug'].'/1';
|
||||||
|
$link_offline = SITE.'checkout/'.$book['priceslug'].'/2';
|
||||||
|
$link_subscript = SITE.'checkout/podpiska-na-elektronnuyu-versiyu-gazety-argumenty-nedeli-na-god/1';
|
||||||
|
|
||||||
$tempcontent = VIEWPATH.'book.phtml';
|
$tempcontent = VIEWPATH.'book.phtml';
|
||||||
include VIEWPATH.'layout.phtml';
|
include VIEWPATH.'layout.phtml';
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ function restoration_kuri(){
|
|||||||
$hashlink = SITE.'resetlink/'.$hash;
|
$hashlink = SITE.'resetlink/'.$hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $hashlink;
|
|
||||||
|
|
||||||
$tempcontent = VIEWPATH.'restore_add.phtml';
|
$tempcontent = VIEWPATH.'restore_add.phtml';
|
||||||
include VIEWPATH.'layout.phtml';
|
include VIEWPATH.'layout.phtml';
|
||||||
}
|
}
|
||||||
|
|||||||
69
app/routes/order.php
Normal file
69
app/routes/order.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* оформление заказа
|
||||||
|
*/
|
||||||
|
|
||||||
|
function checkout_kuri($priceslug, $buy_type = 1){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$price_id = db_get("SELECT * FROM `price` WHERE `priceslug` = '$priceslug' LIMIT 1");
|
||||||
|
|
||||||
|
if (isset($price_id['price_id'])) {
|
||||||
|
|
||||||
|
|
||||||
|
if ($buy_type == 1){ // тип товара
|
||||||
|
$price = $price_id['price']; // электронная книжка
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$price = $price_id['offline_price']; // бумажная книжка
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (defined('CLIENT_ID')){
|
||||||
|
|
||||||
|
$client = client_find_id(CLIENT_ID);
|
||||||
|
|
||||||
|
if (isset($client['result']['client_id'])){
|
||||||
|
$clienthash = $client['result']['clienthash'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['clientmail'])){
|
||||||
|
|
||||||
|
$clientmail = $_POST['clientmail'];
|
||||||
|
|
||||||
|
if (!filter_var($clientmail, FILTER_VALIDATE_EMAIL)){
|
||||||
|
$error_mail = True;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# получаем хэш клиента чтобы отправить на оплату
|
||||||
|
$clienthash = api_add_client($clientmail);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($clienthash) and $clienthash) {
|
||||||
|
$paylink = PAYSITE."anpay/$priceslug/$clienthash";
|
||||||
|
header("Location: $paylink");
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error_price = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
$submit_link = SITE."checkout/$priceslug/$buy_type";
|
||||||
|
|
||||||
|
include VIEWPATH.'checkout.phtml';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,8 +12,16 @@
|
|||||||
<p class="price"><a href="<?=$book['links']['download']?>">Скачать PDF</a></p>
|
<p class="price"><a href="<?=$book['links']['download']?>">Скачать PDF</a></p>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
<?else:?>
|
<?else:?>
|
||||||
<?$paylink = 'https://argumenti.ru/robomail/'.$book['price_id']?>
|
|
||||||
<p class="price"><a href="<?=$paylink?>">Купить за <?=$book['price']?> руб.</a></p>
|
<?if ($book['price'] > 0):?>
|
||||||
|
<p class="price"><a href="<?=$link_online?>">Электронная за <?=$book['price']?> руб.</a></p>
|
||||||
|
<?endif?>
|
||||||
|
<?if ($book['sub'] == 1):?>
|
||||||
|
<p class="price"><a href="<?=$link_subscript?>">Доступ к библиотеке за 490 руб. в год</a></p>
|
||||||
|
<?endif?>
|
||||||
|
<?if ($book['offline_price'] > 0):?>
|
||||||
|
<p class="price"><a href="<?=$link_offline?>">Бумажная за <?=$book['offline_price']?> руб.</a></p>
|
||||||
|
<?endif?>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
24
app/views/checkout.phtml
Normal file
24
app/views/checkout.phtml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<?if (isset($error_price)):?>
|
||||||
|
<p style="color: red;">Просим прощения, но такой товар не найден!</p>
|
||||||
|
<?else:?>
|
||||||
|
|
||||||
|
<form id="clientform" class="clientform" action="<?=$submit_link?>" method="POST">
|
||||||
|
|
||||||
|
<?if (isset($error_mail)):?>
|
||||||
|
<p style="color: red;">Неверный адрес электронной почты</p>
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
<p><label for="clientmail">Для покупки этого товара введите свой электронный адрес ниже:</label></p>
|
||||||
|
<p><input type="email" id="clientemail" name="clientmail"></p>
|
||||||
|
<p><label>Нажимая кнопку «Купить», я соглашаюсь <a href="https://argumenti.ru/subscribe_condition">с условиями подписки</a></label></p>
|
||||||
|
<p><input type="submit" id="submit" value="Купить"></p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user