Marketplace

GetOrderBasket
GET /getOrderBasket/{login}

Метод формирования страницы корзины

Path variables

login
string required

Идентификатор покупателя

Example:
DISAVLE

Notes

Запрос потоварно в БД:

select 
  p.id_product, 
  p.photo, 
  p.name, 
  p.price, 
  c.name, 
  s.name, 
  b.quantity, 
  e.seller_name, 
  e.review, 
  f.isFav 
from 
  basket b 
  left join product_line pl on pl.product_line_id = b.product_line_id 
  left join product p on p.id_product = pl.id_product 
  left join color_prod c on c.id_product = p.id.product 
  left join size_prod s on s.id_product = p.id_product 
  left join product_evalution e on e.id_product = p.id_product 
  left join favourites f on f.id_product = p.id_product 
where 
  b.login = '{login}'

На беке потом считаем итого сумму и кол-во

Responses

200 OK
Body
Object
code
number required

Код ответа

Example:
1
error
string

Текст ошибки

Example:
error
WareList
Array required

Список товаров в корзине

Object
productId
integer required

идентификатор товара

Example:
1234
photoUrl
string required

Ссылка на фото товара

Example:
https://media.giphy.com/media/jp7jSyjNNz2ansuOS8/giphy.gif
name
string required

Наименование товара

Example:
мяч
price
number required

Цена товара

Example:
1000
color
string required

Цвет товара

Example:
Серо-буро-малиновый
size
string required

Размер товара

Example:
RU 56
quantity
integer required

Количество товара

Example:
1
sellerName
string required

Наименование продавца

Example:
Яндекс
reviewCount
integer required

Количество звезд для отзыва

Example:
5
isFav
boolean required

Флаг избранности товара

Example:
true
totalPrice
number required

Цена итого

Example:
2000
totalQuantity
integer required

Количество итого

Example:
2
Example 1
GET /getOrderBasket/DISAVLE HTTP/1.1 

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "error",
    "WareList": [
        {
            "productId": 1234,
            "photoUrl": "https://media.giphy.com/media/jp7jSyjNNz2ansuOS8/giphy.gif",
            "name": "мяч",
            "price": 1000,
            "color": "Серо-буро-малиновый",
            "size": "RU 56",
            "quantity": 1,
            "sellerName": "Яндекс",
            "reviewCount": 5,
            "isFav": true
        }
    ],
    "totalPrice": 2000,
    "totalQuantity": 2
}
ChangeFavourites
POST /changeFavourites

Добавление/удаление избранного товара

Notes

Запрос на обновления списка фаворитов

update 
  favourites 
set 
  isFav = {isFav} 
where 
  login = {login} 
  and id_product = {productID}

Request body

Object
login
string required

логин пользователя

Example:
DISAVLE
wareList
Array required

список товаров

Object
productId
string required

идентификатор товара

Example:
1234
isFav
boolean required

флаг

Example:
true

Responses

200 OK
Body
Object
code
number required

код ответа

Example:
1
error
string

текст ошибки

Example:
error
Example 1
POST /changeFavourites HTTP/1.1 

Content-Type: application/json

{
    "login": "DISAVLE",
    "wareList": [
        {
            "productId": "1234",
            "isFav": true
        }
    ]
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": ""
}
ProcessBasket
POST /processBasket

Метод перерасчета корзины

Notes

Перерасчет корзины, узнаем актульные цены

select 
p.id_product, 
p.price
from product p
where p.id_product = '{productID}' 

Считаем тотал суммы и кол-ва

Request body

Object
productList
Object required

список товаров в корзине

productId
integer required

ид товара

Example:
1234
quantity
integer required

кол-во товара

Example:
2

Responses

200 OK
Body
Object
code
number required

код ответа

Example:
1
error
string

текст ошибки

Example:
ошибка
productList
Array required

список товаров

Object
productId
integer required

идентификатор товара

Example:
1234
price
number required

цена

Example:
1000
Example 1
POST /processBasket HTTP/1.1 

Content-Type: application/json

{
    "productList": {
        "productId": 1234,
        "quantity": 2
    }
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "ошибка",
    "productList": [
        {
            "productId": 1234,
            "price": 1000
        }
    ]
}
GetOrderPayDel
GET /getOrderPayDel/{login}

Метод доставки и способа оплаты

Path variables

login
string required

логин пользователя

Notes

СД - энам на фронте 0 - Доставка; 1 - ПВЗ. СО - энам на фронте 0 - картой; 1 - при получении

Получаем инфу для страницы

 select 
      p.id_product, 
      p.price, 
      b.quantity, 
      ad.adres,
      c.num
    from 
      basket b 
      left join product_line pl on pl.product_line_id = b.product_line_id 
      left join product p on p.id_product = pl.id_product 
      left join card c on c.login = b.login 
      left join adress ad on ad.login = ad.login

    where 
      b.login = '{login}'

Получаем список ПВЗ

 select p.name, p.adress from pickpoint p

Responses

200 OK
Body
Object
code
number required

код ответа

Example:
1
error
string

текст ошибки

infoList
Object

список инфы

card
string

карта

Example:
1000 0000 0000 0000
adress
string

адрес

Example:
Москва, ул Пупкина, д 3
pickPointList
Object

список ПВЗ

name
string required

наименование ПВЗ

Example:
PickPoint
adress
string required

адрес ПВЗ

Example:
Москва, ул Пупкина, д 3
totalPrice
number

итого сумма

Example:
1000
totalQuantity
integer

итого кол-во

Example:
2
Example 1
GET /getOrderPayDel/{login} HTTP/1.1 

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "",
    "infoList": {
        "card": "1000 0000 0000 0000",
        "adress": "Москва, ул Пупкина, д 3"
    }
}
GetOptions
POST /getOptions

Метод доступных опций получения

select 
  p.id_product, 
  p.quantity_in_stock 
from 
  basket b 
  left join product_line pl on pl.product_line_id = b.product_line_id 
  left join product p on p.id_product = pl.id_product 
where 
  b.login = '{login}'

если все товары доступны, то ок, иначе ошибка

Request body

Object
productList
Object

список товаров

productId
integer

ид товара

Example:
1234
quantity
integer

кол-во

Example:
2

Responses

200 OK
Body
Object
code
integer

код ответа

Example:
1
error
string

текст ошибки

Example:
ошибка
Example 1
POST /getOptions HTTP/1.1 

Content-Type: application/json

{
    "productList": {
        "productId": 1234,
        "quantity": 2
    }
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "ошибка"
}
ChangeClientAdress
POST /changeClientAdress

Метод добавления/изменения адреса

Notes

Запрос на обновления адреса клиента

update 
  buyer 
set 
  adress = {adress} 
where 
  login = {login}

Request body

Object
login
string required

логин пользователя

adress
string required

адрес

Responses

200 OK
Body
Object
code
integer required

код ответа

Example:
1
error
string

текст ошибки

Example:
ошибка
Example 1
POST /changeClientAdress HTTP/1.1 

Content-Type: application/json

{
    "login": "",
    "adress": ""
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "ошибка"
}
ChangeClientCard
POST /changeClientCard

Метод добавления/изменения адреса

Notes

Запрос на обновления карты клиента

update 
  card 
set 
  num = {card} 
where 
  login = {login}

Request body

Object
login
string required

логин пользователя

card
string required

карта

Responses

200 OK
Body
Object
code
integer required

код ответа

Example:
1
error
string

текст ошибки

Example:
ошибка
Example 1
POST /changeClientCard HTTP/1.1 

Content-Type: application/json

{
    "login": "",
    "card": ""
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "ошибка"
}
CreateOrder
POST /createOrder

Метод создания заказа

Notes

запрос на создания заказа

insert into order (
basketId, productId, price, color, 
size, quantity, sellerName, totalPrice, 
totalQuantity, card, adress, receivingMethod, 
patmentMethod
) 
values 
(...)

Request body

Object
basketId
string

ид корзины

WareList
Array

список товаров

Object
productId
integer required

ид товара

Example:
1234
price
integer required

цена

Example:
1000
color
string required

цвет

size
string required

размер

Example:
RU 56
quantity
integer required

кол-во

Example:
1
sellerName
string required

наименование продавца

Example:
Яндекс
totalPrice
integer required

итого цена

Example:
2000
totalQuantity
integer required

итого кол-во

Example:
2
card
string

карта

adress
string required

адрес

receivingMethod
string required

способ получения

paymentMethod
string required

способ оплаты

Responses

200 OK
Body
Object
code
integer
Example:
1
error
string
Example:
ошибка
Example 1
POST /createOrder HTTP/1.1 

Content-Type: application/json

{
    "basketId": "",
    "WareList": [
        {
            "productId": 1234,
            "price": 1000,
            "color": "",
            "size": "RU 56",
            "quantity": 1,
            "sellerName": "Яндекс"
        }
    ],
    "totalPrice": 2000,
    "totalQuantity": 2,
    "card": "",
    "adress": "",
    "receivingMethod": "",
    "paymentMethod": ""
}

HTTP/1.1 200 OK 

Content-Type: application/json

{
    "code": 1,
    "error": "ошибка"
}